Basic NLS Help Needed

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

jennie
Posts: 11
Joined: Tue Jul 05, 2011 2:31 pm

Basic NLS Help Needed

Postby jennie » Tue Jul 05, 2011 3:06 pm

Hi,

I am new to eviews and I am trying to run a nonlinear least squares estimation.
I am having trouble programming it and some advice/help would be really great.

The data came from a survey.
I have 28 questions for each participant and i number of of participants.
Each participant is represented by a separate series right now in the workfile.

My equation is:

( p1^c(1) / (p1^(c(1)) - (1-p1)^c(1)) ^ (1/c(1)) ) * z1 ^ c(2) + (1 - ( p1^c(1) / (p1^(c(1)) - (1-p1)^c(1)) ^ (1/c(1)) ) * z2 ^c(2) = series{!i} ^ c(2)

Where p1, z1, z2 are each a series with 28 rows.
series{!i} is a series for each participant from i = 1 to 100 and each particpant and has 28 rows.

I need to estimate c(1) and c(2) in this equation.

When I try to do this I get an error that ^ function given out of range argument.

Code: Select all

' Create a group of the series of subjects group tempGroup for !i = 1 to 100 if !i <10 then tempGroup.add series0{!i} else tempGroup.add series{!i} endif next 'use a starting value of 1 for coefficient 1 and coeffecient 2 'note: I have attempted this with and without a starting value param c(1) 1 c(2) 1 system sys1 for !i = 1 to 100 sys1.append (nn_p1^c(1)) / (nn_p1^c(1) + (1- nn_p1)^c(1)) ^ (1/c(1)) * nn_z1^c(2)+ (1- (nn_p1^c(1)) / (nn_p1^c(1) + (1- nn_p1)^c(1)) ^ (1/c(1))) * nn_z2^c(2) = tempGroup(!i)^c(2) next sys1.ls
Any help/advice would be greatly appreciated. I am feeling pretty lost right now,

Thanks,
Jen

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

Re: Basic NLS Help Needed

Postby EViews Gareth » Tue Jul 05, 2011 3:20 pm

Could you provide the data?

jennie
Posts: 11
Joined: Tue Jul 05, 2011 2:31 pm

Re: Basic NLS Help Needed

Postby jennie » Tue Jul 05, 2011 8:19 pm

Hi,

Here is a copy of the workfile I am using,

Thanks,

Jen
Attachments
survey_data.wf1
(60.34 KiB) Downloaded 471 times

jennie
Posts: 11
Joined: Tue Jul 05, 2011 2:31 pm

Re: Basic NLS Help Needed

Postby jennie » Wed Jul 06, 2011 7:37 am

So I think that in this case I do not want to use a system for the equations, as I need to estimate c(1) and c(2) per subject.

I am trying to loop through the subjects one at a time.
Code looks like this now....

Code: Select all

'Create a group for the subjects. 'Will loop through these for equations after group tempGroup for !i = 1 to 96 if !i <10 then tempGroup.add series0{!i} else tempGroup.add series{!i} endif next 'Start value for coefficient 1 and 2 is 1 'Eventually may need to constrain c(1) between 0.01 and 2 'Eventually may need to constrain c(2) between 0.001 and 10 param c(1) 1 c(2) 1 'loop through each subject and estimate nls for !j = 1 to 96 equation eq{!j}.ls (nn_p1^c(1)) / ( nn_p1^c(1) + (1 - nn_p1)^c(1) ) ^ (1/c(1)) * ( nn_z1 ^ c(2) ) + ( 1 - (nn_p1^c(1)) / ( nn_p1^c(1) + (1 - nn_p1)^c(1) ) ^ (1/c(1)) ) * ( nn_z2 ^ c(2)) = tempGroup(!j)^c(2) next
Error I am getting is Log of non positive in analytic derivatives....any ideas?

EViews Glenn
EViews Developer
Posts: 2682
Joined: Wed Oct 15, 2008 9:17 am

Re: Basic NLS Help Needed

Postby EViews Glenn » Wed Jul 06, 2011 12:25 pm

It's a tricky model to estimate since you've got exponents of exponents which can blow up or cause range errors. After playing around with it, I don't think it's an EViews problem, I think it's a model problem (incidentally, using numeric derivatives gets you farther, but you still end up with out-of-range errors).

jennie
Posts: 11
Joined: Tue Jul 05, 2011 2:31 pm

Re: Basic NLS Help Needed

Postby jennie » Wed Jul 06, 2011 12:44 pm

Thanks for checking....I will keep playing with it and see if I can get something out...

Jen


Return to “Estimation”

Who is online

Users browsing this forum: No registered users and 2 guests