Internals {PVAClone}R Documentation

Internal functions

Description

Functions used internally.

Usage

ts_index(x, type=c("density", "expectation"))

Arguments

x

A vector of observations, possibly with missing values.

type

Character, type of index to calculate.

Details

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 NAs, it is not selected, else, all the observations falling between two consecutive NAs 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.

Value

ts_index returns an integer vector.

Author(s)

Peter Solymos and Khurram Nadeem

Examples

## ts_index
x <- 1:20
x[c(3,4, 6, 10, 13:15, 20)] <- NA
ts_index(x, "density")
ts_index(x, "expectation")

[Package PVAClone version 0.1-7 Index]