-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontingency table.r
58 lines (51 loc) · 1.7 KB
/
contingency table.r
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
##
## Supplementary table 3
##
source("init.r")
hh.all = hh.dyads %>%
left_join(hh %>% dplyr::select(Ego.HH=HH, Ego.zhubo1=zhubo1), by="Ego.HH") %>%
left_join(hh %>% dplyr::select(Alter.HH=HH, Alter.zhubo1=zhubo1), by="Alter.HH")
####################################################################################
## Witch stats
##
#hh = unique(subset(hh.all, select=c(Ego.HH, Ego.zhubo1, Ego.VillageID)))
table(hh$zhubo1) # no. witch houses with Mosuo heads
num.witch.hh = nrow(subset(hh, zhubo1==1))
num.non_witch.hh = nrow(subset(hh, zhubo1==0))
##
## farm help
##
# how many witch houses (and non-witch) helped other witch houses (and non-witch)?
(witch.help = ftable(xtabs(~ Ego.zhubo1 + Alter.zhubo1,
data = subset(hh.all, Ego.HH != Alter.HH & HelpObserved > 0))))
# chi square on farm help
help.chi = chisq.test(witch.help)
help.chi$observed
help.chi$expected
##
## gifts
##
(witch.gifts = ftable(xtabs(~ Ego.zhubo1 + Alter.zhubo1,
data = subset(hh.all, Ego.HH != Alter.HH & TotalGifts.ind > 0))))
# chi square on gifts
gifts.chi = chisq.test(witch.gifts)
gifts.chi$observed
gifts.chi$expected
##
## partners
##
(witch.partners = ftable(xtabs(~ Ego.zhubo1 + Alter.zhubo1,
data = subset(hh.all, Ego.HH != Alter.HH & AnySpousesInAlter > 0))))
# chi square on partners
partners.chi = chisq.test(witch.partners)
partners.chi$observed
partners.chi$expected
##
## children
##
(witch.kids = ftable(xtabs(~ Ego.zhubo1 + Alter.zhubo1,
data = subset(hh.all, Ego.HH != Alter.HH & TotalChildrenInAlter > 0))))
# chi square on kids
kids.chi = chisq.test(witch.kids)
kids.chi$observed
round(kids.chi$expected, 1)