Multiequation non-linear least square estimation

For technical questions regarding estimation of single equations, systems, VARs, Factor analysis and State Space Models in EViews. General econometric questions and advice should go in the Econometric Discussions forum.

Moderators: EViews Gareth, EViews Moderator

tanghaar
Posts: 15
Joined: Mon Aug 15, 2011 6:02 am

Multiequation non-linear least square estimation

Postby tanghaar » Mon Aug 15, 2011 6:13 am

Hello,

I'm finishing my bachelor thesis and I'm stuck at writing the estimation equation into EViews (vers. 7). I'm going into Object -> New Object -> Equation -> OLS (NLS...). Here, where I have to write the equation that I want to estimate I get stuck. I simply do not know how to actually write it into EViews, so please help. My deadline for the bachelor thesis is beginning to get rather close and it is the only thing I need before it can be finished it in a days time, so please help! Thanks alot!

The equation I want to estimate is:
log(w_j)= a_0 + a_1*log( Sum( Y_r^a_2 * W_r^a_3 * H_r^a_4 * e^(D_j,r * a_5))) , for all j=1,...,78.

Where, a_x is alpha number x, Y is income, W is wage, H is housing stock and D_j,r is distance in minutes from region j to region r. e is the inverse natural log. The sum is the sum of the product for all the regions, such that Y1*W1*H1*e^Dj1 + Y2*W2*H2*e^Dj2 .... Y78*W78*H78*e^Dj,78 , for all j=1, ... , 78. I have valid guesses for all the alphas.
Now, I have in total 78 of these equations that should be estimated simultaneously, such that:

log(w_1)= a_0 + a_1*log( Sum( Y_r^a_2 * W_r^a_3 * H_r^a_4 * e^(D_1,r * a_5)))
.
.
.
log(w_78)= a_0 + a_1*log( Sum( Y_r^a_2 * W_r^a_3 * H_r^a_4 * e^(D_78,r * a_5)))

I would really appreciate your help! Just write if you have anything you want clarified or whatever. I'll check this forum several times a day, so expect quick reply.
Once again, thanks!

//tanghaar

tanghaar
Posts: 15
Joined: Mon Aug 15, 2011 6:02 am

Re: Multiequation non-linear least square estimation

Postby tanghaar » Mon Aug 15, 2011 8:57 am

So far I have tried with this, but I get error with the @rsum saying that it lags Group argument (this is only sample for 20 first equations):

log(_98w1) = c(1) + c(2)*log(@rsum(y98^c(3)*y98^c(4)*y98^c(5)*exp(d1*c(6))))
log(_98w2) = c(1) + c(2)*log(@rsum(y98^c(3)*y98^c(4)*y98^c(5)*exp(d2*c(6))))
log(_98w3) = c(1) + c(2)*log(@rsum(y98^c(3)*y98^c(4)*y98^c(5)*exp(d3*c(6))))
log(_98w4) = c(1) + c(2)*log(@rsum(y98^c(3)*y98^c(4)*y98^c(5)*exp(d4*c(6))))
log(_98w5) = c(1) + c(2)*log(@rsum(y98^c(3)*y98^c(4)*y98^c(5)*exp(d5*c(6))))
log(_98w6) = c(1) + c(2)*log(@rsum(y98^c(3)*y98^c(4)*y98^c(5)*exp(d6*c(6))))
log(_98w7) = c(1) + c(2)*log(@rsum(y98^c(3)*y98^c(4)*y98^c(5)*exp(d7*c(6))))
log(_98w8) = c(1) + c(2)*log(@rsum(y98^c(3)*y98^c(4)*y98^c(5)*exp(d8*c(6))))
log(_98w9) = c(1) + c(2)*log(@rsum(y98^c(3)*y98^c(4)*y98^c(5)*exp(d9*c(6))))
log(_98w10) = c(1) + c(2)*log(@rsum(y98^c(3)*y98^c(4)*y98^c(5)*exp(d10*c(6))))
log(_98w11) = c(1) + c(2)*log(@rsum(y98^c(3)*y98^c(4)*y98^c(5)*exp(d11*c(6))))
log(_98w12) = c(1) + c(2)*log(@rsum(y98^c(3)*y98^c(4)*y98^c(5)*exp(d12*c(6))))
log(_98w13) = c(1) + c(2)*log(@rsum(y98^c(3)*y98^c(4)*y98^c(5)*exp(d13*c(6))))
log(_98w14) = c(1) + c(2)*log(@rsum(y98^c(3)*y98^c(4)*y98^c(5)*exp(d14*c(6))))
log(_98w15) = c(1) + c(2)*log(@rsum(y98^c(3)*y98^c(4)*y98^c(5)*exp(d15*c(6))))
log(_98w16) = c(1) + c(2)*log(@rsum(y98^c(3)*y98^c(4)*y98^c(5)*exp(d16*c(6))))
log(_98w17) = c(1) + c(2)*log(@rsum(y98^c(3)*y98^c(4)*y98^c(5)*exp(d17*c(6))))
log(_98w18) = c(1) + c(2)*log(@rsum(y98^c(3)*y98^c(4)*y98^c(5)*exp(d18*c(6))))
log(_98w19) = c(1) + c(2)*log(@rsum(y98^c(3)*y98^c(4)*y98^c(5)*exp(d19*c(6))))
log(_98w20) = c(1) + c(2)*log(@rsum(y98^c(3)*y98^c(4)*y98^c(5)*exp(d20*c(6))))

