I have a dataset containing 20,000 records of home sales. I'm asked
Choose a numerical variable from your dataset. 1. Calculate a 98% confidence interval for the mean of this variable.
I chose the price and I want to find a 98% confidence interval of the mean. It's what I did
mu = mean(hs$price) cat("Mean of population:", mu, "\n") sample_price = sample(hs$price, 200) xbar = mean(sample_price) cat("Mean of sample:", xbar, "\n\n") t.test(sample_price, conf.level = 0.98, mu=?????)
In the code above, what should I put for the
mu in the
t.test? Should I put the mean of population? A guess around it? Nothing? zero?
Then what would be the difference if I leave the parameter (I guess the default is zero) or if I put the mean of population?
If i provide no value for
mu I have:
One Sample t-test data: sample_price t = 25.138, df = 199, p-value < 2.2e-16 alternative hypothesis: true mean is not equal to 0 98 percent confidence interval: 491719.9 592909.1 sample estimates: mean of x 542314.5
If I put the
mu = mu then I have:
One Sample t-test data: sample_price t = 0.1032, df = 199, p-value = 0.9179 alternative hypothesis: true mean is not equal to 540088.1 98 percent confidence interval: 491719.9 592909.1 sample estimates: mean of x 542314.5
The confidence interval is the same, however the
t score is different. Which one is correct? What is the interpretation of each!