Create a dataset for predictions

bnec_newdata(x, resolution = 100, x_range = NA, ...)

Arguments

x

An object of class bayesnecfit or bayesmanecfit as returned by bnec, or of class bayesnecjointfit as returned by bnec_joint.

resolution

A numeric vector of length 1 indicating the number of x values over which to predict values.

x_range

A numeric vector of length 2 indicating the range of x values over which to make predictions.

...

Class-specific arguments, including level for a bayesnecgroupfit.

Value

A data.frame to be used in predictions. Ordinary and hurdle fits give resolution rows. A bayesnecjointfit gives that many rows per level, with the level varying slowest. A bayesnecgroupfit gives one grid per level, as a data frame with a leading level column when schemas match or a named list otherwise. Selecting one grouped level gives one data frame.

Where the formula has a disp(~...) term naming a column other than the predictor, the data frame holds that column at one fixed value, the first level of a factor or the median of a numeric column, and names it in the attribute "bnec_disp_placeholders". The value is the one the fitted curve and the estimates are read at, and the mean does not depend on it. posterior_predict and predict treat a column named there as a placeholder, and draw its value for each posterior draw from the data the fit was made from; see posterior_predict. A column whose values have been changed from the placeholder is used as given.

Examples

if (FALSE) { # \dontrun{
library(bayesnec)
nec4param <- pull_out(manec_example, model = "nec4param")
# Make fine resolution, predict out of range
newdata <- bnec_newdata(nec4param, resolution = 200, x_range = c(0, 4))
nrow(newdata) == 200
all(range(newdata$x) == c(0, 4))
newdata2 <- bnec_newdata(manec_example) # default size
nrow(newdata2) == 100
} # }