[R] Confidence intervals for Sen slope in zyp-package

Jim Lemon jim at bitwrit.com.au
Wed Nov 7 09:13:20 CET 2012


On 11/07/2012 12:31 AM, kunger at gfz-potsdam.de wrote:
> Hi,
>
> I have a question about the computation of confidence intervals in the zyp package, in particular using the functions zyp.sen and confint.zyp, or zyp.yuepilon.
>
> (1) I'm a bit confused about the confidence intervals given by zyp.sen and confint.zyp. When I request a certain confidence interval in the function, the R output seems to deliver another confidence interval, e.g. when I set level=0.95 in the function, then the output is for 0.025 and 0.975 (instead of the expected 0.05 and 0.95). See example below. Which confint statement is the right one?
>
> (2) I checked the documentation but did not find a specification about which confidence interval is used in the zyp.yuepilon function. It seems to be the same as level=0.95 in confint.zyp (I'm not sure if this is 0.95 or 0.975 - see above).
>
> Maybe, I'm just not seeing the obvious explanation... Could anybody advise me?
>
> Thanks in advance,
> Katy
>
> ---
> My example:
>
>> x<- c(0, 1, 2, 3, 4, 5)
>> y<- c(6, 4, 1, 8, 7, 8)
>
> # zyp.sen and confint.zyp function
>
>> slope<- zyp.sen(y~x)
>> slope$coef
>
> Intercept         x
> 4.5000000 0.6666667
>
>> ci_99<- confint.zyp(slope, level=0.99)
>> ci_99
>
>                0.005    0.995
> Intercept -2.071288 10.07129
> x         -3.000000  3.00000
>
>> ci_95<- confint.zyp(slope, level=0.95)
>> ci_95
>
>                 0.025    0.975
> Intercept -0.6196794 8.619679
> x         -2.5000000 2.333333
>
>> ci_90<- confint.zyp(slope, level=0.90)
>> ci_90
>
>                  0.05     0.95
> Intercept  0.1230428 7.876957
> x         -2.0000000 2.000000
>
> # zyp.yuepilon
> # confidence interval corresponds to nominal 0.95 interval in confint.zyp (output 0.025 0.975)
>
>> xy_senslope<- zyp.yuepilon (y, conf.intervals=TRUE)
>> xy_senslope
>
>       lbound       trend      trendp      ubound         tau         sig       nruns     autocor  valid_frac
> -2.50000000  0.66666667  4.00000000  2.33333333  0.80000001  0.08641075  1.00000000 -0.22400000  1.00000000
>       linear   intercept
>   0.74285714  3.83333333
>
>
Hi Katy,
I didn't see an answer to this, so I'll attempt one. A 95% confidence 
interval is defined as an interval within which 95% of replicated values 
will fall. In most cases, the preferred confidence interval among the 
many which could be calculated is symmetric about the observed value in 
the sense that half of the replicated values are expected to fall above 
the observed value and half below. This means that 2.5% of replications 
would be expected to produce values below the lower confidence limit and 
2.5% above the upper one. If these proportions were 5% below and 5% 
above, you would get a 90% confidence interval.

Jim




More information about the R-help mailing list