Furthermore, If i want to make a non-linear least square regression, then any suggestions? Im trying to do it in a system, but i can only find others than NLS (e.g. OLS).
Do you see any other problems in the above? Thanks a lot for the help guys.. !

//tanghaar
Attachments
TEST Values only, Rejsetider, Sverige og Danmark before bridge.xlsx
My data, a test version.
(102.03 KiB) Downloaded 229 times

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

Re: Multiequation non-linear least square estimation

Postby EViews Gareth » Mon Aug 15, 2011 10:26 am

@rsum can only be used to sum across the series in a group, and I'm pretty sure it is not what you want.

I'm not sure I have a grasp on what you're trying to do, but I think, perhaps, you're going to have to write out the sum manually. Either that or what you're trying to do is not possible in EViews.

tanghaar
Posts: 15
Joined: Mon Aug 15, 2011 6:02 am

Re: Multiequation non-linear least square estimation

Postby tanghaar » Mon Aug 15, 2011 10:29 am

I want to take the sum of their products, such that Y_1^a_2 * W_1^a_3 * H_1^a_4 * e^(D_j,1 * a_5) + Y_2^a_2 * W_2^a_3 * H_2^a_4 * e^(D_j,2 * a_5) + ... + Y_78^a_2 * W_78^a_3 * H_78^a_4 * e^(D_j,78 * a_5).

The above is for one of the 78 equations btw.

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

Re: Multiequation non-linear least square estimation

Postby EViews Gareth » Mon Aug 15, 2011 10:31 am

You'll have to write it out manually.

tanghaar
Posts: 15
Joined: Mon Aug 15, 2011 6:02 am

Re: Multiequation non-linear least square estimation

Postby tanghaar » Mon Aug 15, 2011 10:43 am

I'll just ask the question another way, just to double check.
I have the following data:

y98 w98 h98 D1
9.96 133891 10050 0
2.13 173459 135764 87
4.94 141515 5484 113
6.73 158883 7784 81
. . . .
. . . .
. . . .

So, I what I will have to do with each equation is this: 9.96^c(3)*133891^c(4)*10050^c(5)*exp(0*^c(6))+2.13^c(3)*173459^c(4)*135764^c(5)*exp(87*x(6)) + ....
right? Is that really the quickest way?

And, is it correct of me to do it in object -> new object -> system ?
My problem is that it is non-linear least squares, and 'system' does not have that option. Do you have any suggestions to what I might do instead?
Thanks a lot for your help!

//tanghaar

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

Re: Multiequation non-linear least square estimation

Postby EViews Gareth » Mon Aug 15, 2011 10:44 am

System ols incorporates nls

tanghaar
Posts: 15
Joined: Mon Aug 15, 2011 6:02 am

Re: Multiequation non-linear least square estimation

Postby tanghaar » Mon Aug 15, 2011 10:46 am

Okay thanks. Ill take a thinking break to see if there is some easier way - otherwise ill just start brute force :)

Btw. If I want to specify starting values for the iteration of the c(x) in 'system'. What should I do then?

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

Re: Multiequation non-linear least square estimation

Postby EViews Gareth » Mon Aug 15, 2011 10:52 am

Just fill the c vector in your workfile with the values you want.

tanghaar
Posts: 15
Joined: Mon Aug 15, 2011 6:02 am

Re: Multiequation non-linear least square estimation

Postby tanghaar » Mon Aug 15, 2011 10:55 am

Well, Im 100 % sure that the values I put in is wrong. I just know that they are close to the real values. My understanding of the iteration that is done in NLS is that it is improved when it has good guesses as starting value. So if im writing 7.4 instead of c(5), then it doesnt change it, does it?

Sorry for the 'stupid question'.

Thanks :)

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

Re: Multiequation non-linear least square estimation

Postby EViews Gareth » Mon Aug 15, 2011 10:58 am

EViews will only optimise over coefficients specified in the system. If you write a number rather than a coefficient, then, no, EViews will not optimise it.

tanghaar
Posts: 15
Joined: Mon Aug 15, 2011 6:02 am

