Here,I made data
as follows:
data<-data.frame(alzheimer=c(1,1,0,1,0,0,1,0,0,0),
asthma=c(1,1,0,0,1,1,1,1,0,0),
points=c(0,1,3,5,3,2,1,2,1,5),
sex=c(1,1,0,0,0,0,1,1,1,0))
I want to know whether sex
affects alzheimer
or asthma
or points
.
So I was considering to do chi-square test for independence.
alzheimer
and asthma
are binary variables, so I think I can add all the numbers from sex
==1 and sex
==0 separately and make contingency tables to do chi-square tests.
For the variable points
, I don't know whether I can do chi-square test, because points
is an ordinal variable ranges from 0 to 5 with only integers.
To sum up, I want to do 3 tests.
- Are
sex
andalzheimer
independent ? - Are
sex
andasthma
independent? - Are
sex
andpoints
independnet?
Additionally, in my actual data
there are so many columns, so I need to know how to do many tests all in once and make it into a csv file. The csv file should include test statistics and p-values.