r语言的runmed函数_r语言中如何进行两组独立样本秩和检验

安装所需的包

wants

has

if(any(!has)) install.packages(wants[!has])>

一个样本

set.seed(123)

medH0

DV

DV

N

(obs medH0))

[1] 15

(pGreater

[1] 0.02069

(pTwoSided

[1] 0.04139

威尔科克森排检验

IQ

medH0

wilcox.test(IQ, alternative="greater", mu=medH0, conf.int=TRUE)

`Wilcoxon signed rank test

data: IQ

V = 48, p-value = 0.01855

alternative hypothesis: true location is greater than 110

95 percent confidence interval:

113.5 Inf

sample estimates:

(pseudo)median

121`

两个独立样本

Nj

DVa

DVb

wIndDf

IV=factor(rep(1:2, Nj), labels=LETTERS[1:2]))

查看每组中低于或高于组合数据中位数的个案数。

library(coin)

median_test(DV ~ IV, distribution="exact", data=wIndDf)

`Exact Median Test

data: DV by IV (A, B)

Z = 1.143, p-value = 0.3868

alternative hypothesis: true mu is not equal to 0`

Wilcoxon秩和检验(曼 - 惠特尼检疫)

wilcox.test(DV ~ IV, alternative="less", conf.int=TRUE, data=wIndDf)

`Wilcoxon rank sum test

data: DV by IV

W = 202, p-value = 0.02647

alternative hypothesis: true location shift is less than 0

95 percent confidence interval:

-Inf -1.771

sample estimates:

difference in location

-9.761`

library(coin)

wilcox_test(DV ~ IV, alternative="less", conf.int=TRUE,

distribution="exact", data=wIndDf)

`Exact Wilcoxon Mann-Whitney Rank Sum Test

data: DV by IV (A, B)

Z = -1.941, p-value = 0.02647

alternative hypothesis: true mu is less than 0

95 percent confidence interval:

-Inf -1.771

sample estimates:

difference in location

-9.761`

两个依赖样本

N

DVpre

DVpost

wDepDf

DV=c(DVpre, DVpost),

IV=factor(rep(0:1, each=N), labels=c("pre", "post")))

medH0

DVdiff

(obs

[1] 7

(pLess

[1] 0.1316

排名威尔科克森检验

wilcoxsign_test(DV ~ IV | id, alternative="greater",

distribution="exact", data=wDepDf)

`Exact Wilcoxon-Signed-Rank Test

data: y by x (neg, pos)

stratified by block

Z = 2.128, p-value = 0.01638

alternative hypothesis: true mu is greater than 0`

分离(自动)加载的包

try(detach(package:coin))

try(detach(package:modeltools))

try(detach(package:survival))

try(detach(package:mvtnorm))

try(detach(package:splines))

try(detach(package:stats4))

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值