Skip to contents

rho12() returns the residual response-response correlation from a bivariate Gaussian, bivariate lognormal, or bivariate Student-t drmTMB fit. For a bivariate Gaussian fit this is a response-scale residual correlation; for biv_lognormal() it is correlation of the log-response residuals, not a raw-scale correlation. For biv_student() it is the scatter/residual correlation; at finite shared nu, zero correlation does not imply independent margins. Use type = "link" for the Fisher-z-like linear predictor whose response transform is 0.999999 * tanh(eta).

Usage

rho12(object, ...)

# S3 method for class 'drmTMB'
rho12(object, newdata = NULL, type = c("response", "link"), ...)

Arguments

object

A drmTMB fit.

...

Reserved for future extractor options.

newdata

Optional data frame for prediction.

type

Scale of returned values: "response" for correlation values or "link" for Fisher-z-like linear predictors.

Value

A numeric vector of residual correlations, or Fisher-z-like linear predictors when type = "link".

Examples

set.seed(20260525)
n <- 36
x <- seq(-1, 1, length.out = n)
e1 <- rnorm(n)
e2 <- 0.4 * e1 + sqrt(1 - 0.4^2) * rnorm(n)
dat <- data.frame(
  y1 = 0.2 + 0.5 * x + e1,
  y2 = -0.1 + 0.3 * x + e2,
  x = x
)
fit <- drmTMB(
  bf(mu1 = y1 ~ x, mu2 = y2 ~ x, sigma1 = ~ 1, sigma2 = ~ 1, rho12 = ~ x),
  family = biv_gaussian(),
  data = dat
)
head(rho12(fit))
#> [1] 0.2914165 0.2982007 0.3049549 0.3116786 0.3183712 0.3250322
rho12(fit, newdata = data.frame(x = c(-0.5, 0, 0.5)))
#> [1] 0.3497212 0.4054372 0.4582953