## Code for estimating equation for different values of a certain variable and storing residuals

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt

AnwaarAlam92
Posts: 2
Joined: Mon Oct 02, 2017 1:13 am

### Code for estimating equation for different values of a certain variable and storing residuals

Hello!

I am estimating a threshold model of the form: y = c + a*x(z<theta) + b*x(z>=theta)

where z lowest value< theta <z highest value

what I want to do is to estimate this model for all values of "z" variable starting from the lowest value to the highest value, and storing the SSR of each regression along with the value of "z" variable used in the regression.

so lets suppose the lowest value of z is 0.5 and 2nd lowest is 0.6 I want to estimate y = c + a*x(z<0.5) + b*x(z>=0.5) and y = c + a*x(z<0.6) + b*x(z>=0.6) respectively, upto the highest value of z.

I am new to eviews programming so any suggestions would really help me learn the programming syntax.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 11942
Joined: Tue Sep 16, 2008 5:38 pm

### Re: Code for estimating equation for different values of a certain variable and storing residuals

AnwaarAlam92
Posts: 2
Joined: Mon Oct 02, 2017 1:13 am

### Re: Code for estimating equation for different values of a certain variable and storing residuals

So far I have done this

vector v = @convert(z)

vector v1 = @sort (v,"a","i")

'set buffer on either side of sample
!j=11

for !i=!j to v1.@rows-!j

equation eq{!i}.ls y = c(1) + c(2)*x*(z<(v1(!i))) + c(3)*x*(z(-1)>=(v1(!i)))

eq{!i}.makeresids res{!i}

next

its working