post_trend: Trend through Posterior Distributions

Description Usage Arguments Details Value See Also Examples

View source: R/tsTau.R

Description

Fit a trend to a time series of posterior estimates. Ends up being similar to bootstrapping.

Usage

1
post_trend(x, Y, nSamp = 100)

Arguments

x

time step

Y

matrix of posterior samples. Each column is a time step, each row is a sample of the posterior

nSamp

number of times each set of posterior samples should be resampled to fit trend. I.e., number of bootstrap iterations.

Details

Uses Kendall's Tau and accounts for serial correlation in the time series (up to ARMA(2,2)). Uses Kendall::Kendall. Accounts for ties.

Value

A named numeric vector of length 3, containing Kendall's Tau, the associated Z statistic, and the p-value

See Also

tsTau

Examples

1
2
3
4
5
6
7
8
n <- 20
x <- 1:n
slope <- 0.5
n_post <- 50
ar_coeff <- 0.85
y <- c(slope*x+arima.sim(model=list(ar=c(ar_coeff)), n=n))
y_post <- sapply(y, function(x)rnorm(n_post, mean=x, sd=1))
post_trend(x, y_post, 10)

rBatt/trawlDiversity documentation built on Aug. 14, 2021, 1:01 p.m.