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?
1 Answer
Reset to default 1Currently, 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 themlm
needs to be turned into a suitably named vector - the corresponding
estfun
computation needs to be adjusted correspondingly (seesandwich:::estfun.mlm
) - the
objfun
computation should be checked but I guess this works ok - when calling
mob()
the control optionytype = "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
版权声明:本文标题:r - is it posible to fit a multivariate linear model using lmtree? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744278453a2598532.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论