Statalist The Stata Listserver


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

st: A question on programming


From   "Quang Nguyen" <[email protected]>
To   [email protected]
Subject   st: A question on programming
Date   Wed, 21 Feb 2007 19:23:57 -1000

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/



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