Description Usage Arguments Details Value Examples

Fully incorporates the uncertainty from the posterior of the DFA trend

1 2 3 4 5 6 7 8 9 10 |

`rotated_modelfit` |
Output from |

`y` |
A numeric vector to correlate with the DFA trend. Must be the same length as the DFA trend. |

`trend` |
A number corresponding to which trend to use, defaults to 1. |

`time_window` |
Indices indicating a time window slice to use in the correlation. Defaults to using the entire time window. Can be used to walk through the timeseries and test the cross correlations. |

`trend_samples` |
The number of samples from the trend posterior to use. A model will be run for each trend sample so this value shouldn't be too large. Defaults to 100. |

`stan_iter` |
The number of samples from the posterior with each Stan model run, defaults to 300. |

`stan_chains` |
The number of chains for each Stan model run, defaults to 1. |

`...` |
Other arguments to pass to |

Uses a `sigma ~ half_t(3, 0, 2)`

prior on the residual standard
deviation and a `uniform(-1, 1)`

prior on the correlation coefficient.
Fitted as a linear regression of `y ~ x`

, where y represents the `y`

argument to `trend_cor()`

and `x`

represents the DFA trend, and both `y`

and `x`

have been scaled by subtracting their means and dividing by their
standard deviations. Samples are drawn from the posterior of the trend and
repeatedly fed through the Stan regression to come up with a combined
posterior of the correlation.

A numeric vector of samples from the correlation coefficient posterior.

1 2 3 4 5 6 7 8 9 10 11 12 13 | ```
set.seed(1)
s <- sim_dfa(num_trends = 1, num_years = 15)
m <- fit_dfa(y = s$y_sim, num_trends = 1, iter = 50, chains = 1)
r <- rotate_trends(m)
n_years <- ncol(r$trends[, 1, ])
fake_dat <- rnorm(n_years, 0, 1)
correlation <- trend_cor(r, fake_dat, trend_samples = 25)
hist(correlation)
correlation <- trend_cor(r,
y = fake_dat, time_window = 5:15,
trend_samples = 25
)
hist(correlation)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.