Paola --
This is usually an indication that the initial values for the parameters are
poor, leading to a solution where the prediction is flat for some parameters
(i.e., no variation). Try different starting values.
Tom
----- Original Message -----
From: "Paola De Agostini" <[email protected]>
To: <[email protected]>
Sent: Monday, November 17, 2003 10:41 AM
Subject: st: Problems programming nl least squares
> Dear statalisters,
>
> I am having some trouble programming an nl-command. I would like to
> program the following function:
>
> replace `1'= ($B0 + $B1*x1 + $B2*x2 + $B3*x3)*exp( $GF*Z)
>
> Where X are individual characteristics, Z is ln of hhld income and $Bi
> and $GF are parameters to be estimated.
>
> My problems arise when I increase the number of explanatory vars X. In
> this case my command line becomes too long (more than 255 characters).
> Therefore I defined the sum of beta times X over `i' using a loop as
> shown below.
>
> program define nlexercise4_1
> version 8.0
> if "`1'"=="?" {
>
> [parameters definition]
> [parameters initialization]
>
> exit
> }
>
> local sum = 0
> forvalues i = 1/3 {
> local sum= `sum' + ${B`i'}* x`i'
> }
>
> replace `1'= ($B0 + `sum')*exp( $GF*Z)
> End
>
> Results:
>
> (stata4_1)
> ------------------------------------------------------------------------
> ------
> milkcq | Coef. Std. Err. t P>|t| [95% Conf.
> Interval]
> -------------+----------------------------------------------------------
> ------
> B0 | 178.1014 8.751873 20.35 0.000 160.9446
> 195.2581
> B1 | 116.3971 . . . .
> .
> B2 | 142.4194 . . . .
> .
> B3 | 114.4872 . . . .
> .
> GF | .0219544 .0100062 2.19 0.028 .0023387
> .0415701
> ------------------------------------------------------------------------
> ------
> * Parameter B3 taken as constant term in model & ANOVA table
> (SEs, P values, CIs, and correlations are asymptotic approximations)
>
>
> So, it looks like Stata does not recognize B1, B2 and B3 as parameters
> and does not estimate them.
>
> Has anybody encountered a similar problem before? Any hints,
> suggestions, references would be very much appreciated :-))
>
> Thank you,
>
> Paola De Agostini
>
> *
> * 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/
>
*
* 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/