tests/coef.R

library(epigrowthfit)
options(warn = 2L, error = if (interactive()) recover)
example("egf", package = "epigrowthfit"); o.1 <- m1; o.2 <- m2


## object ##############################################################

o.2c <- coef(o.2, random = TRUE)
o.2c.e <- structure(as.double(o.2c),
                    len = c(beta = 2L, theta = 2L, b = 40L),
                    map = list(beta = NULL, theta = c(1L, 2L, NA), b = NULL),
                    class = "coef.egf")
stopifnot(identical(o.2c, o.2c.e))


## print ###############################################################

vv <- withVisible(print(o.2c))
stopifnot(exprs = {
	identical(vv[["value"]], o.2c)
	identical(vv[["visible"]], FALSE)
})


## as.list #############################################################

nms <- c("beta", "theta", "b")
o.2cl <- as.list(o.2c)
o.2cl.e <- split(o.2c, factor(labels(o.2c), levels = nms))
for (s in nms)
	attr(o.2cl.e[[s]], "map") <- attr(o.2c, "map")[[s]]
stopifnot(identical(o.2cl, o.2cl.e))
davidearn/epigrowthfit documentation built on Feb. 22, 2025, 12:44 p.m.