Two shapes, and the difference is the NAMES. The default is brms's
summary matrix: one row per population-level coefficient under
brms's own name (Intercept, sigma_Intercept, x), and the
columns Estimate, Est.Error, Q2.5 and Q97.5. A
maximum-likelihood fit has no draws, so Est.Error is the standard
error and the Q columns are the Wald interval at those
probabilities, which is the interval confint() reports.
flatten = TRUE is one vector of estimates in the INTERNAL parameter
name, which is what confint(), par_template(), start and
newparams use: dpar_column, with the location parameter's own
coefficients left unprefixed (x, not mu_x), and the response
prefixed ahead of that in a multivariate fit.
Usage
# S3 method for class 'frmtmb_fit'
fixef(
object,
summary = TRUE,
robust = FALSE,
probs = c(0.025, 0.975),
pars = NULL,
...,
flatten = FALSE
)Arguments
- object
A
frmtmb_fit.- summary, robust
brms's arguments, in brms's positions so that a positional brms call asks the same question. brms answers
summary = FALSEwith the posterior draws androbust = TRUEwith their median and MAD, and a maximum-likelihood fit has no draws, so both are refused by name with the reason. The default of each is accepted and changes nothing.- probs
Probabilities of the two quantile columns. brms takes the posterior quantiles there; here they are the ends of the Wald interval at those probabilities.
- pars
Row names to keep, in the order given, as in brms. A name the fit does not have is an error listing the ones it does.
- ...
Refused: an argument the method does not have is an error naming it, rather than silently changing nothing.
- flatten
If
TRUE, one named vector of ESTIMATES in theconfint()spelling instead of the summary matrix. Coefficients come in linear-predictor order, which need not be the matrix's row order; index by name. Distributional parameters held at a constant are included here and are absent fromvcov()and from the matrix, which cover the ESTIMATED population-level coefficients only. The exception is a constant the family itself supplies and brms does not show, an ordinal family'sdiscat 1, which is left out.
Details
A distributional parameter nobody wrote a formula for is not a
population-level coefficient in brms and is not a row here: sigma
of a plain gaussian fit is reported by summary() under
Further Distributional Parameters, on its own natural scale.
hypothesis() and variables() use a THIRD vocabulary, brms's
parameter names: b_Intercept, b_sigma_Intercept for a sigma
formula, and sigma on its natural scale when no formula was written
for it. hypothesis() puts class = "b"'s b_ in front of a bare
name, so its default spelling of those is Intercept and
sigma_Intercept.
unlist(fixef(fit, flatten = TRUE)) is none of them. Use
flatten = TRUE to line coefficients up with a prior or with
confint(), and the default matrix to read an estimate with its
standard error.
See also
vcov.frmtmb_fit(), which names its rows as this matrix
does, and confint.frmtmb_fit(), which names them as
flatten = TRUE names its entries.
Examples
set.seed(1)
dd <- data.frame(x = rnorm(100), g = factor(rep(1:10, 10)))
dd$y <- rnorm(100, 1 + 0.5 * dd$x + rnorm(10, 0, 0.8)[dd$g], 1)
# brms's summary matrix, one row per population-level coefficient
fit <- frm(bf(y ~ x + (1 | g), sigma ~ x) + gaussian(), data = dd)
fixef(fit)
#> Estimate Est.Error Q2.5 Q97.5
#> Intercept 1.2368734 0.25319299 0.74062430 1.73312258
#> sigma_Intercept -0.0959985 0.07493824 -0.24287474 0.05087775
#> x 0.5943909 0.10979801 0.37919074 0.80959104
#> sigma_x 0.2082862 0.07165775 0.06783963 0.34873283
exp(fixef(fit)["sigma_Intercept", "Estimate"]) # sigma is on the log
#> [1] 0.9084654
# flatten to the vector confint() names its rows by
fixef(fit, flatten = TRUE)
#> (Intercept) x sigma_(Intercept) sigma_x
#> 1.2368734 0.5943909 -0.0959985 0.2082862
all(names(fixef(fit, flatten = TRUE)) %in% rownames(confint(fit)))
#> [1] TRUE
# the standard error column is vcov()'s diagonal
all.equal(fixef(fit)[, "Est.Error"], sqrt(diag(vcov(fit))))
#> [1] TRUE