Internals | R Documentation |
Functions used internally.
ts_index(x, type=c("density", "expectation"))
x |
A vector of observations, possibly with missing values. |
type |
Character, type of index to calculate. |
ts_index
calculates positional indices of elements of a vector
that fulfill the following conditions when type = "density"
:
(1) if there is only one observation present before the first NA
,
it is not selected, else, all the observations preceding to the
first NA
are selected;
(2) if there is only one observation present after the last NA
,
it is not selected, else, all the observations following the
last NA
are selected;
(3) if there is only one observation present between two
consecutive NA
s, it is not selected, else, all the
observations falling between two consecutive NA
s are selected.
ts_index
calculates positional indices of elements of a vector
that immediately follow a missing (NA
) value if
type = "expectation"
. The reason for this
is that these elements depend on missing data given a first order
Markov process. As a result, these need different treatment in
calculating log densities for model selection.
ts_index
returns an integer vector.
Peter Solymos and Khurram Nadeem
## ts_index
x <- 1:20
x[c(3,4, 6, 10, 13:15, 20)] <- NA
ts_index(x, "density")
ts_index(x, "expectation")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.