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

Re: st: change values of e(b)


From   Joseph Coveney <jcoveney@bigplanet.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: change values of e(b)
Date   Wed, 04 Dec 2002 20:54:01 +0900

Hung-Jen Wang asked, "Is there any way to change elements of the coefficient vector 
e(b) obtained after an estimation?  . . . I want to work with e(b) since I'll later use -
predict- to do some experiments, and I assume that -predict- recognizes e(b) only."

Yes.  You can force Stata into altering system matrixes such as e(b) by writing a simple 
wrapper eclass program that alters them, as in the following illustrative do-file.  -predict- 
will then use your altered e(b) matrix.

Joseph Coveney

--------------------------------------------------------------------------------

drawnorm y x, n(20) mean(0 0) sd(1 1) /*
  */ corr(1.0, 0.7 \ 0.7, 1.0) seed(20021204) clear
regress y x
matrix list e(b)
predict real_hat, xb
capture program drop alterations
program define alterations, eclass
    quietly regress y x
    matrix A = e(b)
    matrix A[1,1] = -A[1,1]
    estimates repost b = A
end
alterations
matrix list e(b)
predict phony_hat, xb
label variable phony_hat "phony"
label variable real_hat "real"
graph y real_hat phony_hat x, connect(.LL) symbol(Oii) /*
  */ xlabel ylabel
exit

--------------------------------------------------------------------------------


*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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   |   What's new   |   Site index