[R] sciplot question

Frank E Harrell Jr f.harrell at vanderbilt.edu
Sun May 24 15:34:47 CEST 2009


Jarle Bjørgeengen wrote:
> Great,
> 
> thanks Manuel.
> 
> Just for curiosity, any particular reason you chose standard error , and 
> not confidence interval as the default (the naming of the plotting 
> functions associates closer to the confidence interval .... ) error 
> indication .
> 
> - Jarle Bjørgeengen
> 
> On May 24, 2009, at 3:02 , Manuel Morales wrote:
> 
>> You define your own function for the confidence intervals. The function
>> needs to return the two values representing the upper and lower CI
>> values. So:
>>
>> qt.fun <- function(x) qt(p=.975,df=length(x)-1)*sd(x)/sqrt(length(x))
>> my.ci <- function(x) c(mean(x)-qt.fun(x), mean(x)+qt.fun(x))

Minor improvement: mean(x) + qt.fun(x)*c(-1,1) but in general confidence 
limits should be asymmetric (a la bootstrap).

I'm not sure how NAs are handled.

Frank

>>
>> lineplot.CI(x.factor = dose, response = len, data = ToothGrowth,
>>    ci.fun=my.ci)
>>
>> Manuel
>>
>> On Fri, 2009-05-22 at 18:38 +0200, Jarle Bjørgeengen wrote:
>>> Hi,
>>>
>>> I would like to have lineplot.CI and barplot.CI to actually plot
>>> confidence intervals , instead of standard error.
>>>
>>> I understand I have to use the ci.fun option, but I'm not quite sure
>>> how.
>>>
>>> Like this :
>>>
>>>> qt(0.975,df=n-1)*s/sqrt(n)
>>>
>>> but how can I apply it to visualize the length of the student's T
>>> confidence intervals rather than the stdandard error of the plotted
>>> means ?
>>>
>> -- 
>> http://mutualism.williams.edu
>>
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 


-- 
Frank E Harrell Jr   Professor and Chair           School of Medicine
                      Department of Biostatistics   Vanderbilt University




More information about the R-help mailing list