[R] Splitting a Vector
Greg.Snow at imail.org
Thu Jan 6 19:09:20 CET 2011
I think that you are looking for the 'resid' and 'fitted' functions, these will give you the residuals and fitted values from an lm object (that added together gives the original response but are orthogonal to each other). Those values can then be assigned to a data frame or used by themselves.
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
greg.snow at imail.org
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Ben Ward
> Sent: Thursday, January 06, 2011 6:09 AM
> To: r-help
> Subject: [R] Splitting a Vector
> Hi all,
> I read in a text book, that you can examine a variable that is colinear
> with others, and giving different ANOVA output and explanatory power
> when ordered differently in the model forula, by modelling that
> explanatory variable, against the others colinear with it. Then, using
> that information to split the vector (explanatory variable) in
> into two new vectors, one should correspond to the fitted values and
> the residuals of the (I think you could call it nested) model. One
> vector therefore should be aligned with the subspacespace defined by
> other variables colinear with it, and the other will be residual, and
> orthogonal to the subspace of the colinear variables. Then by including
> these two variables in the origional model - the one that showed the
> order dependency, you can see how much explanatory power the othogonal
> part of the order dependent variable has, at different orders, and in
> principle it shouldn't change, but the vector made from the part
> co-aligned with the co-variates, will change as the order changes -
> explanatory power should decreace in ANOVA is it moves away from being
> the first explanatory variable in the model.
> Obviously finding the fitted model values and residual required to
> the vector in two is a simple lm() with the right variables. But how
> would I create two new vectors from this and append them to my
> dataframe? Is there a package or function specially designed with this
> sort of task in mind?
> Ben Ward.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help