On Fri, 28 Jan 2011, GREg Ory wrote:
I need some tips on estimating panel data using nonlinear switching
regression technique. AFAIK there are two ways of solving it.
The model I estimate is the following:
panel Price const Cost logist Domestic_Sales Export_Sales Soda PCFT Total_import
Logistic function is given as logist = 1/(1+exp(1,81*(mu-HHI)/sig)).
Height of the logistic function is between 0.025 and 0.975.
Mu = mean(height)
Sig = var(height)
The datafile is attached in case anybody wants to help tackle the
model directly. The theoretic foundation for this analysis is also
attached in the PDF article. I tried to use simultaneous equations to
estimate this model properly but to no avail.
Second best option is to use loop constructs to model all possible
parameter values in the given range then to choose the model with the
highest $rsq. Mu should be in the range of 0.28 to 0.501 and sig
between 0.01 and 0.201. However I have a problem with implementing a
proper loop. Here is an example
nulldata 100
set seed 2478
HHI =randgen(u,0.21,0.27)
P = randgen(u,100,300)
# open two loops for estimated params
loop for (mu=0.28; mu<0.501; mu+=.01)
loop for (sig=0.01; sig<0.201; sig+=.01)
# construct the dependent variables
genr height = randgen(u,0.025,0.975)
genr mu = mean(height)
genr sig = var(height)
genr logist = 1/(1+exp((mu-HHI)/sig))
# run OLS regression as an example
ols P const logist
# grab the coefficient estimates and R-squared
genr b1 = $coeff(const)
genr b2 = $coeff(logist)
genr r2 = $rsq
print a b r2
store coeffs.gdt a b r2
endloop
endloop
Comments:
* In the inner loop you define b1 and b2, but you attempt to print
and save a and b (both undefined). Easily fixed, of course.
* The saving of scalar values to file via "store" is supported
only for "progressive" loops, so you'd have to append the
--progressive flag to the inner loop command to get this
effect.
* However, that would not do what you want: since the "store"
occurs in the inner loop, coeffs.gdt would be over-written on
each iteration of the outer loop and at the end would contain
only the values for mu = 0.5.
* Your loops may well be infinite (and in case are not doing what
you want) because of the way you use mu and sig as loop control
variables but also reset their values within the inner loop:
genr mu = mean(height)
genr sig = var(height)
You need to use different names for these inner variables.
* You don't actually _read_ mu or sig, as set by the loop control
"for" expressions, anywhere inside the loop, so I'm left without
much idea of what the loop is actually trying to do.
Allin Cottrell