Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Bracket [ ] notation


From   "Terra Curtis" <[email protected]>
To   <[email protected]>
Subject   st: Bracket [ ] notation
Date   Tue, 9 Aug 2005 16:51:15 -0400

Dear Statalist,

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.  

Any insights?
Thanks,
Terra   

*
*   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/



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