Statalist The Stata Listserver


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

Re: st: A question on programming


From   "Quang Nguyen" <[email protected]>
To   [email protected]
Subject   Re: st: A question on programming
Date   Wed, 21 Feb 2007 22:18:53 -1000

Dear all,

There are some typos in the last email. I would like to repost it here:

Thanks to suggestions by members of Statalist, I developed the
following program:

program define sol
 if "`1'" == "?" { /* if query call ... */
 global S_1 "A B" /* identify parameters */
 global X = 0.5 /* and initialize */
                      /* them */
      exit
 }
 /* otherwise, calculate function */

 replace `1' = a * exp($X) - b * ($X)^2
set obs 1
gen y=1
nl sol y

end

This program aims at solving the equation: a*exp(X)=b*(X^2). Where a,
and b come from the following data set:

id        a          b
1         3          5
2         7          9
3         4          7

and so on.

My question is how I can integrate these values of a, and b into the
above program so that the value of X for each individual (ID=1, 2, 3
etc.,) can be solved automatically.

Thanks so much for your help!
Have A Wonderful Day!


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

Thanks to suggestions by members of Statalist, I developed th
efollowing program:

program define sol
  if "`1'" == "?" { /* if query call ... */
  global S_1 "A B" /* identify parameters */
  global A = 0.5 /* and initialize */
  global B = 0.5 /* them */
       exit
  }
  /* otherwise, calculate function */

  replace `1' = a * exp($X) - b * ($X)^2
set obs 1
gen y=1
nl sol y

end

This program aims at solving the equation: a*exp(X)=b*(X^2). Where a,
and b comes from the following data set:

id        a          b
1         3          5
2         7          9
3         4          7

and so on.

My question is how I can integrate these values of a, and b into the
above program so that the value of X for each individual (ID=1, 2, 3
etc.,) can be solved automatically.

Thanks so much for your help!
Have A Wonderful Day!
*
*   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