medianCI: Confidence interval for the median in the one sample and in...

Description Usage Arguments Details Value Note See Also Examples

View source: R/medianCI.R

Description

In the one sample case, compute the confidence interval for the median of the random variable. In the paired two sample case, compute the confidence interval for the median of the difference between the two random variables.

Usage

1
medianCI(x, y = NULL, paired = FALSE, conf.level = 0.95)

Arguments

x, y

two continuous variables.

paired

a logical value. If it equals TRUE, you must provide values for x and y and the paired test is implemented. If it equals FALSE, only x must be provided.

conf.level

confidence level for the confidence interval.

Details

Provide the confidence interval for Med(X) in the one sample case and for Med(X-Y) in the two sample case. The confidence interval is based on the rank statistic.

Value

Returns the confidence interval along with the estimate of the median.

Note

The paired median confidence interval can be implemented by providing the variables x and y or by just providing one vector equal to the difference between x and y.

See Also

mediantest

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#Simulations
n=100
M=2000 #number of replications
res1=res2=res3=rep(NA,M)
testone=function(n){
D=rchisq(n,df=4)-qchisq(df=4, p=0.5)
result=medianCI(D)
list(test1=mediantest(D)$p.value,test2=c(result$CI))
}
for (i in 1:M)
{
result=testone(n)
res1[i]=result$test1
res2[i]=result$test2[1]
res3[i]=result$test2[2]
}
mean(res1<0.05) #0.049
(sum(res2>0)+sum(res3<0))/M #0.0525

obouaziz/robusTest0 documentation built on Dec. 22, 2021, 4:13 a.m.