Skip to content
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

mle and semLme not fully supported yet? #283

Open
IndrajeetPatil opened this issue Aug 16, 2020 · 1 comment
Open

mle and semLme not fully supported yet? #283

IndrajeetPatil opened this issue Aug 16, 2020 · 1 comment
Labels
Enhancement 💥 Implemented features can be improved or revised

Comments

@IndrajeetPatil
Copy link
Member

semLme

# setup
set.seed(123)
library(smicd)

# Load and prepare data
data <- Exam
classes <- c(1, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.7, 8.5, Inf)
data$examsc.class <- cut(data$examsc, classes)

# run model with random intercept and default settings
model1 <-
  semLme(
    formula = examsc.class ~ standLRT + schavg + (1 | school),
    data = data,
    classes = classes
  )
#> Warning: 'r.squaredGLMM' now calculates a revised statistic. See the help page.

# summary
summary(model1)
#> Call:
#> semLme(formula = examsc.class ~ standLRT + schavg + (1 | school), 
#>     data = data, classes = classes)
#> 
#> Random effects:
#>     Groups        Name   Variance  Std.Dev.
#> 1   school (Intercept) 0.07661185 0.2767884
#> 2 Residual             0.58815835 0.7669148
#> 
#> Fixed effects:
#>              Estimate
#> (Intercept) 5.0138425
#> standLRT    0.5594550
#> schavg      0.3692529
#> 
#> Marginal R-squared:  0.3534 Conditional R-squared:  0.4279
#> 
#> Variable examsc.class is divided into 9 intervals.

# parameters
parameters::model_parameters(model1)
#> Warning: Model has no standard errors. Please fit model again with bootstrapped
#> standard errors.
#> Warning: Model has no standard errors. Please fit model again with bootstrapped
#> standard errors.
#> Error in `$<-.data.frame`(`*tmp*`, "CI", value = 95): replacement has 1 row, data has 0

mle

# avoid printing to unwarranted accuracy
od <- options(digits = 5)

# simulated EC50 experiment with count data
x <- 0:10
y <- c(26, 17, 13, 12, 20, 5, 9, 8, 5, 4, 8)

# easy one-dimensional MLE:
nLL <- function(lambda) -sum(stats::dpois(y, lambda, log = TRUE))
fit0 <- stats4::mle(nLL, start = list(lambda = 5), nobs = NROW(y))

# parameters
parameters::model_parameters(fit0)
#> Error in do.call(cbind, x@data): no slot of name "data" for this object of class "mle"

Created on 2020-08-16 by the reprex package (v0.3.0)

