Open topepo opened 6 years ago
I think that there may be some matrix dimension dropping within the predict method. It usually gives a data frame back but drops to a numeric vector when a single data point is predicted:
predict
library(sparsediscrim) random <- t(matrix(rexp(20000, rate=.1), ncol=20)) colnames(random) <- paste0("x", 1:ncol(random)) response <- factor(rep(c('a','b'),10)) mod <- hdrda(random, response, gamma = 0, lambda = 0) predict(mod, random[1:2,])$posterior predict(mod, random[1,,drop = FALSE])$posterior
> sessionInfo() R version 3.5.0 (2018-04-23) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: macOS High Sierra 10.13.6 Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods [7] base other attached packages: [1] sparsediscrim_0.2.4 loaded via a namespace (and not attached): [1] Rcpp_0.12.18 rstudioapi_0.7 bindr_0.1.1 [4] magrittr_1.5 tidyselect_0.2.4 munsell_0.5.0 [7] colorspace_1.3-2 R6_2.2.2 rlang_0.2.1.9000 [10] plyr_1.8.4 dplyr_0.7.6 tools_3.5.0 [13] grid_3.5.0 gtable_0.2.0 corpcor_1.6.9 [16] yaml_2.2.0 lazyeval_0.2.1 assertthat_0.2.0 [19] tibble_1.4.2 crayon_1.3.4 bindrcpp_0.2.2 [22] bdsmatrix_1.3-3 purrr_0.2.5 ggplot2_3.0.0 [25] glue_1.3.0 compiler_3.5.0 pillar_1.3.0 [28] scales_1.0.0 mvtnorm_1.0-7 pkgconfig_2.0.1 ``
I think that there may be some matrix dimension dropping within the
predict
method. It usually gives a data frame back but drops to a numeric vector when a single data point is predicted: