R Under development (unstable) (2025-03-11 r87944 ucrt) -- "Unsuffered Consequences" Copyright (C) 2025 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > # testing bugs > library(qgcomp) > library(qgcompint) > set.seed(23) > dat <- simdata_quantized_emm( + outcometype="logistic", + # sample size + n = 100, + # correlation between x1 and x2, x3, ... + corr=c(0.8, 0.6, 0.3, -0.3, -0.3, -0.3), + # model intercept + b0=-2, + # linear model coefficients for x1, x2, ... at referent level of interacting variable + mainterms=c(0.3, -0.1, 0.1, 0.0, 0.3, 0.1, 0.1), + # linear model coefficients for product terms between x1, x2, ... and interacting variable + prodterms = c(1.0, 0.0, 0.0, 0.0, 0.1, 0.1, 0.1), + # type of interacting variable + ztype = "categorical", + # number of levels of exposure + q = 4, + # residual variance of y + yscale = 2.0 + ) > > dat$zspace <- paste("cat", dat$z) > dat$zspace <- ifelse(dat$z==1, "cat1", dat$zspace) > > dat$zspace2 = as.factor(dat$zspace) > # testing with character > res = try(qfit1 <- qgcomp.emm.glm.noboot(y~x1+x2, + data = dat, + expnms = paste0("x", 1:2), + emmvar = "zspace", + q = 4)) Error in qgcomp.emm.glm.noboot(y ~ x1 + x2, data = dat, expnms = paste0("x", : Modifier must be of types: numeric, integer or factor (convert to one of these types to proceed) > > if (!inherits(res, "try-error")) + stop("Didn't catch character error") > > # testing with factor > qfit2 <- qgcomp.emm.glm.noboot(y~x1+x2, + data = dat, + expnms = paste0("x", 1:2), + emmvar = "zspace2", + q = 4) > > qfit2 ## Qgcomp weights/partial effects at zspace2 = cat 0 Scaled effect size (positive direction, sum of positive effects = 0.197) x1 1 Scaled effect size (negative direction, sum of negative effects = -0.102) x2 1 ## Mixture slope parameters (delta method CI): Estimate Std. Error Lower CI Upper CI t value Pr(>|t|) (Intercept) 0.0595640 0.1052333 -0.146690 0.26582 0.5660 0.5727594 psi1 0.0947067 0.0553977 -0.013871 0.20328 1.7096 0.0907146 zspace2cat.2 0.3820859 0.1525247 0.083143 0.68103 2.5051 0.0140018 zspace2cat.2:mixture 0.1663597 0.0835039 0.002695 0.33002 1.9922 0.0493092 zspace2cat1 0.6192143 0.1547481 0.315913 0.92252 4.0014 0.0001272 zspace2cat1:mixture -0.0024506 0.0828798 -0.164892 0.15999 -0.0296 0.9764757 > > # testing tibble (not included in package dependencies, so commenting out) > #library(tibble) > > #dat2 = as_tibble(dat) > > #qgcomp.emm.glm.noboot(y~x1+x2, > # data = dat2, > # expnms = paste0("x", 1:2), > # emmvar = "zspace", > # q = 4) > > > proc.time() user system elapsed 2.56 0.48 3.01