View source: R/final_prog_svyglm.R
| final_prog_svyglm | R Documentation |
Fits a survey-weighted logistic regression model using stabilized prognostic score weights derived from a model predicting the outcome conditional on baseline covariates and excluding the exposure effect. The function supports design-based inference under complex survey sampling while adjusting for confounding through prognostic weighting
final_prog_svyglm(
data,
dep_var,
exposure,
covariates,
id_var,
strata_var,
weight_var,
outcome_covariates = NULL,
level = 0.95,
...
)
data |
Data frame |
dep_var |
Character; binary outcome |
exposure |
Character; exposure variable |
covariates |
Character vector; adjustment variables |
id_var |
Character; PSU |
strata_var |
Character; strata |
weight_var |
Character; survey weight |
outcome_covariates |
Character vector; optional covariates for final model |
level |
Numeric; CI level |
... |
Additional args to svyglm |
A list with:
prog_model: Prognostic svyglm.
final_model: Weighted outcome svyglm.
OR_table: Odds ratios with CI.
AUC: Weighted AUC.
data: Data with prognostic weights.
set.seed(123)
n <- 1000
dat <- data.frame(
psu = sample(1:10, n, replace = TRUE),
strata = sample(1:5, n, replace = TRUE),
weight = runif(n, 0.5, 2),
age = rnorm(n, 50, 10),
sex = factor(sample(c("Male", "Female"), n, replace = TRUE)),
exposure = rbinom(n, 1, 0.5)
)
dat$outcome <- rbinom(n, 1, plogis(-2 + 0.03*dat$age + 0.5*dat$exposure))
fit<-final_prog_svyglm(data = dat,
dep_var = "outcome",
exposure="exposure",
covariates = c("age", "sex"),
id_var = "psu",
strata_var = "strata",
weight_var = "weight",
level = 0.95
)
names(fit)
fit$OR_table
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.