errors icon indicating copy to clipboard operation
errors copied to clipboard

Handle covariance matrix with vector input

Open StaffanBetner opened this issue 2 years ago • 2 comments

Functionality like this would be useful to have available:

lm(formula = mpg ~ cyl + wt, data = mtcars) |> coef() -> coefficients
lm(formula = mpg ~ cyl + wt, data = mtcars) |> vcov() -> covar_mat

set_errors(coefficients, value = covar_mat) -> coefficients_covar

It is a bit cumbersome to set the covariances one by one.

StaffanBetner avatar Sep 12 '23 09:09 StaffanBetner

What do you mean "one by one"?

Enchufa2 avatar Sep 12 '23 09:09 Enchufa2

Maybe something like

covar(x) <- vcov(fit)
set_covar(x, value=vcov(fit))

could be handled as special cases when the provided argument is detected as a valid covariance matrix?

The thing is that the output of this should be a list, which may be confusing for set_covar, but it's not acceptable for covar<- I think, because it's effectively changing the object. See this discussion about wrapping linear models.

Enchufa2 avatar Sep 12 '23 09:09 Enchufa2