Search in titles only. Posts Latest Activity. Page of 1. Filtered by:. Dusan Petrovic. Passing a local or scalar to a program as additional argument 20 Nov , Hello Statalisters, I would like to write a program where I can pass variables and arguments to a program.
I would want to repeat an operation with several variables for two categories for example: I've tried the syntax help, but I'm having a hard time with this: Code:. Tags: None. Suppose we want to bootstrap the variance inflation factor vif , which requires us to run regress and then estat vif.
In such a situation, the statistic to bootstrap falls out from a post estimation command, which is not obtainable from regress and therefore not accommodated by the bootstrap command.
Hence, we must write our own bootstrap program to get a bootstrap estimate of the vif. Click here to report an error on this page or leave a comment. Your Name required. Your Email must be a valid email for us to receive the report! How to cite this page. Example 1 This example we use the bootstrap command and replicate the results by writing our own bootstrap program.
Bias Std. In the first step we obtain initial estimates and store the results in a matrix, say observe. In addition, we must also note the number of observations used in the analysis.
To interpret the size of these ratios it is often useful to know the baseline odds, risk, incidence rate, etc, which happens to be the exponentiated constant. A doubling of these for a unit change in a explanatory variable is a lot more impressive if the baseline is already large: twice a small number is still a small number, but twice a large number is a huge number.
Unfortunately, Stata used to suppress the display of this baseline value. I tricked Stata in displaying these values by first creating a variable baseline , which is always 1, and than add that variable to the model together with the nocons option, so this variable plays the role of constant without Stata knowing it.
Also see this Stata Tip. It creates an indicator dummy variable that is 1 if rep78 is 3, missing if rep78 is missing, and zero otherwise. For a detailed explanation see this official Stata FAQ. Alternative and shorter methods for creating a series of indicator variables from rep78 are: xi i. Since Stata 11 one can add categorical variables directly without xi using factor variables. It creates an interaction between the variable price and an indicator dummy variable that is 1 if rep78 is 3, missing if rep78 is missing, and zero otherwise, without first making the indicator variable.
In many cases I would now use Stata's factor variables , but there are still situations where this is a convenient trick. Table of content Why do you sometimes add if rep78 to a command? Within the auto dataset the variable rep78 is the only variable with missing values. Missing values in Stata are represented by a. So any value less than. For a detailed explanation see this and this official Stata FAQ.
Table of content What does! Also see this official Stata FAQ. It creates a dummy variable that is 1 if the car is domestic and 0 if it is foreign. This is a convenient way to "flip" a dummy variable. Notice I did not add if foreign. This is bad style, but it works since I know that the variable foreign does not contain any missing values. In order to make use of the factor variable notation I need to combine these into a single categorical variable. Finally, the!
So to keep the missing values missing I need to add if! FAQ on example code sent to the statalist by Maarten Buis When posting messages to statalist I often add example code. Table of content How can I make the example work? Why don't you just give the output? What does sysuse auto, clear mean? Why do you put things like long , double , or str8 between variable names when you use input?
Why do I add the variable baseline together with the nocons option? Why do you sometimes add if rep78 to a command? What does! What does the? What does or mean in a list of variables? What does floor x or ceil x mean? What does mod x, y mean? What does 1e4 or 2. What does if! What does vecdiag cholesky diag vecdiag V ' mean?
What does delim ; and delim cr do? What does tempfile do? What does capture program drop do? How can I make the example work? Within the email select the example and copy it: Within Stata type doedit in the command window: This will open the do-file editor: Paste the example in the do-file editor: Do the do-file by pressing the last button on the right see here for instructions for older versions of Stata : And you will get the output: Table of content Why don't you just give the output?
Table of content What does the? All variables whose name begins with a w and with only one other character, see help varlist. Table of content What does or mean in a list of variables? It means that I am using Stata's factor variable notation to create interactions.
0コメント