SPSS로 McNemar Test를 하려고 하는데 힘들었다. Matrix로 실행하는 방법이 없는 것 같은데 못찾은 건지는 모르겠다. R이 새삼스럽게 고마워지는 순간이었다. R의 장점 중 하나는 p=0.000 이라는 표현 대신에 지수를 사용해서 작은 값을 표현해준다. :)
Data가 없이 표로만 자료가 주어지는 상황이라면 다음과 같은 방법으로 구할 수가 있다. Data 입력 순서와 보여지는 방식을 잘 보면 응용하기는 쉽다.
> drug <- matrix(c(55,9,43,77), nrow=2, dimnames=list("Before program"=c("No", "Yes"), "After program"=c("No", "Yes")));drug
After program
Before program No Yes
No 55 43
Yes 9 77
> mcnemar.test(drug)
McNemar's Chi-squared test with continuity correction
data: drug
McNemar's chi-squared = 20.9423, df = 1, p-value = 4.733e-06
Data가 없이 표로만 자료가 주어지는 상황이라면 다음과 같은 방법으로 구할 수가 있다. Data 입력 순서와 보여지는 방식을 잘 보면 응용하기는 쉽다.
> drug <- matrix(c(55,9,43,77), nrow=2, dimnames=list("Before program"=c("No", "Yes"), "After program"=c("No", "Yes")));drug
After program
Before program No Yes
No 55 43
Yes 9 77
> mcnemar.test(drug)
McNemar's Chi-squared test with continuity correction
data: drug
McNemar's chi-squared = 20.9423, df = 1, p-value = 4.733e-06
'공부해 봅시다 > R-Project' 카테고리의 다른 글
Heatmap 만들기 (0) | 2010.05.16 |
---|---|
Chip data 찾아보기.. (0) | 2010.05.05 |
Odds ratio (2) | 2009.10.06 |
평균치 비교 (0) | 2009.10.04 |
Excel 불러오기 (0) | 2009.10.01 |