R Under development (unstable) (2023-08-08 r84908 ucrt) -- "Unsuffered Consequences" Copyright (C) 2023 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. > cat("# factors test\n") # factors test > library("qgcomp") > library("survival") > library('pscl') Classes and Methods for R developed in the Political Science Computational Laboratory Department of Political Science Stanford University Simon Jackman hurdle and zeroinfl functions by Achim Zeileis > # are results at a given seed numerically stable across versions? > set.seed(50) > N=50 > dat <- data.frame(time=(tmg <- pmin(.1,rweibull(N, 10, 0.1))), + d=1.0*(tmg<0.1), x1=runif(N), x2=runif(N), z=runif(N), + z2 = as.factor(sample(c(1,2,3), size=N, replace=TRUE))) > expnms=paste0("x", 1:2) > > > > ##### binomial > set.seed(123123) > f0 = d ~ x1 + x2 + z2 > obj0a <- qgcomp.noboot(f0, expnms = expnms, data = dat, family=binomial()) > print(obj0a) Scaled effect size (positive direction, sum of positive coefficients = 0.31) x2 1 Scaled effect size (negative direction, sum of negative coefficients = -0.0979) x1 1 Mixture log(OR) (Delta method CI): Estimate Std. Error Lower CI Upper CI Z value Pr(>|z|) (Intercept) 0.57991 0.83304 -1.0528 2.21264 0.6961 0.4863 psi1 0.21192 0.39481 -0.5619 0.98574 0.5368 0.5914 > pointwisebound.noboot(obj0a) quantile quantile.midpoint hx or se.lnor ll.or ul.or 1 0 0.125 0.5799074 1.000000 0.0000000 1.0000000 1.000000 2 1 0.375 0.7918281 1.236050 0.3948143 0.5701242 2.679801 3 2 0.625 1.0037488 1.527819 0.7896285 0.3250416 7.181332 4 3 0.875 1.2156695 1.888461 1.1844428 0.1853141 19.244538 > > ##### survival > f1 = survival::Surv(time, d)~ x1 + x2 + z2 > obj0b <- qgcomp.cox.noboot(f1, expnms = expnms, data = dat) > print(obj0b) Scaled effect size (positive direction, sum of positive coefficients = 0.176) x2 1 Scaled effect size (negative direction, sum of negative coefficients = -0.0998) x1 1 Mixture log(hazard ratio) (Delta method CI): Estimate Std. Error Lower CI Upper CI Z value Pr(>|z|) psi1 0.076072 0.245428 -0.40496 0.5571 0.31 0.7566 > > res = try(pointwisebound.noboot(obj0b), silent=TRUE) > stopifnot(class(res)=="try-error") > > ##### zi > f2 = d ~ x1 + x2 + z2 | x1 + x2 + z2 > pp = pscl::zeroinfl(formula = f2, data = dat) > obj0c <- qgcomp.zi.noboot(f2, expnms = expnms, data = dat) Warning messages: 1: In Ops.factor(x1 + x2, z2) : '+' not meaningful for factors 2: In Ops.factor(x1 + x2, z2) : '+' not meaningful for factors > res = try(pointwisebound.noboot(obj0c), silent=TRUE) > stopifnot(class(res)=="try-error") > > > proc.time() user system elapsed 3.04 0.39 3.42