| linear_algebra_stats | R Documentation |
'broadcast' provides some simple Linear Algebra Functions for Statistics:
cinv();
sd_lc().
cinv(x)
sd_lc(X, vc, bad_rp = NaN)
x |
a real symmetric positive-definite square matrix. |
X |
a numeric (or logical) matrix of multipliers/constants |
vc |
the variance-covariance matrix for the (correlated) random variables. |
bad_rp |
if |
cinv()
cinv()
computes the Choleski inverse
of a real symmetric positive-definite square matrix.
sd_lc()
Given the linear combination X %*% b, where:
X is a matrix of multipliers/constants;
b is a vector of (correlated) random variables;
vc is the symmetric variance-covariance matrix for b;
sd_lc(X, vc)
computes the standard deviations for the linear combination X %*% b,
without making needless copies.
sd_lc(X, vc) will use much less memory than a base 'R' approach.
sd_lc(X, vc) may possibly, but not necessarily, be faster than a base 'R' approach
(depending on the Linear Algebra Library used for base 'R').
For cinv():
A matrix.
For sd_lc():
A vector of standard deviations.
John A. Rice (2007), Mathematical Statistics and Data Analysis (6th Edition)
chol, chol2inv
vc <- datasets::ability.cov$cov
X <- matrix(rnorm(100), 100, ncol(vc))
solve(vc)
cinv(vc) # faster than `solve()`, but only works on positive definite matrices
all(round(solve(vc), 6) == round(cinv(vc), 6)) # they're the same
sd_lc(X, vc)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.