Hi everyone,
I'm running regressions, and wish to edit the results stored in e(b) or e(V) before storing the results. It is possible to extract e(b) and e(V) and edit them using standard matrix operations, but the resulting matrices must then be posted back into e(). As suggested previously (https://www.stata.com/statalist/arch.../msg00167.html), this editing of e() can be done with ereturn post.
(Sidenote: ereturn post returns a conformability error if V is supplied but b is not, but not vice versa. So updating V but not b is somewhat unwieldy).
However, the subsequent estimates store command returns an error r(301): "last estimation results not found, nothing to store". The issue appears to arise because ereturn post clears all existing e-class results, and thus presumably estimates store does not find what it expects.
The help file for ereturn suggests that ereturn repost allows the b or V matrix to be altered without removed previously stored results in e(). However, using it instead yields an immediate error, r(152): "non e-class program may not set e()". Perhaps I am missing something simple, but I cannot get ereturn repost to work at all.
Can anyone provide insight into whether it is possible to get around these issues and accomplish the goal of editing and updating e() using ereturn?
Sidenote: It appears there is a way to get around this issue by using a user-written function, erepost, but nonetheless it would be good to understand what is happening with the built-in functions.
Thanks,
Matthew
I'm running regressions, and wish to edit the results stored in e(b) or e(V) before storing the results. It is possible to extract e(b) and e(V) and edit them using standard matrix operations, but the resulting matrices must then be posted back into e(). As suggested previously (https://www.stata.com/statalist/arch.../msg00167.html), this editing of e() can be done with ereturn post.
Code:
version 16 clear all sysuse auto reg mpg price weight gear matrix list e(b) matrix b = e(b) * 2 matrix V = e(V) * 4 ereturn post b V matrix list e(b) estimates store test
However, the subsequent estimates store command returns an error r(301): "last estimation results not found, nothing to store". The issue appears to arise because ereturn post clears all existing e-class results, and thus presumably estimates store does not find what it expects.
The help file for ereturn suggests that ereturn repost allows the b or V matrix to be altered without removed previously stored results in e(). However, using it instead yields an immediate error, r(152): "non e-class program may not set e()". Perhaps I am missing something simple, but I cannot get ereturn repost to work at all.
Code:
version 16 clear all sysuse auto reg mpg price weight gear matrix V = e(V) * 4 ereturn repost V = V matrix list e(V)
Sidenote: It appears there is a way to get around this issue by using a user-written function, erepost, but nonetheless it would be good to understand what is happening with the built-in functions.
Code:
version 16 clear all sysuse auto reg mpg price weight gear mat V = e(V) * 4 erepost V = V mat list e(V) estimates store test
Matthew
Comment