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 at the end of May, and its replacement, is already up and running.

[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   Roger Newson <>
To   "" <>
Subject   Re: st: saving regress results and variable names i.var#i.var
Date   Mon, 4 Oct 2010 17:39:42 +0100

I think what Benhoen2 really needs is the -parmest- and -descsave-packages, together with the -fvregen- package (if Benhoen2 is using Stata Version 11, or the -factext- package if Benhoen2 is using an earlier version. All of these packages can be downloaded from SSC, but if Benhoen2 is using an earlier version of Stata than Stata 11, then Benhoen2 should download -parmest- from my website by typing

net from

and selecting the Stata version required.

The -parmest- package creates datasets with 1 observation per estimated parameter and data on parameter names, estimates, confidence limits, P-values and other parameter attributes. The -fvregen- package reconstructs the factors in this output dataset. An example of the use of -fvregen- with -parmest- and -descsave- is given in Newson (2010). Other examples of the use of -parmest- are listed in the References in the on-line help for -parmest-.

I hope this helps.

Best wishes



Newson RB. Post-parmest peripherals: -fvregen-, -invcise-, and -qqvalue-. Presented at the 16th UK Stata User Meeting, 9-10 September, 2010. Download from

Roger B Newson BSc MSc DPhil
Lecturer in Medical Statistics
Respiratory Epidemiology and Public Health Group
National Heart and Lung Institute
Imperial College London
Royal Brompton Campus
Room 33, Emmanuel Kaye Building
1B Manresa Road
London SW3 6LR
Tel: +44 (0)20 7352 8121 ext 3381
Fax: +44 (0)20 7351 8322
Web page:
Departmental Web page:

Opinions expressed are those of the author, not of the institution.

On 04/10/2010 15:12, Benhoen2 wrote:
Thanks Maarten.  I saved them off and can sleep knowing they are safe.

The more frustrating problem though is how to have the factors in the
interaction variables identified.  The results seem to discard to factor
names. The variable blkgrp (FYI "census blockgroup") has ~1,200 unique
values in the sample (e.g., 89556, 42663, 48335), and the variable pv
("photo voltaic") has two values (e.g., 1=yes, 0=no) and to be useful the
results need to be matched with their identifiers.  The output seems to
discard these names and instead uses a simple integer series (blkgrp pv:
e.g., 1 1, 1 0, 2 1, 2 0,...1199 1, 1199 0, 1200 1, 1200 0).

Is there any way to match the coefficients with their respective blkgrp
factor (obviously I can figure out the pv factor),  i.e., have the results
saved with the underlying variable names?

 From 	  Maarten buis<>
Subject 	  Re: st: saving regress results and variable names
Date 	  Mon, 4 Oct 2010 07:31:36 +0100 (BST)

--- On Mon, 4/10/10, Benhoen2<>  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:
*   For searches and help try:

© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index