library(bayesnec)
nec3param <- function(beta, nec, top, x) {
top * exp(-exp(beta) * (x - nec) *
ifelse(x - nec < 0, 0, 1))
}
data <- data.frame(x = seq(1, 20, length.out = 10), tr = 100, wght = c(1, 2),
group_1 = sample(c("a", "b"), 10, replace = TRUE),
group_2 = sample(c("c", "d"), 10, replace = TRUE))
data$y <- nec3param(beta = -0.2, nec = 4, top = 100, data$x)
# returns error
# > f_1 <- y ~ crf(x, "nec3param") + z
# regular formula not allowed, wrap it with function bnf
# > check_formula(f_1, data)
# population-level covariates are not allowed
# > check_formula(bnf(f_1), data)
# \donttest{
# expect a series of messages for because not all
# nec models have the "bot" parameter
f_2 <- y | trials(tr) ~ crf(x, "nec") + (nec + bot | group_1)
check_formula(bnf(f_2), data, run_par_checks = TRUE)
# }
# runs fine
f_3 <- "y | trials(tr) ~ crf(sqrt(x), \"nec3param\")"
check_formula(bnf(f_3), data)
f_4 <- y | trials(tr) ~ crf(x, "nec3param") + ogl(group_1) + pgl(group_2)
inherits(check_formula(bnf(f_4), data), "bayesnecformula")
Run the code above in your browser using DataLab