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...
OK, so now you have two attempted solutions, Jack Lucchetti's (via
nls) and mine (via grid-search over mu, sigma). Each has problems:
Jack's does not constrain mu and sigma in the range that you say
is acceptable, and mine has a couple of errors: missing the factor
of pi/sqrt(3) in building the "logist" series, and failing to
notice (as per the PDF you attached) that the coefficient on the
"logist" term is constrained to equal 1 (without which constraint,
I suppose, the thing is not identified).
Our candidate solutions also differ in whether they build in fixed
effects (mine does, by using the "panel" command) or not (Jack's).
I'm not sure which is appropriate.
Anyway, in case it's of interest, I'm appending below a re-write
of the grid-search variant that fixes the mistakes noted above. If
you want to remove the fixed effects, just put "ols" instead of
"panel" for the estimation commands.
In this version I've also rescaled the data to make the results
comparable with Jack's NLS variant. And I've added a check: I
noticed that when I ran the script the "optimal" mu and sig were
at the lower limits of their ranges. But, given the way the script
is written, this doesn't necessarily mean these values are
"superior" -- all it means is that were not improved upon by any
other values. So I also try running the panel model with mu and
sig at the upper limits of their ranges -- and I find this makes
no difference to the fit.
That is, it appears that variation in mu and sig, within the
limits you specified, is completely irrelevant to the fit of the
equation.
<script>
open gretl_plant.gdt
scalar R2max = 0
scalar optmu
scalar optsig
scalar nvals = 0
# apply Jack's scaling
Price /=100
HHI *= 100
Domestic_Sales /= 10000
Export_Sales /= 10000
Total_import /= 10000
loop for (mu=0.28; mu<0.501; mu+=.01) --quiet
loop for (sig=0.01; sig<0.201; sig+=.01) --quiet
series logist = 1/(1+exp(1.8138*(mu-HHI)/sig))
series y = Price - logist
panel y const Cost Domestic_Sales Export_Sales \
Soda PCFT Total_import --quiet
r2 = $rsq
if r2 > R2max
optmu = mu
optsig = sig
R2max = r2
endif
nvals++
endloop
endloop
printf "Number of points checked = %d\n", nvals
printf "R^2 is maximized at %.4f for mu = %g, sig = %g\n",
R2max, optmu, optsig
series logist = 1/(1+exp(1.8138*(optmu-HHI)/optsig))
series y = Price - logist
panel y const Cost Domestic_Sales Export_Sales \
Soda PCFT Total_import
# but also try setting (mu, sig) to max acceptable values
optmu = 0.5
optsig = 0.2
series logist = 1/(1+exp(1.8138*(optmu-HHI)/optsig))
series y = Price - logist
panel y const Cost Domestic_Sales Export_Sales \
Soda PCFT Total_import
</script>
Allin Cottrell