convert_betaXA_to_betaXB: Convert parameters between equivalent design matrices

View source: R/convert_param.R

convert_betaXA_to_betaXBR Documentation

Convert parameters between equivalent design matrices

Description

This function allows for the conversion of parameters between design matrices that are equivalent (same data, same rank) but that have been parameterized differently. This is usefull to find conversion of parameters for different contrasts matrices (e.g. contrast treament vs contrast sum), including conversion between poly(..., raw = FALSE) and poly(..., raw = TRUE).

Usage

convert_betaXA_to_betaXB(XA, XB, betaXA)

Arguments

XA

The orignal design matrix

XB

A design matrix equivalent to the original design matrix but with different parameterization

betaXA

The vector of coefficients for the original design matrix

Value

The vector of coefficients for the design matrix XB

Examples

xa <- model.matrix(object = ~ x, data = data.frame(x = factor(c("A", "B", "C"))),
                   contrasts.arg = list(x = "contr.treatment"))
xb <- model.matrix(object = ~ x, data = data.frame(x = factor(c("A", "B", "C"))),
                   contrasts.arg = list(x = "contr.sum"))
beta_xa <- c(0.5, 2, 1)
beta_xb <- convert_betaXA_to_betaXB(XA = xa, XB = xb, betaXA = beta_xa)
## test that we get same predictions as we should:
xa %*% beta_xa
xb %*% beta_xb


courtiol/LM2GLMM documentation built on July 3, 2022, 7:42 a.m.