admin管理员组

文章数量:1401476

I want to fit a lmtree where the response is multivariable. You know that you can fit a Multivariate Multiple Regression using lm function as follows:

lm(cbind(Y1, Y2) ~ X1+X2+X3, data = my_df)

so I tried to do this in the context of lmtree:

lmtree(cbind(Y1,Y2) ~ Z1 | X1+X2+X3,data = my_df)

but it seems it is not implemented, I got this error message:

Error in x[, !is.na(z$coefficients), drop = FALSE] : 
  (subscript) logical subscript too long

It is possible to fit a lmtree with a multivariable response? if so, what is the correct way to specify it?

I want to fit a lmtree where the response is multivariable. You know that you can fit a Multivariate Multiple Regression using lm function as follows:

lm(cbind(Y1, Y2) ~ X1+X2+X3, data = my_df)

so I tried to do this in the context of lmtree:

lmtree(cbind(Y1,Y2) ~ Z1 | X1+X2+X3,data = my_df)

but it seems it is not implemented, I got this error message:

Error in x[, !is.na(z$coefficients), drop = FALSE] : 
  (subscript) logical subscript too long

It is possible to fit a lmtree with a multivariable response? if so, what is the correct way to specify it?

Share Improve this question asked Mar 23 at 17:08 Nicolas MolanoNicolas Molano 7464 silver badges19 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

Currently, lmtree() is only geared towards univariate response variables and multivariate responses are not supported.

In principle, the MOB approach can also be used for multivariate linear models, though. Using the partykit:::lmfit() function as a starting point would also work but:

  • the matrix of coefficients from the mlm needs to be turned into a suitably named vector
  • the corresponding estfun computation needs to be adjusted correspondingly (see sandwich:::estfun.mlm)
  • the objfun computation should be checked but I guess this works ok
  • when calling mob() the control option ytype = "matrix" needs to be specified

If there are no other problems which require adaptation of the code, then it might also be possible to wire this into lmtree() but I haven't got the time to check this now.

本文标签: ris it posible to fit a multivariate linear model using lmtreeStack Overflow