R 要安装用于cuzick测试的软件包
我应该为cuzick测试安装哪个软件包?我已经尝试了PMCMRplus,并安装了github(“raredd/rawr”),但我仍然找不到任何用于cuzick测试的包{R 要安装用于cuzick测试的软件包,r,install.packages,R,Install.packages,我应该为cuzick测试安装哪个软件包?我已经尝试了PMCMRplus,并安装了github(“raredd/rawr”),但我仍然找不到任何用于cuzick测试的包{ cuzick = function(x,z,test.type=c("two.sided", "upper", "lower")) { test.type <- match.arg(test.type) N = length(z) n = unique(z) ranks=rank(x)
cuzick = function(x,z,test.type=c("two.sided", "upper", "lower")) {
test.type <- match.arg(test.type)
N = length(z)
n = unique(z)
ranks=rank(x)
T = sum(ranks*z)
p = (table(z)/N)
E_Z = sum(unique(z)*p)
E_T = 0.5*N*(N+1)*E_Z
Var_Z = sum(unique(z)^2*p) - E_Z^2
Var_T = N^2*(N+1)/12*Var_Z
Zscore = (T-E_T)/sqrt(Var_T)
if(test.type == "two.sided") {
pval = 2*pnorm(-abs(Zscore))
} else if(test.type == "upper") {
pval = pnorm(Zscore,lower.tail=F)
} else pval = pnorm(Zscore,lower.tail=T)
out = data.frame(Zscore,pval,test.type)
colnames(out) = c("Z","p","testType")
return(out)
}
test.type请解释您的代码。仅代码的答案并不完全有用!