Learn R Programming

gRim (version 0.3.4)

cg-stats: 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)

Value

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

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.

Author

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

See Also

Examples

Run this code

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)



Run the code above in your browser using DataLab