theta: Estimate the symmetric second moment array of values.

View source: R/theta.r

thetaR Documentation

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)

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.

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.

Value

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

Author(s)

Steven E. Pav shabbychef@gmail.com

See Also

twomoments

Examples

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

## Not run: 
if (require(sandwich)) {
 th2 <- theta(X,vcov.func=vcovHC)
}

## End(Not run)
# works on data frames too:
set.seed(456)
X <- data.frame(a=runif(100),b=rnorm(100),c=1)
th <- theta(X)

madness documentation built on Aug. 21, 2023, 9:07 a.m.