<> <> set linesize 80 <> # A fuel consumption study of Stata's auto dataset We conduct a study of the fuel consumption of cars in Stata's auto dataset. ~~~~ <> sysuse auto, clear <> ~~~~ ## Perform data transformation We generate a variable, **fuel**, that measures the fuel consumption rate in the unit of Gallons per 100 Miles. ~~~~ <> generate fuel = 100/mpg label variable fuel "Fuel consumption (Gallons per 100 Miles)" <> ~~~~ ## Examine the variables We examine variables for possible errors in the data. ~~~~ <> describe fuel weight <> ~~~~ <> assert fuel > 0 <> ~~~~ <> summarize weight <> ~~~~ The variable **weight** has minimum value <>, maximum value <>, and range <>. ## Plot fuel consumption and vehicle weight ~~~~ <> scatter fuel weight, mcolor(blue%50) <> ~~~~ <> ## Explore relationship between fuel consumption and vehicle weight - linear regression ~~~~ <> regress fuel weight <> ~~~~ <> matrix define eb = e(b) <> <> The regression shows that for every unit increase in weight, a <> unit increase in fuel consumption is predicted. <> The regression shows that for every unit increase in weight, a <> unit decrease in fuel consumption is predicted. <>