stepcand {stepR} | R Documentation |
Forward selection of candidate jumps
Description
Find candidates for jumps in serial data by forward selection.
Usage
stepcand(y, x = 1:length(y), x0 = 2 * x[1] - x[2], max.cand = NULL,
family = c("gauss", "gaussvar", "poisson", "binomial", "gaussKern"), param = NULL,
weights = rep(1, length(y)), cand.radius = 0)
Arguments
y |
a numeric vector containing the serial data |
x |
a numeric vector of the same length as |
x0 |
a single numeric giving the last unobserved sample point directly before sampling started |
max.cand |
single integer giving the maximal number of blocks to find; defaults to using all data (note: there will be one block more than the number of jumps |
family |
distribution of the errors, either |
param |
additional parameters specifying the distribution of the errors; the number of trials for family |
weights |
a numeric vector of the same length as |
cand.radius |
a non-negative integer: adds for each candidate found all indices that are at most |
Value
An object of class stepcand
extending class stepfit
such that it can be used as an input to steppath.stepcand
: additionally contains columns
cumSum |
The cumulative sum of |
cumSumSq |
The cumulative sum of squares of |
cumSumWe |
The cumulative sum of weights up to |
improve |
The improvement this jump brought about when it was selected. |
See Also
Examples
# simulate 5 blocks (4 jumps) within a total of 100 data points
b <- c(sort(sample(1:99, 4)), 100)
f <- rep(rnorm(5, 0, 4), c(b[1], diff(b)))
rbind(b = b, f = unique(f), lambda = exp(unique(f) / 10) * 20)
# add gaussian noise
x <- f + rnorm(100)
# find 10 candidate jumps
stepcand(x, max.cand = 10)
# for poisson observations
y <- rpois(100, exp(f / 10) * 20)
# find 10 candidate jumps
stepcand(y, max.cand = 10, family = "poisson")
# for binomial observations
size <- 10
z <- rbinom(100, size, pnorm(f / 10))
# find 10 candidate jumps
stepcand(z, max.cand = 10, family = "binomial", param = size)