# [Gretl-users] Nonlinear switching regression vs Loop constructs

GREg Ory termess at gmail.com
Fri Jan 28 13:11:01 EST 2011

```Dear Gretl community,

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

My problem is twofold: 1st loop worls perfectly but 2nd loop doesn’t
work. R2 is not saved to a coeffs.gdt file. Any help to estimate the
model using those or other methods is appreciated.

Best Regards,
Gregory
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gretl plant.gdt
Type: application/octet-stream
Size: 9503 bytes
Desc: not available
Url : http://lists.wfu.edu/pipermail/gretl-users/attachments/20110128/37708e2c/attachment-0001.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: !more that one critical concentration ratio. US.pdf
Type: application/pdf
Size: 141903 bytes
Desc: not available
Url : http://lists.wfu.edu/pipermail/gretl-users/attachments/20110128/37708e2c/attachment-0001.pdf
```