> -----Original Message-----
> From: [email protected] [mailto:owner-
> [email protected]] On Behalf Of Richard Williams
> Sent: Thursday, July 21, 2005 7:19 PM
> To: [email protected]
> Subject: Re: st: RE: Changing beta coefficients - w/ logistic regression
>
> At 05:33 PM 7/21/2005 -0500, Scott Merryman wrote:
> >Change the program to:
> >
> >program foo2, eclass
> > tempname bmat
> > matrix `bmat' = e(b)
> > matrix b = e(b)
> > ereturn post b
> > matrix `bmat'[1,1] = 122
> > ereturn repost b = `bmat'
> >end
> >
> >This seems to work for both -regress- and -logit-
> >
> >Scott
>
> I'm surprised the original program doesn't work. Something to be aware of
> with Scott's solution: most of the ereturned stuff gets zapped once you
> run foo2. In particular, since e(predict) gets zapped, the p option on
> predict doesn't work. You can probably add lines to Scott's program to
> revive the ereturned stuff that gets lost but maybe there is a better
> way.
Richard,
Thanks. Nice catch. I too hope there is a better way.
It is not hard to pick up the ereturned stuff:
program foo2, eclass
local depvar = e(depvar)
local predict = e(predict)
local estat_cmd = e(estat_cmd)
local cmd = e(cmd)
tempname bmat
matrix `bmat' = e(b)
matrix b = e(b)
ereturn post b
matrix `bmat'[1,1] = _b[mpg]
ereturn local predict = "`predict'"
ereturn local depvar = "`depvar'"
ereturn local estat_cmd = "`estat_cmd'"
ereturn local cmd = "`cmd'"
ereturn repost b = `bmat'
end
Now -predict prob, p- works, in the sense it doesn't return an error, though
it does not calculate the probability but rather the fitted values. The
probabilities can calculated by using the -invlogit- function, however I am
not sure why -predict prob, p - is not calculating the probabilities.
. qui logit fore mpg
. predict prob1, p
. foo2
. ereturn list
macros:
e(cmd) : "logit"
e(estat_cmd) : "logit_estat"
e(depvar) : "foreign"
e(predict) : "logit_p"
e(properties) : "b"
matrices:
e(b) : 1 x 2
. predict prob2 , p
. l prob* in 1/2
+---------------------+
| prob1 prob2 |
|---------------------|
1. | .2964837 -.864099 |
2. | .1593718 -1.66291 |
+---------------------+
. replace prob2 = invlogit(prob2)
(74 real changes made)
. l prob* in 1/2
+---------------------+
| prob1 prob2 |
|---------------------|
1. | .2964837 .2964837 |
2. | .1593718 .1593718 |
+---------------------+
Scott
*
* 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/