# How can I do t.test when I don't have a null value?

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!

• Could you explain why you want to calculate a confidence interval if you have the total population available? May 22 '19 at 14:59
• @COOLSerdash It's a question of a project with a given dataset. The exact phrasing is Choose a numerical variable from your dataset. 1. Calculate a 98% confidence interval for the mean of this variable. May 22 '19 at 15:00
• Thanks. You may want to edit your question and add this information. Also, please add the self-study tag as these questions are treated a bit differently here. Also I'm pretty sure that the data in the first and second t-test are different. I suspect that you re-ran the code so that a different sample was drawn from the population. If you supply the exact same data, the value of mu does not matter for the calculation of the confidence interval. You can also set a seed with set.seed() to make the calculations reproducible. May 22 '19 at 15:04
• @COOLSerdash I did, you're right the confidence interval for both is similar if I don't change the sample set. However, t score is different. Could one explain why is this so? May 22 '19 at 15:11
• Your question is solely about the confidence interval for which mu is irrelevant. So you can provide any number you wish. May 22 '19 at 15:25