# Re: st: nl command with restriction

 From "E. Paul Wileyto" To rcprates@esalq.usp.br, statalist@hsphsun2.harvard.edu Subject Re: st: nl command with restriction Date Tue, 12 Feb 2008 08:39:56 -0500

Use this and only expect to estimate a and b:

program define nlces12
version 8.0
if "`1'" == "?" {
global S_1 "a b"
global a=.15
global b=.4
global S_2 "Cobb-Douglas with additive error"
exit
}
local A=exp(\$a)/(1+exp(\$a) +exp(\$b))

local B=exp(\$b)/(1+exp(\$a) +exp(\$b))

local C=1/(1+exp(\$a) +exp(\$b))

replace `1' = `A'*((k^`B')*(l^`C')*(n^(1-`B'-`C')))

end

a and b are logits and will range from - to + infinity.

Then use nlcom to get back the estimates of A, B, C:

nlcom (A: exp(_b[a])/(1+exp(_b[a]) +exp(_b[b]))) (B: exp(_b[b])/(1+exp(_b[a]) +exp(_b[b]))) (C: 1/(1+exp(_b[a]) +exp(_b[b])))

Paul

Rodolfo Coelho Prates wrote:

Thanks Paul and Nick!

I tried implement yours sugestions, but I think my comprehention is not
correct.

I estimeted the Cobb-Doulas with three variables, like this:

program define nlces12
version 8.0
if "`1'" == "?" {
global S_1 "a b c"
global a=.15
global b=.4
global c=.3
global S_2 "Cobb-Douglas with additive error"
exit
}

replace `1' = \$a*((k^\$b)*(l^\$c)*(n^(1-\$b-\$c)))

end

This routine works well, but has that problem.

If I understood, the suggestion is:

replace `1' =
\$a*((k^(exp(\$b)/(1+exp(\$b)+exp(\$c))))*(l^(exp(\$c)/(1+exp(\$b)+exp(\$c))))*(n^(1/(1+exp(\$b)+exp(\$c)))))

Thise are the estimations with brute force:

Source | SS df MS Number of obs = 123
-------------+------------------------------ F( 2, 121) = 102.83
Model | 8.2419e+09 2 4.1209e+09 Prob > F = 0.0000
Residual | 4.8489e+09 121 40073949.1 R-squared = 0.6296
Total | 1.3091e+10 123 106429266 Root MSE = 6330.399
Res. dev. = 2500.31
---------------------------------------------------------------------------
y | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+-------------------------------------------------------------
a | 2.594492 .3699407 7.01 0.000 1.862096 3.326887
b | 17.12698 .3519304 48.67 0.000 16.43025 17.82372
c | 16.97066 . . . . .
------------------------------------------------------------------------------

Works well, but the sum of coeficients are larger than one, but not
negatives. Do I need realize a transformation? Or did I made something
wrong?

Best Regards,

Rodolfo

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

--
E. Paul Wileyto, Ph.D.
Assistant Professor of Biostatistics
Tobacco Use Research Center
School of Medicine, U. of Pennsylvania
3535 Market Street, Suite 4100

215-746-7147
Fax: 215-746-7140
epw@mail.med.upenn.edu
http://mail.med.upenn.edu/~epw/
*
* 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/