User Tools

Site Tools


r:chi-square_test

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
r:chi-square_test [2018/12/03 16:57] hkimscilr:chi-square_test [2025/12/02 23:00] (current) hkimscil
Line 1: Line 1:
-====== chi square test ====== +====== chi square test eg. 1 ======
-<code> +
-# read the data +
-df <- read.csv("https://goo.gl/j6lRXD"+
-# summarize data to table  +
-table(df$treatment, df$improvement) +
-              +
-              improved not-improved +
-  not-treated       26           29 +
-  treated           35           15+
  
-</code>+<tabbed> 
 +  * :r:chi-square test:code01 
 +  * *:r:chi-square test:output01 
 +</tabbed>
  
-<code># Chi-sq test +====== chi square test eg. 2 ====== 
-chi <chisq.test(df$treatment, df$improvement, correct=FALSE) +<tabbed
-chi   +  * :r:chi-square test:code02 
- Pearson's Chi-squared test+  * *:r:chi-square test:output02 
 +</tabbed>
  
-data:  df$treatment and df$improvement +====== chi square test eg3 ====== 
-X-squared 5.5569, df 1, p-value 0.01841 +<tabbed> 
-</code>+  * :r:chi-square test:code03 
 +  * *:r:chi-square test:output03 
 +</tabbed> 
 +{{tag> statistics r "chi-square test"}}
  
-<code>> summary(chi) 
-          Length Class  Mode      
-statistic 1      -none- numeric   
-parameter 1      -none- numeric   
-p.value        -none- numeric   
-method    1      -none- character 
-data.name 1      -none- character 
-observed  4      table  numeric   
-expected  4      -none- numeric   
-residuals 4      table  numeric   
-stdres    4      table  numeric   
-> </code> 
- 
-<code> round(chi$expected,2) 
-             df$improvement 
-df$treatment  improved not-improved 
-  not-treated    31.95        23.05 
-  treated        29.05        20.95 
- 
-round(chi$observed,2) 
-             df$improvement 
-df$treatment  improved not-improved 
-  not-treated       26           29 
-  treated           35           15 
-</code> 
- 
-<WRAP box help> 
-Do chi-square test as explained in [[:chi-square test]] explanation.  
-</WRAP> 
r/chi-square_test.1543856242.txt.gz · Last modified: by hkimscil

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki