Last active
April 15, 2021 18:22
-
-
Save bschneidr/088948f83812aea0ec03d8af711a650d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(survey) | |
library(svyVGAM) | |
# Load some example data | |
data(nhanes_sxq) | |
# Save it to a file so it can also be used by Stata | |
haven::write_dta(data = nhanes_sxq, | |
path = "nhanes_sxq.dta") | |
# Set up survey design object | |
svy_design <- svydesign(data = nhanes_sxq, | |
id = ~SDMVPSU, | |
strat = ~SDMVSTRA, nest = TRUE, | |
weights = ~WTINT2YR) | |
# Fit the model and display a summary | |
model_fit <- svy_vglm(malepartners ~ RIDAGEYR + DMDEDUC, | |
family = zinegbinomial(), | |
design = svy_design, crit = "coef") | |
summary(model_fit) | |
confint(model_fit) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use "C:\Users\benja\OneDrive\Documents\Academics\JPSM\2021 - Spring\SURV701 - Analysis of Complex Sample Data\Interactive-Checks\nhanes_sxq.dta" | |
svyset SDMVPSU [pw = WTINT2YR], strata(SDMVSTRA) | |
svy: zinb malepartners RIDAGEYR DMDEDUC, inflate(RIDAGEYR DMDEDUC) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment