日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

r语言 adf检验_r语言中如何进行两组独立样本秩和检验

發(fā)布時(shí)間:2023/12/1 编程问答 55 豆豆
生活随笔 收集整理的這篇文章主要介紹了 r语言 adf检验_r语言中如何进行两组独立样本秩和检验 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
r語言中如何進(jìn)行兩組獨(dú)立樣本秩和檢驗(yàn)?tecdat.cn

安裝所需的包

wants <- c("coin") has <- wants %in% rownames(installed.packages()) if(any(!has)) install.packages(wants[!has])>

一個樣本

測試

set.seed(123) medH0 <- 30 DV <- sample(0:100, 20, replace=TRUE) DV <- DV[DV != medH0] N <- length(DV) (obs <- sum(DV > medH0))

[1] 15

(pGreater <- 1-pbinom(obs-1, N, 0.5))

[1] 0.02069

(pTwoSided <- 2 * pGreater)

[1] 0.04139

威爾科克森排檢驗(yàn)

IQ <- c(99, 131, 118, 112, 128, 136, 120, 107, 134, 122) medH0 <- 110

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

Wilcoxon signed rank testdata: 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

兩個獨(dú)立樣本

測試

Nj <- c(20, 30) DVa <- rnorm(Nj[1], mean= 95, sd=15) DVb <- rnorm(Nj[2], mean=100, sd=15) wIndDf <- data.frame(DV=c(DVa, DVb), IV=factor(rep(1:2, Nj), labels=LETTERS[1:2]))

查看每組中低于或高于組合數(shù)據(jù)中位數(shù)的個案數(shù)。

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

Exact Median Testdata: DV by IV (A, B) Z = 1.143, p-value = 0.3868 alternative hypothesis: true mu is not equal to 0

Wilcoxon秩和檢驗(yàn)(曼 - 惠特尼檢疫)

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

Wilcoxon rank sum testdata: 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 Testdata: 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 <- 20 DVpre <- rnorm(N, mean= 95, sd=15) DVpost <- rnorm(N, mean=100, sd=15) wDepDf <- data.frame(id=factor(rep(1:N, times=2)), DV=c(DVpre, DVpost), IV=factor(rep(0:1, each=N), labels=c("pre", "post")))

medH0 <- 0 DVdiff <- aggregate(DV ~ id, FUN=diff, data=wDepDf) (obs <- sum(DVdiff$DV < medH0))

[1] 7

(pLess <- pbinom(obs, N, 0.5))

[1] 0.1316

排名威爾科克森檢驗(yàn)

wilcoxsign_test(DV ~ IV | id, alternative="greater", distribution="exact", data=wDepDf)

Exact Wilcoxon-Signed-Rank Testdata: 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))

總結(jié)

以上是生活随笔為你收集整理的r语言 adf检验_r语言中如何进行两组独立样本秩和检验的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。