I think -ereturn repost- cannot be used with estimates produced by -regress-because -regress- is one of the commands that does not use -ereturn post- to post its results. (Don't ask me why. StataCorp would have to comment on this) A solution to the problem is to also get the coefficients vector and -ereturn post- the transformed results. Example:
capture program drop foo2
program foo2, eclass
tempname b V
matrix `b' = e(b)
matrix `V' = e(V)
matrix `V'[1,1] = 122
ereturn post `b' `V'
ereturn local cmd "mycmd"
end
Note that it always advisable to define e(cmd) after posting the new results (for example, the -estimates- command will not work if e(cmd) is undefined). Depending on your needs you should also think of setting e(sample), e(N) etc.
A simple strategy to replicate everything in e() is to use Michael Blasnik -estsave- (-ssc d estsave-). Example:
capture program drop foo2
program foo2, eclass
tempvar esave
qui estsave, gen(`esave')
qui estsave, from(`esave')
tempname V
matrix `V' = e(V)
matrix `V'[1,1] = 122
ereturn repost V=`V'
end
ben
> -----Original Message-----
> From: [email protected] [mailto:owner-
> [email protected]] On Behalf Of nicolas.pistolesi
> Sent: Tuesday, February 21, 2006 2:30 PM
> To: statalist
> Subject: st: editing e(V) matrix
>
> Dear Stata users,
> I have stata 8.2 for windows. I would like to edit the
> variance matrix e(V) after a linear regression, ereturn
> repost, seems to be the right command. I do not manage to use
> it correctly. See the log :
>
> . capture program drop foo2;
> . program foo2, eclass;
> 1. matrix bmat = e(V);
> 2. matrix bmat[1,1] = 122;
> 3. ereturn repost V = bmat;
> 4. end;
>
> . sysuse auto;
> (1978 Automobile Data)
>
> . quietly regress price mpg weight;
> . matrix list e(V);
> symmetric e(V)[3,3]
> mpg weight _cons
> mpg 7422.863
> weight 44.601659 .41133468
> _cons -292759.82 -2191.9032 12938766
>
> . foo2;
> last estimates not found
>
>
> any idea why?, thank you very much for your help !
> nicolas
>
>
> Acc�dez au courrier �lectronique de La Poste : www.laposte.net ;
> 3615 LAPOSTENET (0,34 �/mn) ; t�l : 08 92 68 13 50 (0,34�/mn)
>
>
>
>
> *
> * 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/
*
* 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/