bnecfit as fitted by function bnec.R/bnecfit-methods.R
update.bnecfit.Rd# S3 method for class 'bnecfit'
update(
object,
newdata = NULL,
recompile = NULL,
x_range = NULL,
resolution = NULL,
sig_val = NULL,
loo_controls,
force_fit = FALSE,
...
)Optional data.frame to update the model
with new data. Data-dependent default priors will not be updated
automatically.
A logical, indicating whether the Stan
model should be recompiled. If NULL (the default), update
tries to figure out internally, if recompilation is necessary. Setting it to
FALSE will cause all Stan code changing arguments to be ignored.
As for bnec. Each is taken
from object unless supplied, and is the bnec default
where object records none, as an object fitted by an earlier version
of bayesnec does not. An x_range of NA, the default of
bnec, follows the range of newdata.
As for bnec. An element not named is
taken from object, as amend describes.
Whether to refit where family names a family or
link that differs from the one the model was fitted with. New data alone
never require it.
Further arguments to brm.
On a bayesnecfit or bayesmanecfit, a refitted
bayesnecfit if one equation succeeds or a bayesmanecfit
if several succeed. The abstract bnecfit method raises an error
naming any other class.
The models are refitted with the family they were fitted with
unless family is supplied. No family is read off newdata, so
new data alone never change the family and never require
force_fit = TRUE. The new data are checked against the requirements
of the family the refit uses, as bnec checks its data. A value
at a boundary that family excludes, such as a zero for Gamma or a 1
for beta, is shifted off it, and the shift is reported and stored in
the fit's bnec_record where it has one. A value the family
admits is passed on as recorded, so a gaussian fit keeps an exact 1
and a joint hurdle_gamma fit keeps its zeros. A bounded response at
one of its bounds in every observation is refused before any model is
refitted, unless the fit is of the constant equation ecxflat alone.
A family passed through ... is read exactly as
bnec reads it: the link is assigned by bayesnec unless
the caller writes one, an unsupported link is refused before any model is
refitted, and the validated family is the one brms receives. See the
The link section of bnec. Supplying a family that
differs from the fitted one requires force_fit = TRUE, because the
priors carried over from the original fit were built for the original family.
Without it the call is refused before the data are checked, so nothing is
reported as shifted.
Families are compared by name and links, so Gamma(link = "identity")
supplied for a Gamma fit is not a change of family.
A family the stored formula cannot describe is refused before any model is
refitted, whether or not force_fit is set. A disp() term is
checked against it as bnec checks it, so poisson is
refused for a fit with a disp() term. A family that names its
dispersion parameter differently from the fitted one is refused as well,
such as gaussian, whose parameter is sigma, for a Beta
fit, whose parameter is phi. So is a change that adds or removes the
second block of a two-block family such as hurdle_gamma. Fit such a
model with bnec. New data are checked against a variance
function in disp() as bnec checks its data.
if (FALSE) { # \dontrun{
library(bayesnec)
data(manec_example)
# due to package size issues, `manec_example` does not contain original
# stanfit DSO, so need to recompile here
smaller_manec <- update(manec_example, chains = 2, iter = 50,
recompile = TRUE)
# original `manec_example` is fit with a Gaussian. Refitting it to the
# original `nec_data$y` with a Beta distribution changes the family, so it
# requires `force_fit = TRUE`, and a message says the priors may not suit it.
beta_manec <- update(manec_example, newdata = nec_data, recompile = TRUE,
chains = 2, iter = 50,
family = Beta(link = "identity"), force_fit = TRUE)
} # }