File: test-model_parameters.mle2.R

package info (click to toggle)
r-cran-parameters 0.24.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,852 kB
  • sloc: sh: 16; makefile: 2
file content (18 lines) | stat: -rw-r--r-- 571 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
test_that("model_parameters.mle2", {
  skip_if_not_installed("bbmle")

  x <- 0:10
  y <- c(26, 17, 13, 12, 20, 5, 9, 8, 5, 4, 8)
  d <- data.frame(x, y)

  LL <- function(ymax = 15, xhalf = 6) {
    -sum(stats::dpois(y, lambda = ymax / (1 + x / xhalf), log = TRUE))
  }
  model <- suppressWarnings(bbmle::mle2(LL))
  params <- model_parameters(model)
  expect_equal(params$SE, c(4.224444, 1.034797), tolerance = 1e-3)
  expect_equal(
    colnames(params),
    c("Parameter", "Coefficient", "SE", "CI", "CI_low", "CI_high", "z", "df_error", "p")
  )
})