Refits the model with one group (or observation) left out at a time,
warm-started at the full-data estimates, and collects the
fixed-effect and covariance-parameter changes. cooks.distance() on
the result gives the scaled fixed-effect displacement (calling it on
the fit itself runs influence() first); dfbeta() and dfbetas()
give the per-unit coefficient changes, raw and scaled by the
coefficient standard errors (the lme4 influence surface).
plot.frmtmb_influence() draws all three.
Usage
# S3 method for class 'frmtmb_fit'
influence(model, groups = NULL, data = NULL, force = FALSE, ...)
# S3 method for class 'frmtmb_fit'
cooks.distance(model, ...)
# S3 method for class 'frmtmb_influence'
dfbeta(model, ...)
# S3 method for class 'frmtmb_influence'
dfbetas(model, ...)Arguments
- model
A
frmtmb_fit.- groups
Name of a random-effect grouping factor (see
ngrps()) to delete level-wise;NULLdeletes single observations (refuses for large n unlessforce = TRUE).- data
The original model data. The default is the data the fit holds: the model frame and the variables the formula reads through a transform (
xofpoly(x, 2)orlog(x)), on the rows the fit used. A data-dependent basis (poly(),splines::ns(),scale()) keeps the knots, coefficients or center of the fit in every deletion refit, as in lme4'sinfluence.merMod(), so a coefficient change is not a change of basis.- force
Allow observation-wise deletion for n > 500.
- ...
Refused: an argument the method does not have is an error naming it, rather than silently changing nothing.
Value
A frmtmb_influence object: fixed and theta matrices
(one row per deleted unit) plus the full-data reference.
Details
Each deletion refits the same model, so an ordinal response keeps the
threshold count of the full-data fit, and the per-level counts of
thres(gr = ), whether the response is coded as integers, as a
character vector or as an ordered factor. Deleting the last
observation in ANY category, bottom, interior or top, leaves that
category's threshold in the model and unidentified, which shows as a
large displacement in its column, never as a shorter row or a
coefficient under the next column's name.
Two deletions cannot refit the fitted model at all and are refused by
name. A groups = deletion that removes a whole level of
thres(gr = ) takes away every observation behind that level's
thresholds, so they could only be invented. data = holding a
response category outside the fitted model's threshold layout, or a
thres(gr = ) level the fit never saw, describes a different model. A
category the fit never OBSERVED is not outside that layout when
thres(K) declared it, so data = may reach one of those.
A refit that fails for any reason, these two included, leaves its row
NA, and the failures are counted. When some units failed the table
comes back with a warning carrying the count and the first reason;
when every unit failed there is no table to hand back, so that first
reason is raised as an error instead of a silent matrix of NA.
Examples
# \donttest{
set.seed(7)
dd <- data.frame(x = rnorm(60), g = factor(rep(1:6, 10)))
dd$y <- rnorm(60, 1 + 0.5 * dd$x + rnorm(6, 0, 0.5)[dd$g], 1)
fit <- frm(bf(y ~ x + (1 | g)) + gaussian(), data = dd)
#> Boundary (singular) fit: sd_g__Intercept is at zero. The likelihood does not change as it moves further that way, so it has no standard error (NaN in summary(), vcov() and confint()); the other standard errors are kept. lme4 reports such a fit as singular; diagnose() lists the components at the boundary
infl <- influence(fit, groups = "g")
cooks.distance(infl)
#> 1 2 3 4 5 6
#> 0.04211219 0.49008215 0.04168487 0.12687100 0.02619522 0.18339082
# }