| final_svyglm | R Documentation |
Fits a survey-weighted logistic regression model (quasibinomial) using raw survey variables. Returns ORs, confidence intervals, p-values, and model discrimination statistics.
final_svyglm(
data,
dep_var,
covariates,
id_var,
strata_var,
weight_var,
family = "binomial",
level = 0.95,
interaction_terms = NULL
)
data |
A data frame containing the survey data. |
dep_var |
Character. Name of the binary outcome variable (0/1). |
covariates |
Character vector of covariate names to adjust for. |
id_var |
Character. Name of the primary sampling unit variable. |
strata_var |
Character. Name of the stratification variable. |
weight_var |
Character. Name of the survey weight variable. |
family |
Character. Currently supports only |
level |
Numeric. Confidence level for intervals (default = 0.95). |
interaction_terms |
Optional character vector of interaction terms. |
A list containing:
model: Survey-weighted logistic regression model.
results_table: Odds ratios with confidence intervals and p-values.
AUC: Survey-weighted AUC (Somers' C).
data: Input data with predicted probabilities.
design: Survey design object.
set.seed(123)
n <- 100
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_simple<-final_svyglm(dat, dep_var="outcome", covariates=c("age","sex"),
id_var="psu", strata_var="strata", weight_var="weight")
fit_simple$OR_table
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.