Stat question
Question: Is it better in terms of Type I and Type II error to delete tied values or to use the midrank correction?
Use at least three different sample sizes, two different significance levels, two values of “d”, two different distributions, and 10% versus 30% tied values.
Use any test in Chapters 2 – 7 of the text, except for Wilcoxon rank sum, Siegel-Tukey, and two-sample t-test.
Useful code:
## Power for sign test vs. t-test if the distribution is normal
require(coin)
require(rmutil)
powerFun.norm <- function(n,d=1,p=0.5,alpha=0.05,sigma=1,nsims=1000)
{
pval.sign <- numeric(nsims)
pval.t <- numeric(nsims)
pval.wsr <- numeric(nsims)
for (i in 1:nsims) {
dat1 <- rnorm(n,mean=0,sd=sigma)
dat2 <- rnorm(n,mean=d,sd=sigma)
diff <- dat2-dat1
ts <- length(diff[diff > 0])
pval.sign[i] <- binom.test(ts,n)$p.value
pval.wsr[i] <- pvalue(wilcoxsign_test(dat2~dat1))
pval.t[i] <- t.test(diff)$p.value
}
power.sign <- length(pval.sign[pval.sign < alpha])/nsims
power.wsr <- length(pval.wsr[pval.wsr < alpha])/nsims
power.t <- length(pval.t[pval.t < alpha])/nsims
return(list(sign = power.sign, WSR = power.wsr, t=power.t))
}
powerFun.norm(10)
powerFun.norm(20)
# Underlying distribution is exponential
powerFun.exp <- function(n,d=0.5,p=0.5,alpha=0.05,sigma=1,nsims=1000)
{
pval.sign <- numeric(nsims)
pval.t <- numeric(nsims)
pval.wsr <- numeric(nsims)
for (i in 1:nsims) {
dat1 <- rexp(n,rate=1)
dat2 <- rexp(n,rate=d)
diff <- dat2-dat1
ts <- length(diff[diff > 0])
pval.sign[i] <- binom.test(ts,n)$p.value
pval.wsr[i] <- pvalue(wilcoxsign_test(dat2~dat1))
pval.t[i] <- t.test(diff, mu=1)$p.value
}
power.sign <- length(pval.sign[pval.sign < alpha])/nsims
power.wsr <- length(pval.wsr[pval.wsr < alpha])/nsims
power.t <- length(pval.t[pval.t < alpha])/nsims
return(list(sign = power.sign, WSR = power.wsr, t=power.t))
}
powerFun.exp(10)
powerFun.exp(20)
powerFun.dexp <- function(n,d=1,p=0.5,alpha=0.05,sigma=1,nsims=1000)
{
pval.sign <- numeric(nsims)
pval.t <- numeric(nsims)
pval.wsr <- numeric(nsims)
for (i in 1:nsims) {
dat1 <- rlaplace(n,m=0,s=sigma)
dat2 <- rlaplace(n,m=d,s=sigma)
diff <- dat2-dat1
ts <- length(diff[diff > 0])
pval.sign[i] <- binom.test(ts,n)$p.value
pval.wsr[i] <- pvalue(wilcoxsign_test(dat2~dat1))
pval.t[i] <- t.test(diff)$p.value
}
power.sign <- length(pval.sign[pval.sign < alpha])/nsims
power.wsr <- length(pval.wsr[pval.wsr < alpha])/nsims
power.t <- length(pval.t[pval.t < alpha])/nsims
return(list(sign = power.sign, WSR = power.wsr, t=power.t))
}
powerFun.dexp(10)
powerFun.dexp(20)
7 years ago
10
Purchase the answer to view it

- statquestion.docx
- statquestion1.docx
- statquestion1.docx
- Question1.docx
- COM 215 Week 1 Post Traumatic Stress Disorder and Our Nation
- CJA 491 Week 2 Learning Team Assignment Procedures Q&A Response
- WEB 240 Week 5 DQ 1 and DQ 2
- PSY 480 Week 1 DQ 1 and DQ 2
- HSM 250 Week 3 CheckPoint Collaborative Discussion and Reflection on Perceptions
- HCS 446 Week 1-5 Entire course A++ 100%
- HCS 212 Week 1 - DQ 1 and DQ 2
- FIN 534 Week 8 DQs
- FIN 515 Managerial Finance - Entire Course Week 1 - 8
- FIN 534 Qu-iz 5 3#