Learn R Programming

madness (version 0.2.0)

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)

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.

Value

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

Details

Given a $n x k_1 x k_2 ... x k_l$ array whose 'rows' are independent observations of $X$, computes the $k_1 x k_2 x ... x k_l x k_1 x k_2 ... k_l$ array of the mean of $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)

## 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)

Run the code above in your browser using DataLab