cg-stats: Mean, covariance and counts for grouped data (statistics for...

cg-statsR Documentation

Mean, covariance and counts for grouped data (statistics for conditional Gaussian distribution).

Description

CGstats provides what corresponds to calling cow.wt on different strata of data where the strata are defined by the combinations of factors in data.

Usage

CGstats(object, varnames = NULL, homogeneous = TRUE, simplify = TRUE)

Arguments

object

A dataframe.

varnames

Names of variables to be used.

homogeneous

Logical; if TRUE a common covariance matrix is reported.

simplify

Logical; if TRUE the result will be presented in a simpler form.

Value

A list whose form depends on the type of input data and the varnames.

Author(s)

Søren Højsgaard, sorenh@math.aau.dk

See Also

cov.wt

Examples


data(milkcomp)
# milkcomp <- subset(milkcomp, (treat %in% c("a", "b")) & (lactime %in% c("t1", "t2")))
# milkcomp <- milkcomp[,-1]
# milkcomp$treat 	<- factor(milkcomp$treat)
# milkcomp$lactime 	<- factor(milkcomp$lactime)

CGstats(milkcomp)
CGstats(milkcomp, c(1, 2))
CGstats(milkcomp, c("lactime", "treat"))
CGstats(milkcomp, c(3, 4))
CGstats(milkcomp, c("fat", "protein"))

CGstats(milkcomp, c(2, 3, 4), simplify=FALSE)
CGstats(milkcomp, c(2, 3, 4), homogeneous=FALSE)
CGstats(milkcomp, c(2, 3, 4), simplify=FALSE, homogeneous=FALSE)




gRim documentation built on Oct. 2, 2023, 9:06 a.m.