STATA Exercise - FHSS Research Support Center

advertisement
STATA BASICS WORKSHOP – PRACTICAL PRACTICE
Using the example data set auto.dta saved in Stata’s memory (command:sysuse auto.dta, clear), answer the following:
1.
2.
3.
What percent of sampled cars were foreign in 1978?
a.
Syntax _____________________________________________________________________________________
b.
Answer ____________________________________________________________________________________
What is the mean weight of cars in 1978? What is the median weight of cars?
a.
Syntax _____________________________________________________________________________________
b.
Answer ____________________________________________________________________________________
Create a histogram for the variable mpg.
a.
4.
5.
Syntax _____________________________________________________________________________________
What are the four most expensive cars in 1978?
a.
sort Syntax ________________________________________________________________________________
b.
list Syntax ________________________________________________________________________________
c.
Answer ____________________________________________________________________________________
Perform a regression to determine if a car’s mpg helps determine its price.
Is mpg significant at α = .05?
Produce an appropriate scatter plot.
6.
a.
regress Syntax ____________________________________________________________________________
b.
Answer ____________________________________________________________________________________
c.
scatter Syntax ____________________________________________________________________________
Using the information from Question 5, what happens if we add weight as an independent variable to our analysis?
Is weight significant at α = .05? At α = .01?
7.
a.
Syntax _____________________________________________________________________________________
b.
Answer ____________________________________________________________________________________
Create a new variable efficiency that groups different levels of mpg efficiency. Assume the following: a car that gets
less than 15 mpg is “inefficient”, between 15 and 30 mpg is “moderately efficient”, and above 30 mpg is “efficient”.
Produce the appropriate accompanying labels. How many are considered “efficient”?
8.
a.
recode, gen() Syntax _____________________________________________________________________
b.
label variable Syntax ____________________________________________________________________
c.
label define Syntax ______________________________________________________________________
d.
label values Syntax _____________________________________________________________________
e.
tabulate Syntax ___________________________________________________________________________
f.
Answer ____________________________________________________________________________________
Perform the same analysis as in Question 6 using the variable efficiency (created Question 7) instead of mpg.
Run the regression with efficiency as a categorical variable.
Is weight significant at α = .01? Is the overall model significant at α = .01?
9.
a.
i.variable Syntax ________________________________________________________________________
b.
Answer ____________________________________________________________________________________
Store the predicted values of price from the model in Question 8.
a.
Syntax _____________________________________________________________________________________
FHSS Research Support Center / 116 SWKT / (801) 422-5114 / fhssresearch@gmail.com / fhssrsc.byu.edu
Download