Session info
devtools::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 3.6.3 (2020-02-29)
#>  os       macOS Mojave 10.14.6        
#>  system   x86_64, darwin15.6.0        
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_US.UTF-8                 
#>  ctype    en_US.UTF-8                 
#>  tz       Europe/Berlin               
#>  date     2020-08-16                  
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package        * version  date       lib source                               
#>  assertthat       0.2.1    2019-03-21 [1] CRAN (R 3.6.0)                       
#>  backports        1.1.8    2020-06-17 [1] CRAN (R 3.6.2)                       
#>  base64enc        0.1-3    2015-07-28 [1] CRAN (R 3.6.0)                       
#>  bayestestR       0.7.2.1  2020-08-15 [1] Github (easystats/bayestestR@1ffb88f)
#>  boot             1.3-25   2020-04-26 [1] CRAN (R 3.6.2)                       
#>  broom            0.7.0    2020-07-09 [1] CRAN (R 3.6.3)                       
#>  callr            3.4.3    2020-03-28 [1] CRAN (R 3.6.2)                       
#>  checkmate        2.0.0    2020-02-06 [1] CRAN (R 3.6.2)                       
#>  cli              2.0.2    2020-02-28 [1] CRAN (R 3.6.0)                       
#>  cluster          2.1.0    2019-06-19 [2] CRAN (R 3.6.3)                       
#>  colorspace       1.4-1    2019-03-18 [1] CRAN (R 3.6.0)                       
#>  crayon           1.3.4    2017-09-16 [1] CRAN (R 3.6.0)                       
#>  data.table       1.12.8   2019-12-09 [1] CRAN (R 3.6.0)                       
#>  desc             1.2.0    2018-05-01 [1] CRAN (R 3.6.0)                       
#>  devtools         2.3.1    2020-07-21 [1] CRAN (R 3.6.3)                       
#>  digest           0.6.25   2020-02-23 [1] CRAN (R 3.6.0)                       
#>  dplyr            1.0.1    2020-07-31 [1] CRAN (R 3.6.3)                       
#>  ellipsis         0.3.1    2020-05-15 [1] CRAN (R 3.6.2)                       
#>  evaluate         0.14     2019-05-28 [1] CRAN (R 3.6.0)                       
#>  fansi            0.4.1    2020-01-08 [1] CRAN (R 3.6.2)                       
#>  foreign          0.8-75   2020-01-20 [2] CRAN (R 3.6.3)                       
#>  Formula          1.2-3    2018-05-03 [1] CRAN (R 3.6.0)                       
#>  formula.tools    1.7.1    2018-03-01 [1] CRAN (R 3.6.0)                       
#>  fs               1.5.0    2020-07-31 [1] CRAN (R 3.6.2)                       
#>  gdata            2.18.0   2017-06-06 [1] CRAN (R 3.6.0)                       
#>  generics         0.0.2    2018-11-29 [1] CRAN (R 3.6.0)                       
#>  ggplot2          3.3.2    2020-06-19 [1] CRAN (R 3.6.2)                       
#>  glue             1.4.1    2020-05-13 [1] CRAN (R 3.6.2)                       
#>  gridExtra        2.3      2017-09-09 [1] CRAN (R 3.6.0)                       
#>  gtable           0.3.0    2019-03-25 [1] CRAN (R 3.6.0)                       
#>  gtools           3.8.2    2020-03-31 [1] CRAN (R 3.6.2)                       
#>  highr            0.8      2019-03-20 [1] CRAN (R 3.6.0)                       
#>  Hmisc            4.4-1    2020-08-10 [1] CRAN (R 3.6.2)                       
#>  htmlTable        2.0.1    2020-07-05 [1] CRAN (R 3.6.2)                       
#>  htmltools        0.5.0    2020-06-16 [1] CRAN (R 3.6.2)                       
#>  htmlwidgets      1.5.1    2019-10-08 [1] CRAN (R 3.6.0)                       
#>  ineq             0.2-13   2014-07-21 [1] CRAN (R 3.6.0)                       
#>  insight          0.9.0.1  2020-08-16 [1] Github (easystats/insight@8088747)   
#>  jpeg             0.1-8.1  2019-10-24 [1] CRAN (R 3.6.0)                       
#>  knitr            1.29     2020-06-23 [1] CRAN (R 3.6.3)                       
#>  laeken           0.5.1    2020-02-05 [1] CRAN (R 3.6.0)                       
#>  lattice          0.20-41  2020-04-02 [1] CRAN (R 3.6.2)                       
#>  latticeExtra     0.6-29   2019-12-19 [1] CRAN (R 3.6.2)                       
#>  lifecycle        0.2.0    2020-03-06 [1] CRAN (R 3.6.0)                       
#>  lme4             1.1-23   2020-04-07 [1] CRAN (R 3.6.2)                       
#>  magrittr         1.5      2014-11-22 [1] CRAN (R 3.6.0)                       
#>  MASS             7.3-51.5 2019-12-20 [2] CRAN (R 3.6.3)                       
#>  Matrix           1.2-18   2019-11-27 [2] CRAN (R 3.6.3)                       
#>  memoise          1.1.0    2017-04-21 [1] CRAN (R 3.6.0)                       
#>  mice             3.11.0   2020-08-05 [1] CRAN (R 3.6.3)                       
#>  minqa            1.2.4    2014-10-09 [1] CRAN (R 3.6.0)                       
#>  MuMIn            1.43.17  2020-04-15 [1] CRAN (R 3.6.2)                       
#>  munsell          0.5.0    2018-06-12 [1] CRAN (R 3.6.0)                       
#>  mvtnorm          1.1-1    2020-06-09 [1] CRAN (R 3.6.2)                       
#>  nlme             3.1-144  2020-02-06 [2] CRAN (R 3.6.3)                       
#>  nloptr           1.2.2.2  2020-07-02 [1] CRAN (R 3.6.2)                       
#>  nnet             7.3-12   2016-02-02 [2] CRAN (R 3.6.3)                       
#>  operator.tools   1.6.3    2017-02-28 [1] CRAN (R 3.6.0)                       
#>  parameters       0.8.2.1  2020-08-16 [1] Github (easystats/parameters@85b91e8)
#>  pillar           1.4.6    2020-07-10 [1] CRAN (R 3.6.3)                       
#>  pkgbuild         1.1.0    2020-07-13 [1] CRAN (R 3.6.3)                       
#>  pkgconfig        2.0.3    2019-09-22 [1] CRAN (R 3.6.0)                       
#>  pkgload          1.1.0    2020-05-29 [1] CRAN (R 3.6.2)                       
#>  png              0.1-7    2013-12-03 [1] CRAN (R 3.6.0)                       
#>  prettyunits      1.1.1    2020-01-24 [1] CRAN (R 3.6.2)                       
#>  processx         3.4.3    2020-07-05 [1] CRAN (R 3.6.2)                       
#>  ps               1.3.4    2020-08-11 [1] CRAN (R 3.6.3)                       
#>  purrr            0.3.4    2020-04-17 [1] CRAN (R 3.6.2)                       
#>  R6               2.4.1    2019-11-12 [1] CRAN (R 3.6.0)                       
#>  RColorBrewer     1.1-2    2014-12-07 [1] CRAN (R 3.6.0)                       
#>  Rcpp             1.0.5    2020-07-06 [1] CRAN (R 3.6.3)                       
#>  remotes          2.2.0    2020-07-21 [1] CRAN (R 3.6.3)                       
#>  rlang            0.4.7    2020-07-09 [1] CRAN (R 3.6.3)                       
#>  rmarkdown        2.3      2020-06-18 [1] CRAN (R 3.6.3)                       
#>  rpart            4.1-15   2019-04-12 [2] CRAN (R 3.6.3)                       
#>  rprojroot        1.3-2    2018-01-03 [1] CRAN (R 3.6.0)                       
#>  rstudioapi       0.11     2020-02-07 [1] CRAN (R 3.6.0)                       
#>  scales           1.1.1    2020-05-11 [1] CRAN (R 3.6.3)                       
#>  sessioninfo      1.1.1    2018-11-05 [1] CRAN (R 3.6.0)                       
#>  smicd          * 1.1.1    2020-07-18 [1] CRAN (R 3.6.2)                       
#>  statmod          1.4.34   2020-02-17 [1] CRAN (R 3.6.0)                       
#>  stringi          1.4.6    2020-02-17 [1] CRAN (R 3.6.2)                       
#>  stringr          1.4.0    2019-02-10 [1] CRAN (R 3.6.0)                       
#>  survival         3.2-3    2020-06-13 [1] CRAN (R 3.6.2)                       
#>  testthat         2.3.2    2020-03-02 [1] CRAN (R 3.6.2)                       
#>  tibble           3.0.3    2020-07-10 [1] CRAN (R 3.6.2)                       
#>  tidyr            1.1.1    2020-07-31 [1] CRAN (R 3.6.3)                       
#>  tidyselect       1.1.0    2020-05-11 [1] CRAN (R 3.6.3)                       
#>  truncnorm        1.0-8    2018-02-27 [1] CRAN (R 3.6.0)                       
#>  usethis          1.6.1    2020-04-29 [1] CRAN (R 3.6.2)                       
#>  vctrs            0.3.2    2020-07-15 [1] CRAN (R 3.6.3)                       
#>  weights          1.0.1    2020-02-12 [1] CRAN (R 3.6.0)                       
#>  withr            2.2.0    2020-04-20 [1] CRAN (R 3.6.2)                       
#>  xfun             0.16     2020-07-24 [1] CRAN (R 3.6.3)                       
#>  yaml             2.2.1    2020-02-01 [1] CRAN (R 3.6.0)                       
#> 
#> [1] /Users/patil/Library/R/3.6/library
#> [2] /Library/Frameworks/R.framework/Versions/3.6/Resources/library
@IndrajeetPatil IndrajeetPatil added the Enhancement 💥 Implemented features can be improved or revised label Aug 16, 2020
strengejacke added a commit that referenced this issue Aug 16, 2020
@strengejacke
Copy link
Member

semLme should now also work for models w/o bootstrapped se. mle is indeed a problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement 💥 Implemented features can be improved or revised
Projects
None yet
Development

No branches or pull requests

2 participants