-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path02_survey_analysis.Rmd
55 lines (42 loc) · 990 Bytes
/
02_survey_analysis.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: "Survey Analysis"
date: "`r Sys.Date()`"
output:
rmdformats::downcute:
highlight: kate
editor_options:
chunk_output_type: console
---
```{r setup, include=FALSE}
## Global options
knitr::opts_chunk$set(cache = TRUE)
library(tidyverse)
library(survey)
```
# Import data
```{r}
ffi_total <- readRDS("01_data/processed/ffi_total.rds")
```
# Settings survey
```{r eval=FALSE}
ffi_total <- ffi_total %>%
mutate(
count = 1
)
design <- svydesign(
id = ~ ffi_is_health_facility_name + ffi_is_community + ffi_is_cod_household,
strata = ~ ffi_is_district,
weights = ~ ffi_weights_fixed,
nest = TRUE,
fpc = ~ ffi_N_hf + ffi_N_community + ffi_N_households,
data = ffi_total
)
summary(design)
```
```{r eval=FALSE}
svymean(~pv_historic, design)
svytotal(~count, design, deff = TRUE)
svyby(~count, ~ffi_is_district, design, svytotal)
svyby(~count, ~ffi_is_health_facility_name, design, svytotal)
svyby(~count, ~ffi_is_community, design, svytotal)
```