Gerrit Eichner
2019-Sep-04 13:24 UTC
[R] [effects] allEffects does not accept integer value for xlevels
Dear list, citing from allEffects' help page (of package effects 4.1-2): "If xlevels=n is an integer, then each numeric predictor is represented by n equally spaced values rounded to 'nice' numbers." However, adapting the first example from allEffects' help page throws an an error: mod.cowles <- glm(volunteer ~ sex + neuroticism*extraversion, data=Cowles, family=binomial) allEffects(mod.cowles, xlevels=5) Error in xlevels[[name]] : subscript out of bounds It appears to me that the cause is buried in effects:::Analyze.model in or close to the the lines if (is.numeric(xlevels) & length(xlevels) == 1L) { levs <- xlevels for (name in focal.predictors) xlevels[[name]] <- levs } where xlevels -- while not being a list in this case -- is subscripted by xlevels[[name]]. Is anyone aware of a workaround (without having to specify all numeric predictors of the used model explicitly in a list and giving it to xlevels when calling allEffects), and without having to write my own Analyze.model function? ;-) Thx in advance and best regards -- Gerrit PS: sessionInfo() R version 3.6.1 (2019-07-05) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 18362) Matrix products: default Random number generation: RNG: Mersenne-Twister Normal: Inversion Sample: Rounding locale: [1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 [3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C [5] LC_TIME=German_Germany.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] effects_4.1-2 carData_3.0-2 loaded via a namespace (and not attached): [1] Rcpp_1.0.2 lattice_0.20-38 MASS_7.3-51.4 grid_3.6.1 [5] DBI_1.0.0 nlme_3.1-141 survey_3.36 estimability_1.3 [9] minqa_1.2.4 nloptr_1.2.1 Matrix_1.2-17 boot_1.3-23 [13] splines_3.6.1 lme4_1.1-21.9001 survival_2.44-1.1 compiler_3.6.1 [17] colorspace_1.4-1 mitools_2.4 nnet_7.3-12 --------------------------------------------------------------------- Dr. Gerrit Eichner Mathematical Institute, Room 212 gerrit.eichner at math.uni-giessen.de Justus-Liebig-University Giessen Tel: +49-(0)641-99-32104 Arndtstr. 2, 35392 Giessen, Germany http://www.uni-giessen.de/eichner