Stata commands Flashcards
How do you create a quadratic term for the variable age?
generate agesq = age^2
How do you create the natural logarithm of the variable wage?
generate logwage = log(wage)
How do you create an interaction variable equal to the product of the variables x2 and x2?
generate x2_x3 = (x2*x3)
How do you create a ratio of two variables such as wages over hours (hourly wages)?
generate hrwage = wage/hours
How do you create a dummy variable which equal 1 when the variable year is equal to or greater than 47, and zero if otherwise?
generate D = (year>=47)
This creates a dummy variable Di, equal to 1 for observation I if the condition in parentheses is true. Di = 0 if the condition in the parentheses doesn’t hold (i.e. year<47)
How do you create a multiple linear regression which regresses the outcome variable, y, on three regressors, x1, x2 and x3?
regress y x1 x2 x3
How do you create a multiple linear regression with heteroscedasticity-robust standard errors which regresses the outcome variable, y, on three regressors, x1, x2 and x3?
regress y x1 x2 x3, robust
note: the comma is important!