index: Extract time-indices from TRIM output.

View source: R/trim_index.R

indexR Documentation

Extract time-indices from TRIM output.

Description

Indices are obtained by dividing the modelled or imputed time totals by a reference value. Most commonly, the time totals for the starting year are used as reference. As a result, the index value for this year will be 1.0, with a standard error of 0.0 by definition.
Alternatively, a range of years can be used as reference. In this case, the mean time totals for this range will be used as reference, and the standard errors will be larger than 0.0.
Starting with rtrim 2.2, an additional method can be selected, which uses a simpler scaling approach to standard errors of the indices

Usage

index(
  x,
  which = c("imputed", "fitted", "both"),
  covars = FALSE,
  base = 1,
  level = NULL,
  method = c("formal", "scaled"),
  long = FALSE
)

Arguments

x

an object of class trim

which

(character) Selector to distinguish between time indices based on the imputed data (default), the fitted model, or both.

covars

(logical) Switch to compute indices for covariate categories as well.

base

(integer or numeric) One or more years, used as as reference for the index. If just a single year is given, the time total of the corresponding year will be uses as a reference. If a range of years is given, the average of the corresponding time totals will be used as reference.
Alternatively, the reference year(s) can be identified using their rank number, i.e. base=1 always refers to the starting year, base=2 to the second year, etc.

level

(numeric) the confidence interval required. Must be in the range 0 to 1. A value of 0.95 results in 95% confidence intervals. The default value of NULL results in no confidence interval to be computed.

method

(character) Method selector. Options are "formal" (default) to use a formal computation of standard errors, resulting in \text{SE}=0 for the reference year, and "scaled" to use a simpler approach, based on linear scaling of the time-totals SE.

long

(logical) Switch to return 'long' output (default is 'wide', as in rtrim versions < 2.2)

Value

A data frame containing indices and their uncertainty expressed as standard error. Depending on the chosen output, columns fitted and se_fit, and/or imputed and se_imp are present. If covars is TRUE, additional indices are computed for the individual covariate categories. In this case additional columns covariate and category are present. The overall indices are marked as covariate ‘Overall’ and category 0.
In case long=TRUE a long table is returned, and a different naming convention is used. e.g., imputed/fitted info is in column series, and standard error are always in column SE.

See Also

Other analyses: coef.trim(), confint.trim(), gof(), now_what(), overall(), overdispersion(), plot.trim.index(), plot.trim.overall(), plot.trim.smooth(), results(), serial_correlation(), summary.trim(), totals(), trendlines(), trim(), vcov.trim(), wald()

Examples


data(skylark)
z <- trim(count ~ site + time, data=skylark, model=2)
index(z)
# mimic classic TRIM:
index(z, "both")
# Extract standard errors for the imputed data
SE <- index(z,"imputed")$se_mod
# Include covariates
skylark$Habitat <- factor(skylark$Habitat) # hack
z <- trim(count ~ site + time + Habitat, data=skylark, model=2)
ind <- index(z, covars=TRUE)
plot(ind)
# Use alternative base year
index(z, base=3)
# Use average of first 5 years as reference for indexing
index(z, base=1:5)
# Prevent SE=0 for the reference year
index(z, method="scaled")

rtrim documentation built on June 22, 2024, 10:39 a.m.