8000 Error when using PLN regression with univariate Y · Issue #103 · PLN-team/PLNmodels · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Error when using PLN regression with univariate Y #103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
julieaubert opened this issue Aug 23, 2023 · 1 comment · Fixed by #104
Closed

Error when using PLN regression with univariate Y #103

julieaubert opened this issue Aug 23, 2023 · 1 comment · Fixed by #104

Comments

@julieaubert
Copy link
Member

Problem
Error when using PLNmodels::PLN with univariate input

library(PLNmodels)
#> This is packages 'PLNmodels' version 1.0.3
#> Use future::plan(multicore/multisession) to speed up PLNPCA/PLNmixture/stability_selection.
data(trichoptera)
trichoptera <- PLNmodels::prepare_data(trichoptera$Abundance, trichoptera$Covariate)

# Bivariate analysis
biPLN <- PLNmodels::PLN(Abundance[,1:2] ~ 1, data = trichoptera)
#> 
#>  Initialization...
#>  Adjusting a full covariance PLN model with nlopt optimizer
#>  Post-treatments...
#>  DONE!

# Univariate analysis
uniPLN <- PLNmodels::PLN(Abundance[,1] ~ 1, data = trichoptera)
#> Error in if (ncol(Y) == 1 & is.null(colnames(Y))) colnames(Y) <- "Y": l'argument est de longueur nulle

