censCor: Correlation

View source: R/censCor.R

censCorR Documentation

Correlation

Description

Computes the maximum likelihood estimate of the correlation between two possibly left-censored vectors. It is equivalent the the Pearson product-moment correlation for uncensored data.

Usage

censCor(x, y, Full = TRUE, na.rm = TRUE)

Arguments

x

any data that can be converted to a left-censored data object.

y

any data that can be converted to a left-censored data object.

Full

how to compute the mean and standard deviation of x and y. See Details.

na.rm

logical, remove missing values before computing the correlation?

Details

Full may be either logical or a numeric vector. If Full is TRUE, then estimate the means and standard deviations for x and y. If Full is FALSE, use the initial maximum likelihood estimate for those statistics. Otherwise Full can be a named vector containing mnx, the mean for x; sdx, the standard deviation for x; mny, the mean for y; sdy, the standard deviation for y. Full can be set to FALSE if the optimization fails at large censoring levels or to improve processing speed for large sample sizes.

Value

A vector with these names:

cor

the correlation between x and y.

mnx

the mean of x.

sdx

the standard deviation of x.

mny

the mean of y.

sdy

the standard deviation of y.

cx

the proportion of censored values of x.

cy

the proportion of censored values of y.

cxy

the proportion of censored values common to x and y.

n

the number of observations.

ll0

the log likelihood for cor=0

llcor

the log likelihood for cor=cor

References

Lyles, R.H., Williams, J.K., and Chuachoowong R., 2001, Correlating two viral load assays with known detection limits: Biometrics, v. 57 no. 4, p. 1238–1244.

Examples

# Simple no censoring
set.seed(450)
tmp.X <- rnorm(25)
tmp.Y <- tmp.X/2 + rnorm(25)
cor(tmp.X, tmp.Y)
censCor(tmp.X, tmp.Y)
# Some censoring
censCor(as.lcens(tmp.X, -1), as.lcens(tmp.Y, -1))


USGS-R/smwrQW documentation built on Oct. 11, 2022, 6:13 a.m.