r2mlm icon indicating copy to clipboard operation
r2mlm copied to clipboard

Error when using random_covs23

Open jason-struck opened this issue 2 years ago • 0 comments

The r2mlm3_manual() function has a typo when calculating the variance of random_covs23.

Instead of

var_randomcovs23 <- var(cbind(data[, c(random_covs23)]), na.rm = T)

it should read (note the addition of the 1,)

var_randomcovs23 <- var(cbind(1, data[, c(random_covs23)]), na.rm = T)

to match the line calculating the variance of random_covs13

var_randomcovs13 <- var(cbind(1, data[, c(random_covs13)]), na.rm = T)

Otherwise, the function will return the error

Error in t(v23) %*% psi23 : non-conformable arguments

from the line

l2var <- (t(gamma_2) %*% phi_2 %*% gamma_2) + (t(v23) %*% psi23 + 2 * (t(r23) %*% kappa23)) + Tau12[1, 1]

since v23 (created from var_randomcovs23) will be one column short.

jason-struck avatar Nov 28 '22 20:11 jason-struck