User Tools

Site Tools


r:chi-square_test:code01

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

r:chi-square_test:code01 [2025/12/02 22:38] – created hkimscilr:chi-square_test:code01 [2025/12/02 22:42] (current) hkimscil
Line 1: Line 1:
 <code> <code>
-install.packages("MASS")+install.packages("MASS")
 library(MASS)      library(MASS)     
  
Line 14: Line 14:
 e <- chisq$expected e <- chisq$expected
 o o
-round(e, 3+round(e, 2
-<- (e-o)/sqrt(e) +res <- (e-o)/sqrt(e) 
-r +round(res,2) 
-chisq.cal <- sum((e-o)^2/e)+chisq.cal <- sum(res^2)
 p.val <- pchisq(chisq.cal, df=2, lower.tail = F) p.val <- pchisq(chisq.cal, df=2, lower.tail = F)
 chisq.cal chisq.cal
Line 30: Line 30:
 legend("center", legend = rownames(wh.clap.tbl),  legend("center", legend = rownames(wh.clap.tbl), 
        fill = c("red", "lightgreen" ,"blue"))        fill = c("red", "lightgreen" ,"blue"))
 +
 +
 </code> </code>
r/chi-square_test/code01.txt · Last modified: by hkimscil

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki