Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: How to solve a system of nonlinear equations with cross-equation correlations?
From
Amy Wang <[email protected]>
To
"[email protected]" <[email protected]>
Subject
st: How to solve a system of nonlinear equations with cross-equation correlations?
Date
Thu, 19 Sep 2013 19:09:14 +0000
Hi all,
I try to solve a system of nonlinear equations with STATA.
My data looks like this:
id s x e
1 .0064259 -1.008586 ?
1 .2882765 2.701381 ?
1 .1368153 2.010069 ?
where id=1,2,3,...J,
Formula: s_j=exp(x_j+e_j)/A, and A=(1+exp(x_1+e_1)+...+exp(x_j+e_j)+...+exp(x_J+e_J))
I have exactly J equations with J unknowns. I want to know e_js.
I found http://www.stata.com/support/faqs/programming/system-of-nonlinear-equations/ and http://www.stata.com/statalist/archive/2011-06/msg00674.html
but I don't know how to add "A".
I also found "nlsur", which allows me to add "A". Here is what I did.
[1] I reformatted the data as the following:
id s1 x1 s2 x2 s3 x3 s11 x11 s22 x22 s33 x33
1 .0064259 -1.008586 .2882765 2.701381 .1368153 2.010069 .0064259 -1.008586
1 .0064259 -1.008586 .2882765 2.701381 .1368153 2.010069 .2882765 2.701381
1 .0064259 -1.008586 .2882765 2.701381 .1368153 2.010069 .1368153 2.010069
...
code is as the following:
nlsur (s11=exp(x11+{e1})/(1+exp(x1+{e1})+exp(x2+{e2})+...exp(xJ+{eJ}))) /*
*/ (s22=exp(x22+{e2})/(1+exp(x1+{e1})+exp(x2+{e2})+...exp(xJ+{eJ}))) /*
*/ ... (sJJ=exp(xJJ+{eJ})/(1+exp(x1+{e1})+exp(x2+{e2})+...exp(xJ+{eJ})))
STATA returns "cannot have fewer observations than parameters".
Can anyone give me some hint to proceed?
Thanks, Amy
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/