통계 > 비모수 검정 > 쌍-표본 Wilcoxon test...

Statistics > Nonparametric tests > Paired-samples Wilcoxon test...

 

Windows 사례 (10 Pro)

depression 이라는 이름의 데이터셋을 만들자. first, second, change 라는 세개의 변수를 갖는다고 하자. change 변수는 second와 first의 차이를 사례 값으로 갖는다고 하자. 아래와 같을 것이다.

first <- c(1.83,  0.50,  1.62,  2.48, 1.68, 1.88, 1.55, 3.06, 1.30)
second <- c(0.878, 0.647, 0.598, 2.05, 1.06, 1.29, 1.06, 3.14, 1.29)
change <- second - first  # compute new variable 참조할 것
depression <- data.frame(cbind(first, second, change)) # 세개의 vector를 묶어 데이터프레임으로 전환

https://rcmdr.kr/54

 

2. Compute new variable...

새로운 변수 계산하기... Data > Manage variables in active data set > Compute new variable... 활성 데이터셋에 있는 변수들을 활용하여 새로운 변수를 생성하는 많은 방법이 있다. 은 일반적으로 수치형 사..

rcmdr.kr

Windows 사례 (10 Pro)

<선택기능> 창에 있는 기본 선택 사양을 그대로 사용해보자. <대립 가설>에서 '양쪽(측)'이 선택되어 있다. depression 데이터셋의 second 변수와 first 변수 사이에 순위 차이가 있는가를 살펴보는 것이라 할 수 있다.

Windows 사례 (10 Pro)

with(depression, median(second - first, na.rm=TRUE)) # median difference
with(depression, wilcox.test(second, first, alternative='two.sided', 
  paired=TRUE)) # 양측 검정
with(depression, wilcox.test(second, first, alternative='less', paired=TRUE))
                # 단측 검정 ( 차이 < 0 )

Windows 사례 (10 Pro)

<선택 기능> 창에서 <대립 가설>에 '차이 < 0'를 선택하자. second 변수의 사례 값이 first 변수의 사례 값보다 작아졌는지를 점검하는 것이다. (depression이 작아졌다는 것은 개선되었다는 의미로 해석될 수도 있다.)

Windows 사례 (10 Pro)
Windows 사례 (10 Pro)

'Statistics > Nonparametric tests' 카테고리의 다른 글

2. Single-sample Wilcoxon test...  (0) 2022.03.21
1. Two-sample Wilcoxon test...  (0) 2022.03.21
5. Friedman rank-sum test...  (0) 2022.03.20
4. Kruskal-Wallis test...  (0) 2022.03.09

통계 > 비모수 검정 > 일-표본 Wilcoxon 검정...

Statistics > Nonparametric tests > Single-sample Wilcoxon test...

Windows 사례 (10 Pro)

먼저 '통계 > 비모수 검정 > 쌍-표본 Wilcoxon 검정...'을 살펴보는 것을 추천한다. depression 이라는 데이터셋을 만들고, 변수 first, second, change를 만들었다. change는 second와 first의 차이에 관련 사례 값을 갖는다.

https://rcmdr.tistory.com/179

 

3. Paired-samples Wilcoxon test...

통계 > 비모수 검정 > 쌍-표본 Wilcoxon test... Statistics > Nonparametric tests > Paired-samples Wilcoxon test... depression 이라는 이름의 데이터셋을 만들자. first, second, change 라는 세개의 변수를..

rcmdr.kr

'통계 > 비모수 검정 > 일-표본 Wilcoxon 검정...'은 depression 데이터셋의 change 변수처럼 두 개 변수의 차이를 갖는 (또는 차이가 계산된) 변수를 기준값과 비교하여 차이 검정을 하는 기법이다. 때로는 특정 변수와 기준 값의 비교를 통하여 검정을 하기도 한다.

Windows 사례 (10 Pro)

데이터셋과 변수에 대한 의미적 판단이 깊은 경우 <대립 가설>의 선택을 다양하게 결정할 수 있다. 아래 화면에서 'mu < 0'은 change가 귀무(영) 가설, mu=0.0 일 때 depression 의 변화가 작아졌음을 확인하는 것으로 이해할 수 있다.

Windows 사례 (10 Pro)

with(depression, median(change, na.rm=TRUE))
with(depression, mean(change, na.rm=TRUE))
with(depression, wilcox.test(change, alternative='less', mu=0.0))

출력 창에 아래와 같이 검정의 통계적 정보가 제공된다:

'Statistics > Nonparametric tests' 카테고리의 다른 글

3. Paired-samples Wilcoxon test...  (0) 2022.03.21
1. Two-sample Wilcoxon test...  (0) 2022.03.21
5. Friedman rank-sum test...  (0) 2022.03.20
4. Kruskal-Wallis test...  (0) 2022.03.09

통계 > 비모수 검정 > 이-표본 Wilcoxon 검정...

Statistics > Nonparametric tests > Two-sample Wilcoxon test...

Windows 사례 (10 Pro)

'통계 > 비모수 검정 > 이-표본 Wilcoxon 검정...' 기능을 이용하기 위해서 데이터셋을 선택하고, 정비해보자. datasets 패키지에 있는 airquality 데이터셋을 선택하고, 그 안에 있는 변수 Month 사례 값들 중에서 5월, 8월에 해당하는 5, 8을 선택한 하위 데이터셋을 만들고, airquality.sub라 이름 붙이자. 그리고, 5, 8을 요인화 시켜서, May, August라고 수준을 만들자.

https://rcmdr.kr/100

 

airquality 데이터셋

datasets > airquality R이 시작될 때, datasets 패키지가 자동으로 호출된다. 따라서 R Commander를 실행할 때, datasets 패키지는 첨부 패키지화되어 메뉴창을 통해서 내부 데이터셋을 찾고 불러올 수 있다.

