Description Usage Arguments Details Value Note See Also Examples
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.
1 |
x, y |
two continuous variables. |
paired |
a logical value. If it equals TRUE, you must provide values for |
conf.level |
confidence level for the confidence interval. |
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.
Returns the confidence interval along with the estimate of the median.
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
.
mediantest
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
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.