Built using Zelig version r packageVersion("Zelig")

knitr::opts_knit$set(
    stop_on_error = 2L
)
knitr::opts_chunk$set(
    fig.height = 11,
    fig.width = 7,
    eval = TRUE
)

options(cite = FALSE)

From Zelig version 5.1-2 it's possible to estiamate a limited range of models with functions other than zelig and pass them to setx.

Example

For example, you may want to estimate a model with survey weights using the surveyglm function from the survey package. This would allow you to can take full advantage of the options that the package has for model estimation and post-estimation. You may then want to simulate and plot quantities of interest from your fitted model. To do, this use the following code:

# Load packages and data
library(zeligverse)
library(survey)
library(dplyr)
data(api)

# Fit model with surveyglm
dstrat <- svydesign(id = ~1, strata = ~stype, weights = ~pw, data = apistrat,
                    fpc = ~fpc)
m1 <- svyglm(api00 ~ ell + meals + mobility, design = dstrat)

# Set fitted values, simulate quantities of interest, & plot with Zelig
m1 %>% setx() %>% sim() %>% plot()

Supported model types

Currently, the following model types can be passed directly to setx without a need to be estimated by Zelig:

knitr::kable(model_lookup_df)


IQSS/Zelig documentation built on Dec. 11, 2023, 1:51 a.m.