index | R Documentation |
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
index(
x,
which = c("imputed", "fitted", "both"),
covars = FALSE,
base = 1,
level = NULL,
method = c("formal", "scaled"),
long = FALSE
)
x |
an object of class |
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. |
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 |
long |
(logical) Switch to return 'long' output (default is 'wide', as in rtrim versions < 2.2) |
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
.
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()
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.