File: test-model_parameters.lme.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 (31 lines) | stat: -rw-r--r-- 975 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
23
24
25
26
27
28
29
30
31
skip_if_not_installed("nlme")
skip_if_not_installed("lme4")

data("sleepstudy", package = "lme4")

model <- nlme::lme(Reaction ~ Days,
  random = ~ 1 + Days | Subject,
  data = sleepstudy
)

test_that("model_parameters.lme", {
  params <- model_parameters(model, effects = "fixed")
  expect_equal(params$SE, c(6.8245, 1.5458), tolerance = 1e-3)
  expect_equal(
    colnames(params),
    c("Parameter", "Coefficient", "SE", "CI", "CI_low", "CI_high", "t", "df_error", "p", "Effects")
  )
})

test_that("model_parameters.lme", {
  params <- model_parameters(model, effects = "all")
  expect_equal(params$Coefficient, c(251.4051, 10.46729, 24.74024, 5.9221, 0.066, 25.59184), tolerance = 1e-3)
  expect_equal(params$SE, c(6.82452, 1.54578, NA, NA, NA, NA), tolerance = 1e-3)
  expect_equal(
    colnames(params),
    c(
      "Parameter", "Coefficient", "SE", "CI", "CI_low", "CI_high", "t",
      "df_error", "p", "Effects", "Group"
    )
  )
})