spm_lag: Create lagged columns in a sspm smoothed data slot

spm_lagR Documentation

Create lagged columns in a sspm smoothed data slot

Description

This function is a wrapper around lag (note that not all arguments are supported). The default value for the lag is the mean of the series.

Usage

spm_lag(sspm_object, vars, n = 1, default = "mean", ...)

## S4 method for signature 'sspm'
spm_lag(sspm_object, vars, n = 1, default = "mean", ...)

## S4 method for signature 'sspm_fit'
spm_lag(sspm_object, vars, n = 1, default = "mean", ...)

Arguments

sspm_object

[sspm_dataset] An object of class sspm_dataset.

vars

[character] Names of the variables to lag.

n

Positive integer of length 1, giving the number of positions to lag or lead by

default

The value used to pad x back to its original size after the lag or lead has been applied. The default, NULL, pads with a missing value. If supplied, this must be a vector with size 1, which will be cast to the type of x.

...

a list of variables that are the covariates that this smooth is a function of. Transformations whose form depends on the values of the data are best avoided here: e.g. s(log(x)) is fine, but s(I(x/sd(x))) is not (see predict.gam).

Value

Updated sspm_object.

Examples

## Not run: 
sspm_model <- sspm_model %>%
    spm_lag(vars = c("weight_per_km2_borealis_with_catch",
                     "weight_per_km2_all_predators"),
                     n = 1)

## End(Not run)


pedersen-fisheries-lab/spaspm documentation built on Feb. 16, 2025, 7:39 p.m.