null_ts: Generate null data by simulating from a time series model.

View source: R/method-ts.r

null_tsR Documentation

Generate null data by simulating from a time series model.

Description

Null hypothesis: data follows a time series model using auto.arima from the forecast package

Usage

null_ts(var, modelfn)

Arguments

var

variable to model as a time series

modelfn

method for simulating from ts model.

Value

a function that given data generates a null data set. For use with lineup or rorschach

See Also

null_model

Examples

require(forecast)
require(ggplot2)
require(dplyr)
data(aud)
l <- lineup(null_ts("rate", auto.arima), aud)
ggplot(l, aes(x=date, y=rate)) + geom_line() +
  facet_wrap(~.sample, scales="free_y") +
  theme(axis.text = element_blank()) +
  xlab("") + ylab("")
l_dif <- l %>%
  group_by(.sample) %>%
  mutate(d=c(NA,diff(rate))) %>%
  ggplot(aes(x=d)) + geom_density() +
  facet_wrap(~.sample)

nullabor documentation built on Sept. 11, 2024, 8:20 p.m.