Learn R Programming

madness (version 0.2.8)

theta: Estimate the symmetric second moment array of values.

Description

Given rows of observations of some vector (or multidimensional data), estimates the second moment by taking a simple mean, returning a madness object.

Usage

theta(X, vcov.func=vcov, xtag=NULL)

Value

A madness object representing the mean of the outer product of the tail dimensions of X.

Arguments

X

a multidimensional array (or a data frame) of observed values.

vcov.func

a function which takes an object of class lm, and computes a variance-covariance matrix. If equal to the string "normal", we assume multivariate normal returns.

xtag

an optional string tag giving the name of the input data. defaults to figuring it out from the input expression.

Author

Steven E. Pav shabbychef@gmail.com

Details

Given a \(n\times k_1 \times k_2 \times ... \times k_l\) array whose 'rows' are independent observations of \(X\), computes the \(k_1 \times k_2 \times ... \times k_l \times k_1 \times k_2 ... k_l\) array of the mean of \(\mathrm{outer}(X,X)\) based on \(n\) observations, returned as a madness object. The variance-covariance is also estimated, and stored in the object.

One may use the default method for computing covariance, via the vcov function, or via a 'fancy' estimator, like sandwich:vcovHAC, sandwich:vcovHC, etc.

See Also

twomoments

Examples

Run this code
set.seed(123)
X <- matrix(rnorm(1000*3),ncol=3)
th <- theta(X)

if (FALSE) {
if (require(sandwich)) {
 th2 <- theta(X,vcov.func=vcovHC)
}
}
# works on data frames too:
set.seed(456)
X <- data.frame(a=runif(100),b=rnorm(100),c=1)
th <- theta(X)

Run the code above in your browser using DataLab