view_on_correlation | R Documentation |
Helper to construct views on the correlation matrix.
view_on_correlation(x, cor) ## Default S3 method: view_on_correlation(x, cor) ## S3 method for class 'matrix' view_on_correlation(x, cor) ## S3 method for class 'xts' view_on_correlation(x, cor) ## S3 method for class 'tbl_df' view_on_correlation(x, cor)
x |
An univariate or a multivariate distribution. |
cor |
A |
A list
of the view
class.
library(ggplot2) # Invariant ret <- diff(log(EuStockMarkets)) # Assume that a panic event throws all correlations to the roof! co <- matrix(0.95, 4, 4) diag(co) <- 1 co # Prior probability (usually the equal-weight setting) prior <- rep(1 / nrow(ret), nrow(ret)) # View views <- view_on_correlation(x = ret, cor = co) views # Optimization ep <- entropy_pooling(p = prior, Aeq = views$Aeq, beq = views$beq, solver = "nlminb") autoplot(ep) # prior correlation structure stats::cor(ret) # posterior correlation structure matches the initial view very closely stats::cov2cor(ffp_moments(x = ret, p = ep)$sigma)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.