I was wondering how to get the actual components from predict(..., type = 'term)
. I know that if I take the rowSums
and add the attr(,"constant")
value to each, I will get the predicted values but what I'm not sure about is how this attr(,"constant")
is split up between the columns. All in all, how do I alter the matrix returned by predict
so that each value represents the model coefficient multiplied by the prediction data. The result should be a matrix (or data.frame) with the same dimensions as returned by predict
but the rowSums
automatically add up to the predicted values with no further alteration needed.
Note: I realize I could probably take the coefficients produced by the model and matrix multiply them with my prediction matrix but I'd rather not do it that way to avoid any problems that factors could produce.
Edit: The goal of this question is not to produce a way of summing the rows to get the predicted values, that was just meant as a sanity check.
If I have the equation y = 2*a + 3*b + c and my predicted value is 500, I want to know what 2*a was, what 3*b was, and what c was at that particular point. Right now I feel like these values are being returned by predict
but they've been scaled. I need to know how to un-scale them.