Package 'mvtweedie'

Title: Fit multivariate logit Tweedie model using mgcv or glmmTMB
Description: Defines predict function that transforms output from a Tweedie GLM fitted using mgcv or glmmTMB, and returns predictions of an equivalent multivariate logit Tweedie model. This can then be used for standard plotting and diagnostics.
Authors: James Thorson [aut, cre] (ORCID: <https://orcid.org/0000-0001-7415-1010>)
Maintainer: James Thorson <[email protected]>
License: GPL-3
Version: 1.1.0
Built: 2026-06-02 00:35:13 UTC
Source: https://github.com/james-thorson-noaa/mvtweedie

Help Index


Data to demonstrate and test multivariate logit Tweedie model

Description

Data sufficient to demonstrate how to use a Tweedie GLM to provide inference about proportions e.g. in food habits analysis, where the model output is processed to represent a multivariate logit Tweedie model.

Usage

data(Middleton_Island_TUPU)

Details

Specifically includes Tufted Puffin bill loads sampled at Middleton Island.

  • Response Numeric prey biomass in bill load samples

  • Year Numeric year

  • group factor representing prey species or category

  • SampleID factor with a level for every sampling occasion, e.g., for use in row normalization

Author(s)

Mayumi Arimitsu


Get predictions from a multivariate logit interpretation of a Tweedie GLM

Description

It returns a tibble with predicted proportions from a Tweedie GAM model.

Usage

predict_mvtweedie(
  model,
  exclude_terms = NULL,
  length_out = 50,
  values = NULL,
  ...
)

Details

The created tibble can then be plotted using ggplot2


Predict proportions for new data

Description

Predict proportions and associated standard errors using a standard S3 object interface

Usage

## S3 method for class 'mvtweedie'
predict(
  x,
  category_name = "group",
  newdata,
  origdata = x$frame,
  se.fit = FALSE
)

Arguments

x

output from gam or glmmTMB, but with class(x)=c("mvtweedie",...) where ... indicates the original values for class(x)

category_name

name of column that indicates grouping variable

newdata

An optional data frame in which to look for variables with which to predict. If omitted, the fitted values are used.

origdata

original data used when fitting

se.fit

A switch indicating if standard errors are required.

Details

A Tweedie GLM using a log-link and multiple categories can be transformed to yield predicted proportions and associated SEs, where the model is interpreted as a multivariate logit Tweedie distribution. This function does this transformation for a model fitted using:

  • A generalized additive model (GAM) using gam

  • A generalized linear mixed model (GLMM) using glmmTMB

It then also calculates an approximation to the standard error for this proportion

Examples

## Not run: 
# Load packages
library(mvtweedie)

# load data set
data( Middleton_Island_TUPU, package="mvtweedie" )
DF = Middleton_Island_TUPU

# Run Tweedie GLM
gam0 = gam( formula = Response ~ 0 + group, data = DF, family = tw )

# Inspect results
class(gam0) = c( "mvtweedie", class(gam0) )
predict(gam0, se.fit=TRUE, origdata = DF)

## End(Not run)