[This article was first published on Freakonometrics - Tag - R-english, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Friday in the course of statistics, we started the section on confidence interval, and like
always, I got a bit confused with the degrees of freedom of the Student
(should it be
And each time I start to get confused, the student obviously see it,
and start to ask tricky questions… So let us make it clear now. The correct formula is the following: let
But the important thing is neither the n-1 that appear as degrees of freedom nor the
Consider the following case: we have
n=20; X=rt(n,df=3)
for(s in 1:10000){ X=rt(n,df=3) pv[s]=ad.test(X)$p.value } mean(pv>.05) [1] 0.6799
For those samples, we can look at bounds of the 90% confidence interval for the mean, with three different formulas,
(and one might think to look at the non-unbiased estimator of the variance, also).
for(s in 1:10000){ X=rt(n,df=3) m[s]=mean(X) sd=sqrt(var(X)) IC1[s]=m[s]-qt(.95,df=n-1)*sd/sqrt(n) IC2[s]=m[s]-qt(.95,df=n)*sd/sqrt(n) IC3[s]=m[s]-qnorm(.95)*sd/sqrt(n) }
The dotted vertical line is the true lower bound of the 90%-confidence interval, given the true distribution (which was not a Gaussian one).
If I get back to the standard procedure in any statistical textbook, since the sample is almost Gaussian, the lower bound of the confidence interval should be (since we have a Student t distribution)
mean(IC1) [1] -0.605381
mean(IC3) [1] -0.5759391
quantile(m,.05) 5% -0.623578As I mentioned in a previous post (here), an important issue is that if we do not know a parameter and substitute an estimator, there is usually a cost (which means usually that the confidence interval should be larger). And this is what we observe here. From a teacher’s point of view, it is an important issue that should be mentioned in statistical courses….
But another important point is also that confidence interval is valid only if the underlying distribution is Gaussian. And not almost Gaussian, but really a Gaussian one. So since with
To leave a comment for the author, please follow the link and comment on their blog: Freakonometrics - Tag - R-english.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.