Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]



--- On Mon, 4/10/10, Benhoen2 <benhoen2@earthlink.net> wrote:
> I want to save regress results to a new stata dataset that
> I can use in later calculations.  The reg command contained
> i.var#i.var in the independent variable list and produced a 
> 1x4314 e(b) matrix of coefficients.
> 
> Specifically, I need to save the results from the
> interaction (though the other results can come with it too)
> into a new matrix and NEED to include the variable names as
> shown in the output.  I will be using these names to create
> new variables in the new dataset. 

The easiest way to do things like that is to use -est save-
to store the entire model. That way you can use postestimation
commands like -predict- and -predictnl- to create your new
variables. 

*---------- begin example ---------------
sysuse auto, clear
// estimate the model
reg price c.mpg##i.foreign

est save "c:/temp/foo"

// create the other dataset
drop _all
set obs 100
gen mpg = rnormal(21,6)
gen foreign = runiform() < .3

// load the saved estimation results
est use "c:/temp/foo"

// create my variable using -predict-
// alternatively look at -predictnl- 
predict mpghat
*----------------- end example ------------------
(For more on examples I sent to the Statalist see: 
http://www.maartenbuis.nl/example_faq )

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://www.maartenbuis.nl

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index