Reputation: 11
Make a 95% confidence interval for the difference in earnings between above median height men and below median height men.
What programs/scripts would be helpful for a problem such as this in R?
Was able to use commands like:
# Use this command to calculate 95% confidence interval for difference in
# height means between males and females
t.test(height ~ sex, data=CPS, conf.level=.95)
But cannot think of a way to find the confidence interval of below median and above median heights for the same dataset. Any tips? Sorry, new to R.
Upvotes: 0
Views: 112
Reputation: 8252
(Hints/outline of solution because this is homework.)
You don't make it clear what data you have. What are the variables and other information that's available?
My guess is (it's not stated clearly) you're intended to do this on the sample median height rather than some externally determined value for median height.
You'll need to construct a factor (at least implicitly) that indicates if height is greater than median height.
[Unfortunately, this invalidates the proposed test/confidence interval in the question -- see several posts on stats.stackexchange which discuss the issue -- but let's ignore that for now and treat it as a pure R-code issue.]
You'll then need to construct a confidence interval, perhaps using the example code in your question as a template.
Note that you're working with a subset of all people so you'll have to subset your data at some point, either before calling a function to do the CI, or within it. (That is, there are three variables in this problem, a response, a factor for comparing the response across and a variable for subsetting on.)
Upvotes: 1