Learn R Programming

comparison (version 1.0.8)

makeCompVar: Compute integrated means and covariances

Description

Takes a large sample from the background population and calculates the within and between covariance matrices, a vector of means, a vector of the counts of replicates for each item from the sample, and other bits needed to make up a compcovar object.

Usage

makeCompVar(x, ...)

# S3 method for default makeCompVar(x, item.column, ...)

# S3 method for formula makeCompVar(x, data = NULL, ...)

Value

an object of class compvar

Arguments

x

a matrix, or data.frame, of observations, with cases in rows, and properties as columns, or a formula.

...

other arguments.

item.column

an integer indicating which column gives the item.

data

if x is a formula, then the user must supply a data.frame containing the observations.

Methods (by class)

  • makeCompVar(default): Create a compvar object using a formula.

  • makeCompVar(formula): Create a compvar object using a formula.

Author

David Lucy and James Curran

Details

Uses ML estimation at the moment - this will almost certainly change in the future and hopefully allow regularisation methods to get a more stable (and non-singular) estimate.

Examples

Run this code
# load Greg Zadora's glass data
data(glass)

# calculate a compcovar object based upon glass
# using K, Ca and Fe - warning - could take time
# on slower machines
background = subset(glass, select = c(item, logKO, logCaO, logFeO))
Z1 = makeCompVar(background, 1)

# Use the formula interface
Z2 = makeCompVar(item ~ logKO + logCaO + logFeO, data = glass)

Run the code above in your browser using DataLab