install.packages(“qgcomp”) #### developmental release (not always guaranteed to be stable) devtools::install_github(“alexpkeil1/qgcompint”, build_vignettes=TRUE)
vignette(“qgcompint-vignette”, package=“qgcompint”)
library(qgcomp)
library(qgcompint)
set.seed(40)
dat <- data.frame(y=runif (50),
x1=runif (50),
x2=runif (50),
z=rbinom(50, 1, 0.5),
r=rbinom(50, 1, 0.5))
# quantile g-computation without effect measure modification
qfit <- qgcomp.glm.noboot(f=y ~ z + x1 + x2,
expnms = c('x1', 'x2'),
data=dat, q=2,
family=gaussian())
# no output given here
# with effect measure modification by Z
(qfitemm <- qgcomp.emm.glm.noboot(f=y ~ z + x1 + x2,
emmvar="z",
expnms = c('x1', 'x2'),
data=dat, q=2,
family=gaussian()))
> ## Qgcomp weights/partial effects at z = 0
> Scaled effect size (positive direction, sum of positive coefficients = 0)
> None
> Scaled effect size (negative direction, sum of negative coefficients = -0.278)
> x2 x1
> 0.662 0.338
> ## Qgcomp weights/partial effects at z = 1
> Scaled effect size (positive direction, sum of positive effects = 0.0028)
> x1
> 1
> Scaled effect size (negative direction, sum of negative effects = -0.0128)
> x2
> 1
> Mixture slope parameters (delta method CI):
> Estimate Std. Error Lower CI Upper CI t value Pr(>|t|)
> (Intercept) 0.58062 0.11142 0.36224 0.79900 5.2112 4.787e-06
> psi1 -0.27807 0.20757 -0.68490 0.12876 -1.3397 0.1872
> z -0.10410 0.15683 -0.41148 0.20329 -0.6637 0.5103
> z:mixture 0.26811 0.26854 -0.25822 0.79444 0.9984 0.3235
> Estimate (CI), z=1:
> -0.0099575 (-0.34389, 0.32398)
z
in this case)z=0
)
z=0
))z=1
)z=1
))z=1
)