Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Estout and predicted signs

From   "Jann, Ben" <>
To   <>
Subject   st: RE: Estout and predicted signs
Date   Sat, 12 Feb 2005 21:17:02 +0100

Hervé wrote:
>In a regression table, I would like to insert a column with predicted
>signs after the var names. I know that I can do it manually in my excel
>sheet after -estout- but I would like to know if it is possible to do it
>with -estout-.

There is no simple solution to the problem. You can, for example, 
add a matrix indicating the predicted signs to the estimates and then 
use -estout- to table both the estimates and the predicted signs. 
The problem is of course that you cannot have strings in a matrix.
Thus, use, say, "999" for "positive sign" and "-999" for "negative
sign" and then apply -estout-'s -substitute()- option. An example:

  sysuse auto
  regress price mpg weight foreign
  tempname b
  matrix `b' = e(b)
  matrix `b' = `b'[1,1..3] //get rid of constant
  matrix `b'[1,1] = -999   //neg. sign for mpg
  matrix `b'[1,2] = +999   //pos. sign for weight
  matrix `b'[1,3] = +999   //pos. sign for foreign
  eret2 matrix signs = `b'
  estimates store model1
  estout model1, cells("signs b") substitute(-999 - 999 +)

Alternatively, store the predictes signs as an own set of
"fake" estimates: 

  capture program drop prsign
  program define prsign, eclass
    tempname b V
    matrix `b' = e(b)
    matrix `V' = e(V)
    local i = 0
    foreach sign of local 0 {
      matrix `b'[1,`++i'] = `sign'999
    ereturn post `b' `V'
    ereturn local cmd sham

  sysuse auto
  regress price mpg weight foreign
  estimates store model1
  regress price mpg weight foreign, noconstant
  prsign - + +
  estimates store signs
  estout signs model1, substitute(-999 - 999 +)


*   For searches and help try:

© Copyright 1996–2021 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index