rcmdr.kr

data(airquality, package="datasets") # airquality 데이터셋 불러오기
airquality.sub <- subset(airquality, subset=Month %in% c(5, 8)) 
                                     # 5월, 8월만 포함하는 하위셋 만들기
summary(airquality.sub)
airquality.sub <- within(airquality.sub, {
  Month.f <- factor(Month, labels=c('May','August'))
})                                   # Month.f라는 요인형 변수 만들기

집단 변수인 Month.f는 두개의 수준을 갖고 있고, 이 두개의 수준을 기준으로 Ozone을 비교하는 것이다.

Windows 사례 (10 Pro)

<선택기능> 창에 있는 기본 설정을 우선 그대로 사용해보자. 향후 데이터셋과 변수에 대한 이해력이 높아지면, 다양한 선택을 할 수 있다.

Windows 사례 (10 Pro)

Tapply(Ozone ~ Month.f, median, na.action=na.omit, data=airquality.sub) 
  # medians by group
wilcox.test(Ozone ~ Month.f, alternative="two.sided", data=airquality.sub)

Windows 사례 (10 Pro)

'Statistics > Nonparametric tests' 카테고리의 다른 글

3. Paired-samples Wilcoxon test...  (0) 2022.03.21
2. Single-sample Wilcoxon test...  (0) 2022.03.21
5. Friedman rank-sum test...  (0) 2022.03.20
4. Kruskal-Wallis test...  (0) 2022.03.09

통계 > 비모수 검정 > Friedman 순위-합 검정...

Statistics > Nonparametric tests > Friedman rank-sum test...

Linux 사례 (MX 21)

<Friendman 순위-합 검정...> 기능은 두개 이상의 수치형 변수가 데이터셋에 포함되어 있을때 활성화된다. <Friedman 순위-합 검정...> 기능의 함수적 특징을 이해하기 위하여 먼저 아래와 같이 RoundingTimes라는 데이터셋을 만들어보자.

RoundingTimes <-
data.frame(matrix(c(5.40, 5.50, 5.55,
         5.85, 5.70, 5.75,
         5.20, 5.60, 5.50,
         5.55, 5.50, 5.40,
         5.90, 5.85, 5.70,
         5.45, 5.55, 5.60,
         5.40, 5.40, 5.35,
         5.45, 5.50, 5.35,
         5.25, 5.15, 5.00,
          5.85, 5.80, 5.70,
         5.25, 5.20, 5.10,
         5.65, 5.55, 5.45,
         5.60, 5.35, 5.45,
         5.05, 5.00, 4.95,
         5.50, 5.50, 5.40,
         5.45, 5.55, 5.50,
         5.55, 5.55, 5.35,
         5.45, 5.50, 5.55,
         5.50, 5.45, 5.25,
         5.65, 5.60, 5.40,
         5.70, 5.65, 5.55,
         6.30, 6.30, 6.25),
       nrow = 22,
       byrow = TRUE,
       dimnames = list(1 : 22,
                       c("Round Out", "Narrow Angle", "Wide Angle"))))
summary(RoundingTimes)     # RoundingTimes 데이터셋 보기

이 데이터셋을 만드는 이유는 friedman.test()라는 함수의 예제 연습에 포함되어있기 때문이다. RoundingTimes 데이터셋은 아래와 같은 내부 구성을 갖는다:

Linux 사례 (MX 21)

RoungdingTimes 라는 데이터셋을 만들고, 화면 맨 위에 있는 <Friedman 순위-합 검정...> 기능을 선택하면 추가적인 선택 메뉴 창으로 넘어간다. <Friedman 순위 합 검정> 창에서 <반복-측정 변수 (두개 이상 선택)>에서 세개의 변수를 모두 선택하고, 예(OK) 버튼을 누른다.

Linux 사례 (MX 21)

local({
  .Responses <- na.omit(with(RoundingTimes, cbind(Narrow.Angle, Round.Out, Wide.Angle)))
  cat("\nMedians:\n") 
  print(apply(.Responses, 2, median)) 
  friedman.test(.Responses)
})

Linux 사례 (MX 21)

help("friedman.test")     # Friedman 순위 합 검정 도움말 보기
example("friedman.test")  # Friedman 순위 합 검정 예제 연습하기

'Statistics > Nonparametric tests' 카테고리의 다른 글

3. Paired-samples Wilcoxon test...  (0) 2022.03.21
2. Single-sample Wilcoxon test...  (0) 2022.03.21
1. Two-sample Wilcoxon test...  (0) 2022.03.21
4. Kruskal-Wallis test...  (0) 2022.03.09

통계 > 비모수 검정 > Kruskal-Wallis 검정...
Statistics > Nonparametric tests > Kruskal-Wallis test...

Linux 사례 (MX 21)

carData 패키지에 있는 Friendly 데이터셋을 활용한다. https://rcmdr.tistory.com/153

Friendly 데이터셋

carData > Friendly data(Friendly, package="carData") help("Friendly")

rcmdr.kr

Linux 사례 (MX 21)
data(Friendly, package="carData")
Tapply(correct ~ condition, median, na.action=na.omit, data=Friendly) # medians by group
kruskal.test(correct ~ condition, data=Friendly)
Linux 사례 (MX 21)

'Statistics > Nonparametric tests' 카테고리의 다른 글

3. Paired-samples Wilcoxon test...  (0) 2022.03.21
2. Single-sample Wilcoxon test...  (0) 2022.03.21
1. Two-sample Wilcoxon test...  (0) 2022.03.21
5. Friedman rank-sum test...  (0) 2022.03.20

+ Recent posts