Good afternoon,
When programming an estimation command in Stata, what is the best practice of dealing with the Intercept/Constant vector of 1s?
i) When I use a temporary variable for the vector of 1s, to not change the user's data, then I get in my resulting estimation tables some nasty looking name for the intercept such as __0000A. Added problem here is that when my command finishes executing, the temporary Intercept variable disappears (as it should), and cannot be used in subsequent postestimation commands.
ii) When I create a variable for the vector of 1s, I fiddle with the user's data which probably I shouldn't, and in principle I could hit a name conflict with an existing variable.
What I do currently is that I create a vector of 1s with an unlikely name
- gen _ones=1-
which vector I leave behind after my estimation command is done to potentially use in postestimation commands.
iii) Stata provides a system scalar _cons, which scalar is 1. What is the use of that, how am I supposed to use it in estimation commands? I think what would have been useful here for the _cons to be a vector of 1s, and not a scalar, but maybe I just have not figured out the intended use of the system scalar _cons..
In short, what is the best practice when we are explicitly creating an Intercept/Constant vector in our estimation commands?
When programming an estimation command in Stata, what is the best practice of dealing with the Intercept/Constant vector of 1s?
i) When I use a temporary variable for the vector of 1s, to not change the user's data, then I get in my resulting estimation tables some nasty looking name for the intercept such as __0000A. Added problem here is that when my command finishes executing, the temporary Intercept variable disappears (as it should), and cannot be used in subsequent postestimation commands.
ii) When I create a variable for the vector of 1s, I fiddle with the user's data which probably I shouldn't, and in principle I could hit a name conflict with an existing variable.
What I do currently is that I create a vector of 1s with an unlikely name
- gen _ones=1-
which vector I leave behind after my estimation command is done to potentially use in postestimation commands.
iii) Stata provides a system scalar _cons, which scalar is 1. What is the use of that, how am I supposed to use it in estimation commands? I think what would have been useful here for the _cons to be a vector of 1s, and not a scalar, but maybe I just have not figured out the intended use of the system scalar _cons..
In short, what is the best practice when we are explicitly creating an Intercept/Constant vector in our estimation commands?
Comment