library(survey) # Analysis of Complex Survey Samples
library(srvyr) # 'dplyr' inspired syntactic style
# complex survey design
design <- data %>% as_survey_design(ids = HOSP_NRD, weights = DISCWT, strata = NRD_STRATUM)
# create my survey-weighted GLM
fit_cost <- svyglm(Costs1 ~ 1,
design = design,
family = Gamma(link = "log"))
# predictive marginal means works
svypredmeans(fit_cost, ~group)
I can't figure out how to get the marginpred command to work without adjusting for anything. I just want a simple GLM.
It gives the following error: "Error in eval(e[[2L]], where) : argument "adjustfor" is missing, with no default".
# Standardised predictions (predictive margins) for regression models
marginpred(fit_cost,
predictat = data.frame(group = c("a", "b")))
I first read the help page for
?marginpred
and saw thatmarginpred
first does some adjustments and then hands off to thepredict
function. In the absence of a proper example I continued down to the examples on that page and then executed the `svyglm example and attempted my comment suggestion with apparently satisfactory results: