Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

Re: st: saving regress results and variable names i.var#i.var

From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: saving regress results and variable names i.var#i.var
Date   Mon, 4 Oct 2010 07:31:36 +0100 (BST)

--- On Mon, 4/10/10, Benhoen2 <[email protected]> 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
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: )

Hope this helps,

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


*   For searches and help try:

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