[R] bootstrapped correlation confint lower than -1 ?
Robert A LaBudde
ral at lcfltd.com
Sun Aug 16 18:01:21 CEST 2009
The "basic" interval (which you are using by default) is just the
usually normal distribution interval with the standard error
estimated from the resampling distribution. It has all the benefits
and problems of assuming a normal distribution.
If you wish to maintain the domain limits on the correlation, use the
"percentile" method, which would use the 2.5% and 97.5% quantiles of
the resampling distribution.
Because you clearly have a non-central correlation (-0.8), you would
get more accurate results with the "BCa" method, which does bias and
skew correction of the resampling distribution.
At 06:22 AM 8/16/2009, Liviu Andronic wrote:
>Dear R users,
>Does the results below make any sense? Can the the interval of the
>correlation coefficient be between *-1.0185* and -0.8265 at 95%
>confidence level?
>Liviu
>
> > library(boot)
> > data(mtcars)
> > with(mtcars, cor.test(mpg, wt, met="spearman"))
>
> Spearman's rank correlation rho
>
>data: mpg and wt
>S = 10292, p-value = 1.488e-11
>alternative hypothesis: true rho is not equal to 0
>sample estimates:
> rho
>-0.88642
>
>Warning message:
>In cor.test.default(mpg, wt, met = "spearman") :
> Cannot compute exact p-values with ties
> > corr.fun <- function(data, indices) {
>+ data.samp <- data[indices,] # allows boot to select sample
>+ tmp.corr <- with(data.samp, cor.test(mpg, wt, met="spearman"))
>+ return(tmp.corr$estimate)
>+ }
> > corr.boot <- boot(mtcars, corr.fun, R=1000)
>There were 50 or more warnings (use warnings() to see the first 50)
> > corr.boot
>
>ORDINARY NONPARAMETRIC BOOTSTRAP
>
>
>Call:
>boot(data = mtcars, statistic = corr.fun, R = 1000)
>
>
>Bootstrap Statistics :
> original bias std. error
>t1* -0.88642 0.012992 0.050042
> > boot.ci(corr.boot, type="basic")
>BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
>Based on 1000 bootstrap replicates
>
>CALL :
>boot.ci(boot.out = corr.boot, type = "basic")
>
>Intervals :
>Level Basic
>95% (-1.0185, -0.8265 )
>Calculations and Intervals on Original Scale
>
>
>
>
>
>
>
>
>--
>Do you know how to read?
>http://www.alienetworks.com/srtest.cfm
>Do you know how to write?
>http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail
>
>______________________________________________
>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.
================================================================
Robert A. LaBudde, PhD, PAS, Dpl. ACAFS e-mail: ral at lcfltd.com
Least Cost Formulations, Ltd. URL: http://lcfltd.com/
824 Timberlake Drive Tel: 757-467-0954
Virginia Beach, VA 23464-3239 Fax: 757-467-2947
"Vere scire est per causas scire"
More information about the R-help
mailing list