I want to convert a degree of freedom of t-distribution to follow a standard deviation of normal distribution to plot a density line.
Assume I have a samples (size =14) with mean =0 and sd = 7.8, I want to plot a normal distribution density line with mean =0 and sd = 7.8 and a t-distribution density with same mean =0 and sd =7.8 which will be represented through degree of freedom.
Is it impossible to do it?
Example: Groundwater sulfate concentrations are monitored at a contaminated site over the course of a year.Those concentrations are compared to ones measured at background sites for the same time period. You want to determine if the concentration at the contaminated site is significantly larger than that for the background site. The concentrations of sulfate (in ppm) for both sites are as follows:
contaminated = c(600,590,570,570,565,580)
background = c(560,550,570,550,570,590, 550,580)
H0 : mean of contaminated = mean of background, so, mean of contaminated - mean of background =0, so, expected value of H0 = 0
Ha : mean of contaminated > mean of background, so, mean of contaminated - mean of background >0
se.pooled = sqrt( (length(contaminated)-1)*var(contaminated) + (length(background)-1)*var(background) )/sqrt(length(contaminated)+ length(background)-2)
se.h0 = (se.pooled * sqrt(1/length(contaminated) + 1/length(background)))
t= (mean(contaminated) - mean(background)) / se.h0
p.value.t = pt(t, df =12 , lower.tail = F)
With the results of t = 1.809851
and se.h0 = 7.827532
, I want to plot a density t-distribution whose mean = expected value of H0 =0
and sd = se.h0
under a normal distribution whose mean = expected value of H0 =0
and sd = se.h0
.
I try it but I do not know how to convert the df =12 in t-distribution to be proportional with sd.h0 of normal distribution. Because the t-distribution's variance = n/(n-2), so it only reach to normal distribution curve with sd = 1 (not a sd which I choose) when n get large and the result is:
1st try : I used df = se.h0/ (df of sample)
x.axis = seq(0 - se.h0*3, 0 + se.h0*3, length =100)
plot(x.axis, dnorm(x.axis, mean =0, sd = se.h0), type ="l", col = "red", ylim=c(0,0.27))
lines(x.axis, dt(x.axis-0, df = se.h0/12), type = "l")
abline(h=0)
abline(v= t*se.h0, col = "red", lty =2)
abline(v= 0, lty =2)
the plot looks quite good but I know something wrong in that because t-distribution has a variance = df/(df-2), so the t distribution density curve is too thin and fall out side the normal distribution density curve
https://app.box.com/s/uzyjr17go6fybgqzz94j4td0fxw4f7er
Red line is normal distribution and blue line is t distribution density Red dash-line is x= t ( t statistic I computed above)
2nd try: I used df = 2*var/ (var -1) = 2*se.h0^2 / (se.h0^2 -1) and the plot look disaster ! Red dash-line x= t fall outside the density curve of t-distribution
https://app.box.com/s/svt2x66jmsj8lzqcllcutlliufn20g08
EDIT : I found the solution
plot(x.axis, dnorm(x.axis, mean =0, sd = se.h0), type ="l", col = "red")
lines(x.axis, dt.scaled(x.axis, df=12, mean =0, sd = se.h0), type ="l", col = "blue")
abline(h=0)
abline( v= t*se.h0, col = "red", lty =2)
abline( v= 0, lty =2)