r语言 - 如何对两个数据表执行Chi^2检验,其中x和y的长度不同



所以我有以下表格(这里简化):

这是Ost_data

tbody> <<tr>
Raumeinheit Langzeitarbeitslose
汉堡22
科隆45

Pearson's ChiSq检验是当这些行测量相同的东西时。听起来这里你的行只是在重复样本上测量一些数量,所以你应该使用t检验。

t.test(Ost_data$Langzeitarbeitslose, West_data$Langzeitarbeitslose)

你的变量最重要的方面是"(长期失业)不在于是否正态分布,而在于其规模水平。我假设它是一个二分变量(是或否)。

  • t检验需要间隔刻度
  • wilcoxon测试需要序数刻度
  • 卡方检验适用于标称数据(因此也适用于二分类)

如果两者都有,则每个城市的长期失业人数和非长期失业人数可以比较东部和西部失业的概率。

l_west <- absolute number of longtime-unemployed in the west
l_ost  <- absolute number of longtime-unemployed in the east
n_west <- absolut number of observed people (unemployed or not) in the west
n_ost  <- absolut number of observed people (unemployed or not) in the east
N      <- n_west + n_ost # absolut number of observations
chisq.test(c(l_west,l_ost),p=c(n_west/N, n_ost/N)) 
# this tests whether the relative frequency of unemployment in the east (l_ost / n_ost)
# differs from the equivalent rel. frequency in the west (l_west / n_west)
# while considering the absolut number of observeations in east and west

我知道Ost(东方),West(西方)和Langzeitarbeitslose(失业)这三个词。我知道汉堡和Köln在西方而不是在东方(因此它们不应该出现在你的"ost_data"中)。不知道这一点的人无法帮助你。——比;以后请记住这一点。

最好的,ajj

最新更新