covML: Maximum likelihood covariance estimate

View source: R/f_convenience_covML.R

covMLR Documentation

Maximum likelihood covariance estimate

Description

These functions complement the base R cov function by simplifying obtaining maximum likelihood (ML) covariance estimates (denominator n) instead of unbiased (UB) covariance estimates (denominator n-1). The function covML can be used to obtain ML estimates, the function covUBtoML transforms from UB to ML estimates, and the function covMLtoUB transforms from UB to ML estimates.

Usage

covML(x, ...)
covUBtoML(x, n, ...)
covMLtoUB(x, n, ...)

Arguments

x

A dataset

n

The sample size

...

Arguments sent to the cov function.

Author(s)

Sacha Epskamp <mail@sachaepskamp.com>

Examples

data("StarWars")
Y <- StarWars[,1:10]

# Unbiased estimate:
UB <- cov(Y)

# ML Estimate:
ML <- covML(Y)

# Check:
all(abs(UB - covMLtoUB(ML, nrow(Y))) < sqrt(.Machine$double.eps))
all(abs(ML - covUBtoML(UB, nrow(Y))) < sqrt(.Machine$double.eps))

psychonetrics documentation built on June 22, 2024, 10:29 a.m.