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]
--- On Mon, 4/10/10, Benhoen2 <firstname.lastname@example.org> 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
*---------- begin example ---------------
sysuse auto, clear
// estimate the model
reg price c.mpg##i.foreign
est save "c:/temp/foo"
// create the other dataset
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-
*----------------- end example ------------------
(For more on examples I sent to the Statalist see:
Hope this helps,
Maarten L. Buis
Institut fuer Soziologie
* For searches and help try: