-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPolymodEstimates.Rmd
54 lines (43 loc) · 1.12 KB
/
PolymodEstimates.Rmd
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
---
title: "Estimates from Polymod Data"
output:
pdf_document: default
html_notebook: default
---
We need to estiamte the following parameters;
1) What proportion of contacts are within household?
```{r}
library(socialmixr)
library(dplyr)
library(modelr)
```
We want to do a really simple model of household size and the number of contacts that occur within the household.
```{r}
data(polymod)
```
```{r}
contacts = polymod$contacts
participants = polymod$participants
```
```{r}
# Join the participant data frame to the dataframe that stores contact data on the participant ID and filter to the United Kingdom
model_data = participants %>%
filter(country == "United Kingdom") %>%
left_join(contacts, by = "part_id") %>%
select(part_id, hh_size, cnt_home, frequency_multi)
```
By household size.
```{r}
summary = model_data %>%
group_by(hh_size) %>%
filter(!is.na(cnt_home)) %>%
summarize(prop_within_house = mean(cnt_home), n = n())
summary
```
By household.
```{r}
summary = model_data %>%
filter(!is.na(cnt_home)) %>%
summarize(prop_within_house = mean(cnt_home),mean = mean(frequency_multi), n = n())
summary
```