r2mlm
r2mlm copied to clipboard
Error when using random_covs23
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.