Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: RE: How to solve a system of nonlinear inequalities in Stata


From   "Quang Nguyen" <[email protected]>
To   [email protected]
Subject   Re: st: RE: How to solve a system of nonlinear inequalities in Stata
Date   Wed, 7 Feb 2007 13:02:21 -1000

Dear all,

Thanks to Rodrigo I found a very nice discussion on how Stata can be
used to solve a nonlinear equation system, I replicated the example
using Stata version 8. Howver, there was a nerror message when I run
the following command:

nl faq @ y, parameters(A B C) initial(A 1 B 1 C 1)

I look at help for nl in stata, and change the command to:

nl faq  y, parameters(A B C) initial(A 1 B 1 C 1)

There is a message: "option at() required, nlfaq refused query, rc=198"

Can anyone hhelp me solving this issue.

Thanks so much and Have A Great Day!
Sincerely yours,

Quang



Suppose that I want to solve the following system for A, B, and C:

 exp(A) + B*C = 3
 A/B + C^2    = log(B)
 A/(A+B+C)    = sin(C)

Here is my nl program:
 program nlfaq

        syntax varlist(min=1 max=1) [if], at(name)

        tempname A B C
        scalar `A' = `at'[1, 1]
        scalar `B' = `at'[1, 2]
        scalar `C' = `at'[1, 3]

        tempvar yh
        gen double `yh' = exp(`A') + `B'*`C' - 2 in 1
        replace `yh' = `A'/`B' + `C'^2 - log(`B') in 2
        replace `yh' = `A'/(`A'+`B'+`C') - sin(`C') in 3

        replace `varlist' = `yh'

 end

Now I generate the dataset that nl requires:
 . clear
 . set obs 3
 obs was 0, now 3

 . generate y = 0

 . replace y = 1 in 1
 (1 real change made)

I estimate using nl:
 . nl faq @ y, parameters(A B C) initial(A 1 B 1 C 1)
 (obs = 3)



On 2/7/07, Quang Nguyen <[email protected]> wrote:
Dear Rodrigo,

Brillian! Thanks so much for you kind assistance. I will have a look at it.
Have A Great Day!
Sincerely yours,

Quang
On 2/7/07, Rodrigo A. Alfaro <[email protected]> wrote:
> Quang,
>
> Searching in Google "nonlinear stata" gives you several entries,
> I suggest you
>
> http://www.stata.com/support/faqs/lang/nl.html and
> http://www.stata.com/statalist/archive/2003-08/msg00495.html
>
> I hope this helps, Rodrigo.
>
>
> ----- Original Message -----
> From: "Quang Nguyen" <[email protected]>
> To: <[email protected]>
> Sent: Wednesday, February 07, 2007 3:37 PM
> Subject: Re: st: RE: How to solve a system of nonlinear inequalities in
> Stata
>
>
> Dear Nick,
>
> Thanks so much for always giving us your kind helps and great advices.
> I highly appreciate it.
>
> Have A Great Day!
> Sincerely yours,
>
> Quang
> On 2/7/07, Nick Cox <[email protected]> wrote:
> > Possible yes, in so far as Stata, and especially
> > Mata, is highly programmable. But that means
> > that you or someone close to you has to write
> > all the programs.
> >
> > Thus a good idea? No. There is really almost no
> > support for this kind of thing in Stata. You
> > would be better off elsewhere.
> >
> > Nick
> > [email protected]
> >
> > Quang Nguyen
> >
> > > Please accept my apology if you feel this is not a very relevant
> > > question. Is it possible to use Stata to solve a system of highly
> > > nonlinear equations (or inequalities)? If yes, can anyone suggest me
> > > the way to do it. A friend of mine uses Mathematica and receive a good
> > > result.
> >
> > *
> > *   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/
> >
> *
> *   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/
>
> *
> *   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/
>

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



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index