Created on 2023-08-23 with reprex v2.0.2

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.3.1 (2023-06-16)
#>  os       Ubuntu 22.04.2 LTS
#>  system   x86_64, linux-gnu
#>  ui       X11
#>  language (EN)
#>  collate  fr_FR.UTF-8
#>  ctype    fr_FR.UTF-8
#>  tz       Europe/Paris
#>  date     2023-08-23
#>  pandoc   3.1.1 @ /usr/lib/rstudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package      * version date (UTC) lib source
#>  bit            4.0.5   2022-11-15 [1] CRAN (R 4.3.1)
#>  bit64          4.0.5   2020-08-30 [1] CRAN (R 4.3.1)
#>  callr          3.7.3   2022-11-02 [1] CRAN (R 4.3.1)
#>  cli            3.6.1   2023-03-23 [1] CRAN (R 4.3.1)
#>  codetools      0.2-19  2023-02-01 [4] CRAN (R 4.2.2)
#>  colorspace     2.1-0   2023-01-23 [1] CRAN (R 4.3.1)
#>  coro           1.0.3   2022-07-19 [1] CRAN (R 4.3.1)
#>  corrplot       0.92    2021-11-18 [1] CRAN (R 4.3.1)
#>  digest         0.6.33  2023-07-07 [1] CRAN (R 4.3.1)
#>  dplyr          1.1.2   2023-04-20 [1] CRAN (R 4.3.1)
#>  evaluate       0.21    2023-05-05 [1] CRAN (R 4.3.1)
#>  fansi          1.0.4   2023-01-22 [1] CRAN (R 4.3.1)
#>  fastmap        1.1.1   2023-02-24 [1] CRAN (R 4.3.1)
#>  fs             1.6.3   2023-07-20 [1] CRAN (R 4.3.1)
#>  future         1.33.0  2023-07-01 [1] CRAN (R 4.3.1)
#>  future.apply   1.11.0  2023-05-21 [1] CRAN (R 4.3.1)
#>  generics       0.1.3   2022-07-05 [1] CRAN (R 4.3.1)
#>  ggplot2        3.4.3   2023-08-14 [1] CRAN (R 4.3.1)
#>  glassoFast     1.0.1   2023-08-21 [1] CRAN (R 4.3.1)
#>  globals        0.16.2  2022-11-21 [1] CRAN (R 4.3.1)
#>  glue           1.6.2   2022-02-24 [1] CRAN (R 4.3.1)
#>  gridExtra      2.3     2017-09-09 [1] CRAN (R 4.3.1)
#>  gtable         0.3.4   2023-08-21 [1] CRAN (R 4.3.1)
#>  htmltools      0.5.6   2023-08-10 [1] CRAN (R 4.3.1)
#>  igraph         1.5.1   2023-08-10 [1] CRAN (R 4.3.1)
#>  knitr          1.43    2023-05-25 [1] CRAN (R 4.3.1)
#>  lattice        0.21-8  2023-04-05 [4] CRAN (R 4.3.0)
#>  lifecycle      1.0.3   2022-10-07 [1] CRAN (R 4.3.1)
#>  listenv        0.9.0   2022-12-16 [1] CRAN (R 4.3.1)
#>  magrittr       2.0.3   2022-03-30 [1] CRAN (R 4.3.1)
#>  MASS           7.3-60  2023-05-04 [4] CRAN (R 4.3.1)
#>  Matrix         1.6-1   2023-08-14 [1] CRAN (R 4.3.1)
#>  munsell        0.5.0   2018-06-12 [1] CRAN (R 4.3.1)
#>  nloptr         2.0.3   2022-05-26 [1] CRAN (R 4.3.1)
#>  parallelly     1.36.0  2023-05-26 [1] CRAN (R 4.3.1)
#>  pillar         1.9.0   2023-03-22 [1] CRAN (R 4.3.1)
#>  pkgconfig      2.0.3   2019-09-22 [1] CRAN (R 4.3.1)
#>  PLNmodels    * 1.0.3   2023-07-01 [1] CRAN (R 4.3.1)
#>  processx       3.8.2   2023-06-30 [1] CRAN (R 4.3.1)
#>  ps             1.7.5   2023-04-18 [1] CRAN (R 4.3.1)
#>  purrr          1.0.2   2023-08-10 [1] CRAN (R 4.3.1)
#>  R.cache        0.16.0  2022-07-21 [1] CRAN (R 4.3.1)
#>  R.methodsS3    1.8.2   2022-06-13 [1] CRAN (R 4.3.1)
#>  R.oo           1.25.0  2022-06-12 [1] CRAN (R 4.3.1)
#>  R.utils        2.12.2  2022-11-11 [1] CRAN (R 4.3.1)
#>  R6             2.5.1   2021-08-19 [1] CRAN (R 4.3.1)
#>  Rcpp           1.0.11  2023-07-06 [1] CRAN (R 4.3.1)
#>  reprex         2.0.2   2022-08-17 [1] CRAN (R 4.3.1)
#>  rlang          1.1.1   2023-04-28 [1] CRAN (R 4.3.1)
#>  rmarkdown      2.24    2023-08-14 [1] CRAN (R 4.3.1)
#>  rstudioapi     0.15.0  2023-07-07 [1] CRAN (R 4.3.1)
#>  scales         1.2.1   2022-08-20 [1] CRAN (R 4.3.1)
#>  sessioninfo    1.2.2   2021-12-06 [1] CRAN (R 4.3.1)
#>  styler         1.10.1  2023-06-05 [1] CRAN (R 4.3.1)
#>  tibble         3.2.1   2023-03-20 [1] CRAN (R 4.3.1)
#>  tidyr          1.3.0   2023-01-24 [1] CRAN (R 4.3.1)
#>  tidyselect     1.2.0   2022-10-10 [1] CRAN (R 4.3.1)
#>  torch          0.11.0  2023-06-06 [1] CRAN (R 4.3.1)
#>  utf8           1.2.3   2023-01-31 [1] CRAN (R 4.3.1)
#>  vctrs          0.6.3   2023-06-14 [1] CRAN (R 4.3.1)
#>  withr          2.5.0   2022-03-03 [1] CRAN (R 4.3.1)
#>  xfun           0.40    2023-08-09 [1] CRAN (R 4.3.1)
#>  yaml           2.2.1   2020-02-01 [2] CRAN (R 4.0.2)
#> 
#>  [1] /home/jaubert/R/x86_64-pc-linux-gnu-library/4.3
#>  [2] /usr/local/lib/R/site-library
#>  [3] /usr/lib/R/site-library
#>  [4] /usr/lib/R/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────
@jchiquet
Copy link
Member

Try with drop = FALSE to keep the matrix formatting of of the counts:

library(PLNmodels)
data(trichoptera)
trichoptera <- PLNmodels::prepare_data(trichoptera$Abundance, trichoptera$Covariate)
# Univariate analysis
uniPLN <- PLNmodels::PLN(Abundance[,1, drop=FALSE] ~ 1, data = trichoptera)

Note that it cannot work when the left-hand side is a vector in the formula

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
0