Search code examples
rlogistic-regressionglm

Calculating marginal effects for a weighted logit model


I calculated a weighted logit model with the "survey" package.

 library(survey)

 Mod_design <- svrepdesign(variables = Data,
                    weights = weights,
                    repweights = REP_WGT,
                    type = "JKn",
                    scale = 1,       
                    rscales = 1)

 Mod <- svyglm(Education ~ 
                 Sex + Age + Edu_Parents, 
                 family = quasibinomial, design = Mod_design)

Now I would like to calculate marginal effects for this model. Without weights, I would usually use the logitmfx function of the mfx package. Unfortunately, it is not possible to calculate marginal effects for weighted models with this package and so far I couldn't find a way how I could handle this problem.

Is there a way how I could calculate marginal effects for weighted models?


Solution

  • You can obtain marginal effects from models estimated via svyglm from the R package survey using the following code:

    summary(margins(MODEL_NAME, variables = "VARIABLE_OF_INTEREST", design=YOUR_DESIGN))