Re: Multiequation non-linear least square estimation

Postby tanghaar » Mon Aug 15, 2011 10:59 am

Okay thanks man. Now I have atleast reached some sort of conclusion. I have went through three statistical packages (R, SPSS and EViews) and havent been able to solve my problem yet. Seems like I have to kill my self to get the results :)

Cheers :)

tanghaar
Posts: 15
Joined: Mon Aug 15, 2011 6:02 am

Re: Multiequation non-linear least square estimation

Postby tanghaar » Mon Aug 15, 2011 3:19 pm

Hello again!

I have now made all the 78 equations manually and each looks more or less like the one shown below. Now I get an 'unmatched parenthesis' error. I have went through the equation and I cannot see that I miss either a left or a right parenthesis, so what is wrong? :) And beside that problem, can you see any other problems with it (also see attachment, which includes all the equations that I want to estimate simultaneously)? My procedure is, in 'system' to copy the attached file in, go 'Proc' -> 'Estimate' and then OLS and o.k..

Thanks a lot in advance!

log(146591.455)=c(1)+c(2)*log(987293449.4^c(3)*146591.455^c(4)*10056^c(5)*exp(0*c(6))+23027634432^c(3)*187596.3082^c(4)*136326^c(5)*exp(87*c(6))+511300277.4^c(3)*139205.0851^c(4)*5484^c(5)*exp(113*c(6))+721161417.4^c(3)*148234.6182^c(4)*7850^c(5)*exp(81*c(6))+1114084298^c(3)*178367.6429^c(4)*6632^c(5)*exp(87*c(6))+893838543.8^c(3)*146964.5748^c(4)*11733^c(5)*exp(88*c(6))+812677299.5^c(3)*138705.803^c(4)*6555^c(5)*exp(92*c(6))+489547748.6^c(3)*133137.8158^c(4)*4352^c(5)*exp(125*c(6))+892062093.4^c(3)*180725.7077^c(4)*6099^c(5)*exp(128*c(6))+1054440769^c(3)*163327.2567^c(4)*10159^c(5)*exp(98*c(6))+686058512.3^c(3)*173159.6447^c(4)*7280^c(5)*exp(90*c(6))+1044780569^c(3)*176841.6671^c(4)*7064^c(5)*exp(74*c(6))+481794518.2^c(3)*141247.2935^c(4)*6142^c(5)*exp(62*c(6))+657196784.7^c(3)*137287.818^c(4)*7368^c(5)*exp(49*c(6))+546139066^c(3)*141928.0317^c(4)*6119^c(5)*exp(74*c(6))+580495004^c(3)*143438.3504^c(4)*5743^c(5)*exp(86*c(6))+606947729.8^c(3)*129302.8824^c(4)*6024^c(5)*exp(30*c(6))+835562377.1^c(3)*178006.4715^c(4)*5453^c(5)*exp(86*c(6))+702005406.3^c(3)*154049.9026^c(4)*6337^c(5)*exp(109*c(6))+790954987.5^c(3)*196999.9969^c(4)*3495^c(5)*exp(116*c(6))+846806690.9^c(3)*161204.3958^c(4)*7882^c(5)*exp(131*c(6))+745492027.3^c(3)*164169.1317^c(4)*5998^c(5)*exp(127*c(6))+792273514.2^c(3)*163153.5243^c(4)*6843^c(5)*exp(151*c(6))+9645742236^c(3)*198227.3374^c(4)*46817^c(5)*exp(83*c(6))+2419983296^c(3)*161839.3163^c(4)*19024^c(5)*exp(107*c(6))+9369786908^c(3)*181072.6802^c(4)*57962^c(5)*exp(119*c(6))+1045867118^c(3)*160877.8831^c(4)*10207^c(5)*exp(140*c(6))+1642823975^c(3)*168754.3888^c(4)*12889^c(5)*exp(94*c(6))+1594018660^c(3)*156752.7446^c(4)*12972^c(5)*exp(43*c(6))+2248014715^c(3)*181364.6401^c(4)*17596^c(5)*exp(90*c(6))+5636191037^c(3)*163923.7715^c(4)*35142^c(5)*exp(70*c(6))+2287412827^c(3)*161244.3837^c(4)*17294^c(5)*exp(135*c(6))+2943459196^c(3)*168941.0088^c(4)*23194^c(5)*exp(94*c(6))+84682000000^c(3)*246697.8576^c(4)*274570^c(5)*exp(162*c(6))+9764000000^c(3)*244081.6939^c(4)*49801^c(5)*exp(163*c(6))+6272000000^c(3)*303611.1918^c(4)*12315^c(5)*exp(165*c(6))+3377000000^c(3)*268186.1499^c(4)*8915^c(5)*exp(179*c(6))+11554000000^c(3)*296142.5093^c(4)*20392^c(5)*exp(169*c(6))+6795000000^c(3)*297036.1951^c(4)*14974^c(5)*exp(162*c(6))+635000000^c(3)*234490.3988^c(4)*5331^c(5)*exp(156*c(6))+2284000000^c(3)*238837.185^c(4)*14230^c(5)*exp(183*c(6))+3104000000^c(3)*240900.2716^c(4)*25085^c(5)*exp(190*c(6))+3607000000^c(3)*231010.6315^c(4)*17260^c(5)*exp(199*c(6))+2293000000^c(3)*223380.4189^c(4)*12664^c(5)*exp(202*c(6))+4185000000^c(3)*254391.8303^c(4)*14656^c(5)*exp(173*c(6))+8142000000^c(3)*266269.8672^c(4)*31599^c(5)*exp(172*c(6))+9810000000^c(3)*284232.4854^c(4)*29163^c(5)*exp(169*c(6))+5787000000^c(3)*281263.6695^c(4)*9949^c(5)*exp(163*c(6))+2696000000^c(3)*222350.5155^c(4)*16133^c(5)*exp(202*c(6))+5314000000^c(3)*241139.9011^c(4)*26325^c(5)*exp(191*c(6))+4798000000^c(3)*274030.4986^c(4)*12508^c(5)*exp(167*c(6))+6133000000^c(3)*251095.1894^c(4)*17167^c(5)*exp(186*c(6))+6857000000^c(3)*267173.1931^c(4)*23001^c(5)*exp(161*c(6))+8735000000^c(3)*279725.8782^c(4)*19516^c(5)*exp(163*c(6))+2819000000^c(3)*258885.1134^c(4)*10538^c(5)*exp(181*c(6))+2127000000^c(3)*248510.34^c(4)*8733^c(5)*exp(161*c(6))+8579000000^c(3)*273190.4595^c(4)*25589^c(5)*exp(172*c(6))+8424000000^c(3)*301805.675^c(4)*14120^c(5)*exp(176*c(6))+4303000000^c(3)*271431.2748^c(4)*17490^c(5)*exp(164*c(6))+7514000000^c(3)*260766.9617^c(4)*17984^c(5)*exp(151*c(6))+975000000^c(3)*252198.6549^c(4)*5065^c(5)*exp(161*c(6))+2893000000^c(3)*227454.9886^c(4)*13930^c(5)*exp(197*c(6))+3751000000^c(3)*242673.2225^c(4)*19009^c(5)*exp(165*c(6))+5591000000^c(3)*220239.5021^c(4)*29671^c(5)*exp(222*c(6))+5862000000^c(3)*225002.8787^c(4)*27295^c(5)*exp(194*c(6))+4482000000^c(3)*230591.1406^c(4)*20474^c(5)*exp(229*c(6))+5672000000^c(3)*240420.4815^c(4)*22022^c(5)*exp(179*c(6))+1526000000^c(3)*240998.1049^c(4)*9646^c(5)*exp(182*c(6))+4438000000^c(3)*222791.1647^c(4)*23979^c(5)*exp(256*c(6))+7052000000^c(3)*223426.1635^c(4)*33326^c(5)*exp(209*c(6))+2642000000^c(3)*215059.0151^c(4)*14021^c(5)*exp(210*c(6))+3846000000^c(3)*245955.1065^c(4)*12737^c(5)*exp(187*c(6))+9465000000^c(3)*245061.2329^c(4)*33934^c(5)*exp(177*c(6))+7720000000^c(3)*225296.212^c(4)*34259^c(5)*exp(205*c(6))+1294000000^c(3)*244012.8229^c(4)*8001^c(5)*exp(172*c(6))+2376000000^c(3)*218081.6888^c(4)*11592^c(5)*exp(196*c(6))+1439000000^c(3)*229140.1274^c(4)*8652^c(5)*exp(203*c(6))+3941000000^c(3)*216657.5041^c(4)*20555^c(5)*exp(210*c(6)))
Attachments
99data.txt
The equations that I want to estimate simultaneously.
(342.79 KiB) Downloaded 241 times

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

Multiequation non-linear least square estimation

Postby EViews Gareth » Mon Aug 15, 2011 3:33 pm

I think there's some wires crossed somewhere. You're probably better off in a package that has a generic optimiser. R might be the best choice.

tanghaar
Posts: 15
Joined: Mon Aug 15, 2011 6:02 am

Re: Multiequation non-linear least square estimation

Postby tanghaar » Mon Aug 15, 2011 3:37 pm

What do you mean by 'wires crossed'?

I sorta want to stick to EViews, since I know that the best..
Thanks :)


Return to “Estimation”

Who is online

Users browsing this forum: No registered users and 2 guests