Bookmark and Share

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: Mata calls on Stata variables and macros


From   Brad Jeffrey Hershbein <[email protected]>
To   [email protected]
Subject   st: Mata calls on Stata variables and macros
Date   Sat, 17 Apr 2010 19:00:30 -0400

Dear Statalisters,

I would like to solve a (cubic) polynomial equation where one of the coefficients of the polynomial is a variable in my dataset and the other coefficients are stored as scalars. That is, I want to solve for the roots of Ax^3 + Bx^2 + Cx + D = 0, where D is the variable Z in my dataset, and A, B, and C are stored in the scalars a1, b1, and c1, respectively. The values of A, B, C, and D are such that there is only one positive, real root in all cases, and I would like that root to be a new variable in the dataset.

I know the Mata routine polyroots can find the roots of a polynomial, but I cannot figure out how to simultaneously pass the scalars and Z for polyroots to take as arguments, and how to return the positive real root as a new variable to Stata.

Thank you for your consideration.

Brad Hershbein
University of Michigan
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index