Hi,
I am trying to estimate a nonlinear equation using -nl-, thus I have to first define the equation to be estimated using -nlfcns-.(see the e-mail chain below for my original question to the Stata list about fixed effects and nonlinear estimation). My problem is that I get the following error message when attempting to run the program:
expression too long
error #130 occurred in program nldeltatr
r(130);
The source of this error is the following very long equation that has about 150 variables:
replace `1'=$T*top3 + $T*$D*top3L1 + $T*($D^2)*top3L2 + $C2*k2 + $C3*k3 + $C4*k4 + $C5*k5 + $C6*k6 + $C7*k7 + $C8*k8 + $C9*k9 + $C10*k10 + $C11*k11 + $C12*k12 + $C13*k13 + $C14*k14 + $C15*k15 + $C16*k16 + $C17*k17 + $C18*k18 + $C19*k19 + $C20*k20 + $C21*k21 + $C22*k22 + $C23*k23 + $C24*k24 + $C25*k25 + $C26*k26 + $C27*k27 + $C28*k28 + $C29*k29 + $C30*k30 + $C31*k31 + $C32*k32 + $C33*k33 + $C34*k34 + $C35*k35 + $C36*k36 + $C37*k37 + $C38*k38 + $C39*k39 + $C40*k40 + $C41*k41 + $C42*k42 + $C43*k43 + $W2*t2 + $W3*t3 + $W4*t4 + $W5*t5 + $W6*t6 + $W7*t7 + $W8*t8 + $W9*t9 + $W10*t10 + $W11*t11 + $W12*t12 + $W13*t13 + $W14*t14 + $W15*t15 + $W16*t16 + $W17*t17 + $W18*t18 + $W19*t19 + $W20*t20 + $W21*t21 + $W22*t22 + $W23*t23 + $W24*t24 + $W25*t25 + $W26*t26 + $W27*t27 + $W28*t28 + $W29*t29 + $W30*t30 + $W31*t31 + $W32*t32 + $W33*t33 + $W34*t34 + $W35*t35 + $W36*t36 + $W37*t37 + $W38*t38 + $W39*t39 + $W40*t40 + $W41*t41 + $W42*t42 + $W43*t43 + $W44*t44 + $W45*t45 + $W46*t46 + $W!
47*t47 + $W48*t48 + $W49*t49 + $W50*t50+ $W51*t51 + $W52*t52 + $W53*t53 + $W54*t54 + $W55*t55 + $W56*t56 + $W57*t57 + $W58*t58 + $W59*t59 + $W60*t60+ $W61*t61 + $W62*t62 + $W63*t63 + $W64*t64 + $W65*t65 + $W66*t66 + $W67*t67 + $W68*t68 + $W69*t69 + $W70*t70+ $W71*t71 + $W72*t72 + $W73*t73 + $W74*t74 + $W75*t75 + $W76*t76 + $W77*t77 + $W78*t78 + $W79*t79 + $W80*t80+ $W81*t81 + $W82*t82 + $W83*t83 + $W84*t84 + $W85*t85 + $W86*t86 + $W87*t87 + $W88*t88 + $W89*t89 + $W90*t90+ $W91*t91 + $W92*t92 + $W93*t93 + $W94*t94 + $W95*t95 + $W96*t96 + $W97*t97 + $W98*t98 + $W99*t99 + $W100*t100+ $W101*t101 + $W102*t102 + $W103*t103 + $W104*t104
c2-c43 and t2-t104 are sets of dummy variables. I could demean the data and get rid of c2-c43, but even without c2-c43 the expression is still too long.
The manual suggests breaking up the expression into smaller parts. Does anyone know how such an expression could be broken up or is estimating this equation in this form too much too ask?
Thanks,
Larry Chavis
Ph.D. Student
Stanford Graduate School of Business
[email protected]
(650)724-4909
-----Original Message-----
From: [email protected]
[mailto:[email protected]]On Behalf Of Chavis, Larry
Wilson
Sent: Tuesday, April 20, 2004 10:37 AM
To: [email protected]
Subject: st: Nonlinear Least Squares and Fixed Effects
Mark,
Thanks for your input. Greene's series of papers on nonlinear models and fixed effects is certainly helpful. I'll have to go over the paper more carefully, but initially it seems I may be OK in terms of consistency since the data covers a larger number of time periods. It seems that these models generally get better as T increases (but that is just a first guess). Greene certainly seems to be optimistic that panel data and nonlinear models can coexist.
As far as the other issues goes, de-meaning would seem to give me more flexibility. Maybe I could wipe out the fixed effects and then use the -nlfcns- to estimate the nonlinear model. -cnsreg- is close to what I need but it only accepts linear constraints and I would like to add a nonlinear one.
Thanks again,
Larry Chavis
Ph.D. Student
Stanford Graduate School of Business
[email protected]
(650)724-4909
-----Original Message-----
From: [email protected]
[mailto:[email protected]]On Behalf Of Mark Schaffer
Sent: Tuesday, April 20, 2004 8:10 AM
To: [email protected]
Subject: Re: Nonlinear Least Squares and Fixed Effects
Larry,
Is your estimation going to be consistent? Sometimes, with fixed
effects models, the incidental parameters problem makes the estimator
inconsistent.
Bill Greene has a short paper about this on his website that also has
some useful reading:
http://www.stern.nyu.edu/~wgreene/fixedeffects.doc
In your first example, it looks like you might be able to de-mean the
data by hand to wipe out the fixed effects and then do a constrained
linear estimation with -cnsreg-.
Hope this helps.
--Mark
Subject: st: Nonlinear Least Squares and Fixed Effects
Date sent: Mon, 19 Apr 2004 13:28:34 -0700
From: "Chavis, Larry Wilson" <[email protected]>
To: <[email protected]>
Send reply to: [email protected]
>
>
> Hi,
>
> I am working with panel data and I am trying to impose some nonlinear constraints on an equation with a large number of fixed effects. So far I have been unsuccessful and I have a couple of questions in this regard. Any advice you could provide would be greatly appreciated.
>
>
> 1) For one specification I have run the following linear regression -xtreg lnunit dummy1 dummy2 dummy3 week2-week104, fe i(id)-. Basically I have about 8,000 products (id's) that I have data on for 104 weeks. I would also like to estimate this while constraining the coefficients on dummy1
dummy2 and dummy3 in a nonlinear fashion (i.e. _b[dummy1] = (_b[dummy2]^2) / _b[dummy3]. I am able to test the restriction post-estimation using -testnl-, but I would like to incorporate the restrictions into the regression. Any ideas?
>
>
> 2) Similarly I could aggregate the data by country so that the panel data now represents 43 countries over 104 weeks. Now the data is a manageable size to use the -nl- command and set up the regression using -nlfcns-. The only problem is that I am not sure how to set up the fixed effects
dummies in the equation. The only thing I can think of is to us the brute force method and just type in something like - '1' = $B1 * week1 + $B2 * week2 + $B3 week3 + ......-. This seems a little cumbersome since I have over 140 fixed effect dummies. I would also have to type a similarly long
list to declare and initialize the parameters. I thought of using -for num- to declare and initialize the sequence of variables, but I am still stuck when it comes to the actual equation. Is there something akin to a summation sign that I could use in this situation?
>
>
> Thanks,
> Larry Chavis
>
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/