[R] Splitting a Vector

Greg Snow 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
Intermountain Healthcare
greg.snow at imail.org
801.408.8111


> -----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
> question,
> into two new vectors, one should correspond to the fitted values and
> one
> the residuals of the (I think you could call it nested) model. One
> vector therefore should be aligned with the subspacespace defined by
> the
> other variables colinear with it, and the other will be residual, and
> so
> 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 -
> it's
> 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
> split
> 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?
> 
> Thanks,
> Ben Ward.
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list