Skip to contents

Reuses the assembled design (no formula parsing, no frame assembly) and warm-starts the optimizer at the previous estimates, so a refit costs one re-tape plus the optimization. This is the engine for parametric bootstrap: simulate responses with simulate(), refit to each.

Usage

# S3 method for class 'frmtmb_fit'
refit(object, newresp, start = NULL, ...)

Arguments

object

A frmtmb_fit for a univariate model.

newresp

Replacement response: a vector of the original length, or a matrix of the original dimensions for matrix responses. A bernoulli() response is given as its 0/1 codes, which is what simulate() returns, whatever two values the data held.

start

Optional named start list (as in frm()); when given it replaces the warm start.

...

Refused: an argument the method does not have is an error naming it, rather than silently changing nothing.

Value

A new frmtmb_fit.

Details

A refit does not repeat the warning frm() gives when a nonlinear model's likelihood is flat at the optimum along a combination of its parameters' coefficients. The design, and so the flat direction, is the original fit's, which already warned; a parametric bootstrap would otherwise warn once per replicate. The refit's standard errors along that direction are as unusable as the original's.

Examples

set.seed(2)
dd <- data.frame(x = rnorm(80), g = factor(rep(1:8, 10)))
dd$y <- rnorm(80, 1 + 0.5 * dd$x + rnorm(8, 0, 0.5)[dd$g], 1)
fit <- frm(bf(y ~ x + (1 | g)) + gaussian(), data = dd)
# refit to a simulated response (the parametric-bootstrap step)
ysim <- simulate(fit, nsim = 1, re_formula = NA)[[1]]
rf <- refit(fit, ysim)
fixef(rf)
#>            Estimate Est.Error      Q2.5     Q97.5
#> Intercept 0.9330096 0.2342003 0.4739855 1.3920337
#> x         0.5717610 0.1101705 0.3558307 0.7876912