# st: nl using estimated coefficients

 From Kumiko Imai To statalist@hsphsun2.harvard.edu Subject st: nl using estimated coefficients Date Thu, 19 Sep 2002 00:58:46 -0400

Hello,

Does anyone have any ideas how to fix the following problem? After estimating a logit I use the estimated coefficients in an nl routine but I get the "type mismatch" error. I suspected the problem lies in the use of scalars, so I first svmat the coefficients and then use those instead of the scalars, but then I get the "RHS variables missing" error.

Thanks very much,

Kumiko

------------------------------------
. logit anycost age

Iteration 0: log likelihood = -2843.9766
Iteration 1: log likelihood = -2843.968
Iteration 2: log likelihood = -2843.968

Logit estimates Number of obs = 5055
LR chi2(1) = 0.02
Prob > chi2 = 0.8954
Log likelihood = -2843.968 Pseudo R2 = 0.0000

anycost Coef. Std. Err. z P>z [95% Conf. Interval]

age -.0004165 .0031672 -0.13 0.895 -.0066242 .0057911
_cons 1.112459 .119838 9.28 0.000 .877581 1.347337

. scalar b10=_b[_cons]

. scalar b11=_b[age]

. di b10 b11
1.1124592-.00041651

.
. program define nlfcn
1. if "`1'"="?"{
2. global S_1 "b20 b21"
3. global b20=.1
4. global b21=.1
5. exit
6. }
7. replace `1'=exp((b10+\$b20)+(b11+\$b21)*age)/(1+exp(b10+b11*age))
8. end

.
. nl fcn cost
type mismatch
nlfcn refused query, rc=109
r(109);

end of do-file
r(109);

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