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

From |
"Terra Curtis" <terra.curtis@cambridgefinance.com> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
RE: st: RE: RE: Bracket [ ] notation |

Date |
Wed, 10 Aug 2005 16:18:36 -0400 |

-capture- didn't seem to help. I think what's happening is, since I have unbalanced panel data, the nonlinear equation I have specified is trying to include observations for a company that doesn't have an observation in that year, even though some of the companies will have an observation in that (or any given) year. I've tried putting an if statement at the end of the -by coname: replace- line saying if *none of the variables in the specified equation are blank.* But this doesn't seem to make a difference. Is the problem more clear now? And if so, do you know how I could deal with it? Thanks. -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of n j cox Sent: Wednesday, August 10, 2005 12:15 PM To: statalist@hsphsun2.harvard.edu Subject: Re: st: RE: RE: Bracket [ ] notation -capture- gives you a way to ignore a command if it produces an error and would otherwise stop your program. I have to guess that is not what you need here, but I'm less clear about what you do need. >>> Terra Curtis Is there any way to tell Stata to ignore the command when at least one of the referenced entries does not exist? Nick Cox If the subscript on the RHS is missing (meaning not present in the dataset), the result on the LHS will be missing too (meaning "missing"). Here the use of -by:- is just a detail and does not affect the principle. The principle can be seen by sysuse auto di mpg[0] di mpg[75] As advised in another thread, you would surely be better off re-casting this using time-series operators. Nick n.j.cox@durham.ac.uk Terra Curtis > I am running into some problems trying to run a nonlinear regression. > I continue to get error 480 "starting values invalid or some RHS > variables have missing values." I think I see where my error is but > I'm not sure how STATA deals with a reference, say 'by varname: > data[x]' if x is out of the range of data for that varname. Here is > my code: I have written a program to specify the nonlinear equation, > and that is where the error is: > > program nlstk2_depreciation > version 8.1 > if "`1'" == "?" { > global S_1 "B3 B4 B5 drd2 dmktg2" > global B3=1 > global B4=1 > global B5=1 > global drd2=0.15 > global dmktg2=0.15 > exit > } > forvalues x=10/53 { > by coname: replace `1'=$B3+$B4*(ireal46[`x'] + > (1-$drd2)*ireal46[`x'-1] + (1-$drd2)^2*ireal46[`x'-2] + > (1-$drd2)^3*ireal46[`x'-3] + (1-$drd2)^4*ireal46[`x'-4] + > (1-$drd2)^5*ireal46[`x'-5] + (1-$drd2)^6*ireal46[`x'-6] + > (1-$drd2)^7*ireal46[`x'-7]+ (1-$drd2)^8*ireal46[`x'-8] + > (1-$drd2)^9*ireal46[`x'-9]/$drd2) + $B5*(imktg[`x'] + > (1-$dmktg2)*imktg[`x'-1] + (1-$dmktg2)^2*imktg[`x'-2] + > (1-$dmktg2)^3*imktg[`x'-3] + (1-$dmktg2)^4*imktg[`x'-4] + > (1-$dmktg2)^5*imktg[`x'-5] + (1-$dmktg2)^6*imktg[`x'-6] + > (1-$dmktg2)^7*imktg[`x'-7] + (1-$dmktg2)^8*imktg[`x'-8] + > (1-$dmktg2)^9*imktg[`x'-9]/$dmktg2) if `x'==year > } > end > > I have panel data for companies over a period of years, although each > company has a different amount of years of data (no company has more > than 53 years of data). If a company has 10 years of data, I want the > regression to use all 10 years of data. If it has more than 10 years > of data, I want it to use the most recent 10 (say, years 1990-1999), > then use the next 10 (years 1989-1998), and so on until it gets to the > last set of 10 years for that company. I think the logic of the > equation I have written works out, so I'm guessing the error is coming > from some referencing problem in the brackets...I don't quite > understand how STATA would deal with ireal46[49] if some company > didn't have a 49th ireal46 entry. * * 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/

**References**:**Re: st: RE: RE: Bracket [ ] notation***From:*n j cox <n.j.cox@durham.ac.uk>

- Prev by Date:
**RE: st: odds ratio vs. RRR in multinomial logistic regression** - Next by Date:
**RE: st: RE: RE: Bracket [ ] notation** - Previous by thread:
**Re: st: RE: RE: Bracket [ ] notation** - Next by thread:
**RE: st: RE: RE: Bracket [ ] notation** - Index(es):

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