[R] bootstrapped correlation confint lower than -1 ?
Duncan Murdoch
murdoch at stats.uwo.ca
Sun Aug 16 12:50:11 CEST 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?
>
Why not? You used an ordinary nonparametric bootstrap, so it doesn't
know that the parameter is constrained. The bootstrapped estimates of
the correlation will all lie between -1 and 1, but the basic bootstrap
confidence interval is not just the central 95% of the bootstrap
estimates (that's the percentile confidence interval), the basic
interval is twice the original estimate minus that range. See the
Davison and Hinkley reference.
Duncan Murdoch
> 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
>
>
>
>
>
>
>
>
>
More information about the R-help
mailing list