errors
errors copied to clipboard
Handle covariance matrix with vector input
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.
What do you mean "one by one"?
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.