Professional Documents
Culture Documents
#chi-square test
install.packages("vcd")
library(vcd)
#Chi-Square test
View(Arthritis)
mytable1<-xtabs(~Treatment+Improved,data=Arthritis)
mytable1
chisq.test(mytable1)
mytable2<-xtabs(~Improved+Sex,data=Arthritis)
mytable2
chisq.test(mytable2)
OUTPUT
#Chi-Square test
> View(Arthritis)
> mytable1<-xtabs(~Treatment+Improved,data=Arthritis)
> mytable1
Improved
Placebo 29 7 7
Treated 13 7 21
> chisq.test(mytable1)
data: mytable1
> mytable2
Sex
None 25 17
Some 12 2
Marked 22 6
CORRELATION
# Correlation
#Correlation coefficients are used to describe relationships among quantitative variables. The sign ±
indicates the direction of the relationship (positive or inverse) and
#the magnitude indicates the strength of the relationship (ranging from 0 for no relationship to 1 for a
perfectly predictable relationship)
#The Pearson product moment correlation assesses the degree of linear relationship
#Spearman's Rank Order correlation coefficient assesses the degree of relationship between two rank-
ordered variables.
#cor(x,use=,method=)
states<-state.x77[,1:6]
View(states)
cor(states)
cor(states,method="spearman")
cor(states,method="kendall")
x <- states[,c("Population", "Income", "Illiteracy", "HS Grad")]
cor(x,y)
Output
# Correlation
> #Correlation coefficients are used to describe relationships among quantitative variables. The sign ±
indicates the direction of the .... [TRUNCATED]
> View(states)
> cor(states)
> cor(states,method="spearman")
> cor(states,method="kendall")
> cor(x,y)