B. Calculate the sample mean and sample variance for wage in our sample of wages (6 points)
Note: from here on out, you need to create the chunks in your document. Make sure you name each chunk with a unique name corresponding to the question and subquestion.
In a new code chunk, create a new object called
mean10exper
that is equal to the sample mean of wage (wage10exper) for those observations in the sample (workers with less than 10 years of work experience). Then, create a new object called
n10exper
that is equal to the number of observations (n) in the sample. Then, create a new object called
var10exper
that is equal to the sample variance of wage (s2) for the sample. Use the sample variance formula from our notes, not the
var()
function (though it should give the same result, the point is to do it yourself). Finally, use
print(mean10exper)
,
print(var10exper)
, and
print(n10exper)
to output the sample mean, sample variance, and sample size.
Question What are the units of the wage column?
Hint: you can learn about wooldridge datasets by using the help for that data
?wage2
Leave a Reply