[R] Computing normal conf.intervals
P.Dalgaard at biostat.ku.dk
Thu Dec 20 12:34:44 CET 2007
Jonas Malmros wrote:
> Hi everybody,
> I wonder if there is a built-in function similar to Matlab's "normfit"
> which computes 95% CI based on the normality assumption.
> So, I have a vector of values and I want to calculate 95% normal CI.
> Of course, I could write my own function, no problem, but I still
> wonder if built-in functionality exists. (I wish quantile() had this
> functionality included).
> Anyone knows?
First, be more clear about what the intention is. Prediction intervals,
or confidence intervals for the mean? If the former, do you want the
crude version (plus/minus 1.96s) or the version that takes the
estimation variance into account
> x <- rnorm(10)
> qnorm(c(.025,.975), mean=mean(x), sd=sd(x))
 -1.763791 1.465144
> predict(lm(x~1), newdata=data.frame(1), interval="p")
fit lwr upr
[1,] -0.1493235 -2.103664 1.805017
2.5 % 97.5 %
(Intercept) -0.7385793 0.4399324
> Also, I wonder if there is a function similar to Matlab's "flipud".
> Obviously there is package "matlab" which has this function, but I
> wonder if I can turn a matrix upside-down without loading matlab
or (safer if nrow==0)
> Thanks for your help in advance!
O__ ---- Peter Dalgaard Øster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help