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]
Re: st: How to save results as .dat file
From
"Cai,Zhuangyu" <[email protected]>
To
<[email protected]>
Subject
Re: st: How to save results as .dat file
Date
Thu, 24 Jan 2013 14:46:09 -0500
On Thu, 24 Jan 2013 00:02:51 -0500, Joerg Luedicke wrote:
As all -ereturn- programs, GLLAMM stores a number of estimation
results in e(). Type -ereturn list- after running GLLAMM to see
what's
there. For example, coefficients are stored in e(b), variances and
covariances can be obtained from e(V). What you then could do is to
store the desired results in a matrix from which you can create a
Stata dataset which then can be saved in the desired format. Consider
the following example where we create an empty matrix first, with 10
rows and 3 columns (and label the columns). We then run GLLAMM 10
times and each time around we put the results into one row of the
matrix:
*--------------------------------------
clear
use http://www.stata-press.com/data/r11/childweight.dta
mat myest = J(10,3,.)
mat colnames myest = model b_age se_age
forval i = 1/10 {
qui gllamm weight age girl, i(id)
mat b = e(b)
mat v = e(V)
mat myest[`i',1] = `i'
mat myest[`i',2] = b[1,1]
mat myest[`i',3] = sqrt(v[1,1])
qui replace age = age / `i'
}
*--------------------------------------
You can look at the matrix by typing (see -help matrix-):
mat list myest
Finally, you can create a dataset with
svmat myest, names(col)
using the column names from the matrix as variable names (see -help
svmat-), after which you can save the dataset.
Joerg
On Wed, Jan 23, 2013 at 11:04 PM, Cai,Zhuangyu <[email protected]> wrote:
Dear Stata users,
I have to run GLLAMM 100 times in my code. How do I save the
coefficient,
standard errors, vanriance and covariance of random effect generated
by
GLLAMM everytime into a data set? Thanks for help.
Zhuangyu
*
* 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/
*
* 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/
Hi Joerg,
Thank you very much for your response. It works very well. Have a nice
day.
Zhuangyu
*
* 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/