Skip to contents

Partitions the link-scale variance of a fitted sdmTMB model among its random components using sdmTMB::tidy(), and plots the proportion of that variance from each. This is an approximate, descriptive summary, not a formal variance decomposition.

Usage

plot_variance_partitioning(fit, base_size = 11)

Arguments

fit

A fitted sdmTMB::sdmTMB() model.

base_size

Numeric. Base font size. Default 11.

Value

A ggplot object.

Details

Only components whose standard deviation is a marginal SD on the link scale are included:

  • the spatial field (sigma_O) and spatiotemporal field (sigma_E);

  • random intercepts (sd__(Intercept), one per grouping factor);

  • observation error, only for a gaussian() family with an identity link or a lognormal() family, where phi is an SD on the link scale.

Left out are observation error for other families (for e.g. Tweedie, Gamma or NB2, phi is a dispersion or shape parameter, and binomial has none), smooth-term SDs (sd__s(...), the SD of penalised spline coefficients, not of the fitted smooth) and spatially varying coefficient SDs (sigma_Z, whose contribution scales with the covariate). The proportions are therefore of the variance of the included components only.

See also

Author

Mikko Vihtakari

Examples

# \donttest{
mesh <- sdmTMB::make_mesh(sdmTMB::pcod, c("X", "Y"), cutoff = 20)
m <- sdmTMB::sdmTMB(
  density ~ 0 + as.factor(year), data = sdmTMB::pcod, time = "year",
  mesh = mesh, family = sdmTMB::tweedie()
)
plot_variance_partitioning(m)

# }