<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="FeedCreator 1.8" -->
<?xml-stylesheet href="http://www.commres.net/lib/exe/css.php?s=feed" type="text/css"?>
<rdf:RDF
    xmlns="http://purl.org/rss/1.0/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
    xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel rdf:about="http://www.commres.net/feed.php">
        <title>COMMunication&lt;br /&gt;RESearch.NET - r:chi-square_test</title>
        <description></description>
        <link>http://www.commres.net/</link>
        <image rdf:resource="http://www.commres.net/_media/wiki/logo.png" />
       <dc:date>2026-05-01T07:33:21+00:00</dc:date>
        <items>
            <rdf:Seq>
                <rdf:li rdf:resource="http://www.commres.net/r/chi-square_test/code01?rev=1764715346&amp;do=diff"/>
                <rdf:li rdf:resource="http://www.commres.net/r/chi-square_test/code02?rev=1764715690&amp;do=diff"/>
                <rdf:li rdf:resource="http://www.commres.net/r/chi-square_test/code03?rev=1764715775&amp;do=diff"/>
                <rdf:li rdf:resource="http://www.commres.net/r/chi-square_test/output01?rev=1764715315&amp;do=diff"/>
                <rdf:li rdf:resource="http://www.commres.net/r/chi-square_test/output02?rev=1764715676&amp;do=diff"/>
                <rdf:li rdf:resource="http://www.commres.net/r/chi-square_test/output03?rev=1764966213&amp;do=diff"/>
            </rdf:Seq>
        </items>
    </channel>
    <image rdf:about="http://www.commres.net/_media/wiki/logo.png">
        <title>COMMunication<br />RESearch.NET</title>
        <link>http://www.commres.net/</link>
        <url>http://www.commres.net/_media/wiki/logo.png</url>
    </image>
    <item rdf:about="http://www.commres.net/r/chi-square_test/code01?rev=1764715346&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-12-02T22:42:26+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>code01</title>
        <link>http://www.commres.net/r/chi-square_test/code01?rev=1764715346&amp;do=diff</link>
        <description># install.packages(&quot;MASS&quot;)
library(MASS)     

print(str(survey))
??MASS::survevy

wh.clap = data.frame(survey$Clap,survey$W.Hnd)
wh.clap.tbl = table(survey$Clap,survey$W.Hnd) 
wh.clap.tbl
chisq &lt;- chisq.test(wh.clap.tbl)
chisq
o &lt;- chisq$observed
e &lt;- chisq$expected
o
round(e, 2)
res &lt;- (e-o)/sqrt(e)
round(res,2)
chisq.cal &lt;- sum(res^2)
p.val &lt;- pchisq(chisq.cal, df=2, lower.tail = F)
chisq.cal
p.val
chisq

