[R] Student Distribution and Funtion qt
"Antje Schafföner"
AS-maus at gmx.de
Mon Jun 9 15:14:02 CEST 2008
Hello,
I am trying to calculate and plot mean and confidence intervall for a set of data. This is the code that I am currently using:
means <- sapply(data, mean, na.rm=TRUE)
n <- sapply(data,length)
stdev <- sqrt(sapply(data, var, na.rm=TRUE))
ciw <- qt(0.98, n) * stdev / sqrt(n)
par(mgp=c(2,0.6,0), las=2, fin=c(7,3), mai=c(1,0.5,0.2,0.2), cex=0.8)
plotCI(x=means, uiw=ciw, ylim=c(0,100), col="red",col.axis="black",add=F)
The code works fine, just the results are not as expected. I compared the results that R calculates for my variable ciw and noticed differences compared to other calculations. I suppose that the reason can be found in the value that qt(0.98, n) calculates.
I compared the results of qt with the values I would expect and found out that it returns the values of the student distribution for a one-sided question (eg. qt(0.99, 10) = 2.76). Is there a way to use qt to calcute the quantiles for a two-sided problem? Or is there a different function I could use in a similar way as qt?
Thanx, Antje
--
Jetzt dabei sein: http://www.shortview.de/?mc=sv_ext_mf@gmx
More information about the R-help
mailing list