File: test-model_parameters.gam.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 (22 lines) | stat: -rw-r--r-- 716 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
test_that("model_parameters.gam", {
  skip_if_not_installed("mgcv")
  set.seed(123)
  model <-
    mgcv::gam(
      formula = mpg ~ s(hp) + s(wt) + factor(cyl) + am + qsec,
      family = stats::quasi(),
      data = mtcars
    )

  params <- model_parameters(model)
  expect_equal(params$SE, c(10.83359, 1.80704, 2.82608, 1.71366, 0.53172, NA, NA), tolerance = 1e-2)
  expect_equal(params$df_error, c(23.3923, 23.3923, 23.3923, 23.3923, 23.3923, NA, NA), tolerance = 1e-2)
  expect_equal(params$CI[[1]], 0.95, tolerance = 1e-2)
  expect_named(
    params,
    c(
      "Parameter", "Coefficient", "SE", "CI", "CI_low", "CI_high", "t / F",
      "df", "df_error", "p", "Component"
    )
  )
})