barplot(wh.clap.tbl, beside = TRUE, 
        col = c(&quot;red&quot;, &quot;lightgreen&quot;, &quot;blue&quot;),
     …</description>
    </item>
    <item rdf:about="http://www.commres.net/r/chi-square_test/code02?rev=1764715690&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-12-02T22:48:10+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>code02</title>
        <link>http://www.commres.net/r/chi-square_test/code02?rev=1764715690&amp;do=diff</link>
        <description>####################
file_path &lt;- &quot;https://www.sthda.com/sthda/RDoc/data/housetasks.txt&quot;
housetasks &lt;- read.delim(file_path, row.names = 1)
housetasks

chisq &lt;- chisq.test(housetasks)
chisq

o &lt;- chisq$observed
e &lt;- chisq$expected
o
round(e,2)
cs.cal &lt;- sum((e-o)^2/e)
cs.cal
dim(housetasks)
dim(housetasks)-1
pchisq(cs.cal, 12*3, lower.tail = F)
chisq</description>
    </item>
    <item rdf:about="http://www.commres.net/r/chi-square_test/code03?rev=1764715775&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-12-02T22:49:35+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>code03</title>
        <link>http://www.commres.net/r/chi-square_test/code03?rev=1764715775&amp;do=diff</link>
        <description># or the below works also
chisq &lt;- chisq.test(df$treatment, df$improvement, correct=F)
chisq

o &lt;- chisq$observed
e &lt;- chisq$expected
o
round(e,2)
r &lt;- (e-o)/sqrt(e) # this is called residuals
round(r, 3)
round(chisq$residuals, 3)

cs.tmp &lt;- sum(chisq$residuals^2)
cs.tmp
cs.cal &lt;- sum((e-o)^2/e)
pchisq(cs.cal, 1,lower.tail = F)
cs.cal
chisq

library(corrplot)
corrplot(chisq$residuals, is.cor = FALSE)

contrib &lt;- 100*chisq$residuals^2/chisq$statistic
round(contrib, 3)

# Visualize the contributio…</description>
    </item>
    <item rdf:about="http://www.commres.net/r/chi-square_test/output01?rev=1764715315&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-12-02T22:41:55+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>output01</title>
        <link>http://www.commres.net/r/chi-square_test/output01?rev=1764715315&amp;do=diff</link>
        <description>&gt; # install.packages(&quot;MASS&quot;)
&gt; library(MASS)     
&gt; 
&gt; print(str(survey))
&#039;data.frame&#039;:	237 obs. of  12 variables:
 $ Sex   : Factor w/ 2 levels &quot;Female&quot;,&quot;Male&quot;: 1 2 2 2 2 1 2 1 2 2 ...
 $ Wr.Hnd: num  18.5 19.5 18 18.8 20 18 17.7 17 20 18.5 ...
 $ NW.Hnd: num  18 20.5 13.3 18.9 20 17.7 17.7 17.3 19.5 18.5 ...
 $ W.Hnd : Factor w/ 2 levels &quot;Left&quot;,&quot;Right&quot;: 2 1 2 2 2 2 2 2 2 2 ...
 $ Fold  : Factor w/ 3 levels &quot;L on R&quot;,&quot;Neither&quot;,..: 3 3 1 3 2 1 1 3 3 3 ...
 $ Pulse : int  92 104 87 NA 35 64 83 74 …</description>
    </item>
    <item rdf:about="http://www.commres.net/r/chi-square_test/output02?rev=1764715676&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-12-02T22:47:56+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>output02</title>
        <link>http://www.commres.net/r/chi-square_test/output02?rev=1764715676&amp;do=diff</link>
        <description>&gt; ####################
&gt; file_path &lt;- &quot;https://www.sthda.com/sthda/RDoc/data/housetasks.txt&quot;
&gt; housetasks &lt;- read.delim(file_path, row.names = 1)
&gt; housetasks
           Wife Alternating Husband Jointly
Laundry     156          14       2       4
Main_meal   124          20       5       4
Dinner       77          11       7      13
Breakfeast   82          36      15       7
Tidying      53          11       1      57
Dishes       32          24       4      53
Shopping     33          23      …</description>
    </item>
    <item rdf:about="http://www.commres.net/r/chi-square_test/output03?rev=1764966213&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2025-12-05T20:23:33+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>output03</title>
        <link>http://www.commres.net/r/chi-square_test/output03?rev=1764966213&amp;do=diff</link>
        <description>&gt; 
&gt; #Author DataFlair
&gt; df &lt;- read.csv(&quot;https://goo.gl/j6lRXD&quot;)  #Reading CSV
&gt; head(df)
  id   treatment  improvement
1  1     treated     improved
2  2     treated     improved
3  3 not-treated     improved
4  4     treated     improved
5  5     treated not-improved
6  6     treated not-improved
&gt; tail(df)
     id   treatment  improvement
100 100 not-treated     improved
101 101     treated     improved
102 102     treated     improved
103 103 not-treated not-improved
104 104     treated     …</description>
    </item>
</rdf:RDF>
