[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
"Paola De Agostini" <[email protected]> |

To |
<[email protected]> |

Subject |
st: Problems programming nl least squares |

Date |
Mon, 17 Nov 2003 15:41:45 -0000 |

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/

**Follow-Ups**:**st: Re: Problems programming nl least squares***From:*"Steichen" <[email protected]>

**st: Re: Problems programming nl least squares***From:*"Thomas Cornelissen" <[email protected]>

- Prev by Date:
**st: RE: findvar command?** - Next by Date:
**st: Re: Problems programming nl least squares** - Previous by thread:
**st: negative binomial marginal effects** - Next by thread:
**st: Re: Problems programming nl least squares** - Index(es):

© Copyright 1996–2024 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |