46独立性检验函数47相关性分析函数48相关性检测函数

46独立性检验函数

独立性检验

1.卡方检验:chisq.test

2.Fisher检验:fi9sher.test

3Cochran-Mantel-Haenze检验:mantelhaen.test()

library(vcd)

Arthritis

x<-Arthritis

mytable<-table(x$Treatment,x$Improved)

chisq.test(mytable)

fisher.test(mytable)

mantelhaen.test(mytable)

47相关性分析函数

Pearcon,Spearman,Kendall相关系数

偏相关系数

多分格相关系数

多系列相关系数

state.x77

cor(state.x77)

cov:协方差,2个变量的总体误差

cov(state.x77)

x<-state.x77[,c(1,2,3,6)]

y<-state.x77[,c(4,5)]

cor(x,y)

48相关性检测函数

1.两个变量之间的相关性
cor.test(x, y, alternative = c("two.sided", "less", "greater"), method = c("pearson", "kendall", "spearman"),)
cor.test(state.x77[,3],state.x77[,5])
2.多个变量之间的检验
library(psych)
corr.test(state.x77)
3.t.test
library(MASS)
UScrime
t.test(Prob~So,data=UScrime)
posted @ 2021-10-30 21:41  ^_^Anne  阅读(208)  评论(0)    收藏  举报