# Fit models
## Unadjusted
modelUnmatch <- glm(formula = Y ~ factor(Tr), data = data,
family = quasipoisson())
## IPTW
modelIptw <- svyglm(formula = Y ~ factor(Tr), design = iptwData,
family = quasipoisson())
## MW
modelMw <- svyglm(formula = Y ~ factor(Tr), design = mwData,
family = quasipoisson())
# Return pairs of coef and vcov
library(sandwich)
U = list(coef = coef(modelUnmatch), vcov = sandwich(modelUnmatch))
Ip = list(coef = coef(modelIptw), vcov = vcov(modelIptw))
Mw = list(coef = coef(modelMw), vcov = vcov(modelMw))
# Unadjusted
U = list(coef = coef(modelUnmatch), vcov = sandwich(modelUnmatch))
## coefficient
coef = U$coef
coef[4] <- coef[3] - coef[2]
names(coef) <- c("Int","1v0","2v0","2v1")
coef
## varaince-covariance
vcov <- U$vcov
vars <- diag(vcov)
vars[4] <- vcov[2,2] + vcov[3,3] - 2 * vcov[2,3]
names(vars) <- names(coef)
## standard error
se <- sqrt(vars[-1])
## confidence interval
lower <- coef[-1] - 1.95996 * se
upper <- coef[-1] + 1.95996 * se
z <- coef[-1] / se
lstModelOut = list(coef = coef, vars = vars, lower = lower, upper = upper, z = z)
참고
Yoshida K, Hernández-Díaz S, Solomon DH, et al. Matching weights to simultaneously compare three treatment groups: comparison to three-way matching. Epidemiology. 2017;28(3):387-395. https://github.com/kaz-yos/mw
https://stat.ethz.ch/pipermail/r-help/2008-December/183272.html