Sorry, I forgot to reply to all..... See Patrick suggestion below. I also got another idea from Julian Faraway's book on R
> res <- rep(NA,153) > res[as.numeric(row.names(na.omit(airquality)))] <- gl$res where gl was a regression and airquality the data. Thanks, Fabian -----Original Message----- From: Patrick Burns [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 31, 2007 12:55 PM To: Garavito,Fabian Subject: Re: [R] Error message when running lm() with na.action=NULL Garavito,Fabian wrote: > I was trying to get a vector of residuals where NA would be assigned > to the lm residual vector (in this case reg_test$residuals) whenever > NA was present in the sample. For instance, > > Obs fitted residual > O1 f1 r1 > O2 f2 r2 > NA NA NA > > All I am getting is residual vectors for Non Missing observations > (i.e. the dimension of the residual vector could be different from > that of the response vector) > Makes sense. I think you need to do it yourself. Perhaps something like (untested): test.nona <- na.omit(test) mod <- lm(y | ., data=test.nona) allresids <- rep(NA, nrow(test)) allresids[-attr(test.nona, 'na.action')] <- residuals(mod) Putting this into a function would probably be the way to go. > Thank you very much for your help. I used to use R a few years ago, > but I have not used it in a long while. Moreover, I had been using SAS > in the last year and going back to R has been quite difficult. I was > actually looking for a good book in R. Any ideas? > 'good' is questionable and not exactly about R, but S Poetry is at least free. Venables and Ripley is a common citation. Peter Dalgaard's book is given good reviews. There is a book that is aimed more towards finance (which I'm assuming you are in) but I've forgotten what it is nor have I seen it. Searching Amazon should probably show you a lot of your choices, and I haven't heard of any books that generate aversion. Pat > Fabian > > > -----Original Message----- > From: Patrick Burns [mailto:[EMAIL PROTECTED] > Sent: Tuesday, July 31, 2007 11:39 AM > To: Garavito,Fabian > Subject: Re: [R] Error message when running lm() with na.action=NULL > > Doing > > na.action=NULL > > means that you need to get rid of missing values yourself > from your data, which I'm guessing you haven't done. > > > Patrick Burns > [EMAIL PROTECTED] > +44 (0)20 8525 0696 > http://www.burns-stat.com > (home of S Poetry and "A Guide for the Unwilling S User") > > Garavito,Fabian wrote: > > >Hi there, > > > >I am trying to run a liner regression using lm with na.action = NULL, > but I > >am getting an error message. Any ideas as to why this may be happening? > >Please see code and error message below: > > > > > > > >>reg_test<-lm(yy~.,data=test,na.action=NULL) > >> > >> > >Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : > > NA/NaN/Inf in foreign function call (arg 4) > > > > > >This message and any attachment are confidential and may be > privileged or otherwise protected from disclosure. If you are not the > intended recipient, please telephone or email the sender and delete > this message and any attachment from your system. If you are not the > intended recipient you must not copy this message or attachment or > disclose the contents to any other person. Nothing contained in the > attached email shall be regarded as an offer to sell or as a > solicitation of an offer to buy any services, funds or products or an > expression of any opinion or views of the firm or its employees. > Nothing contained in the attached email shall be deemed to be an > advise of, or recommendation by, the firm or its employees. No > representation is made as to accuracy, completeness, reliability or > appropriateness of the information contained in the attached email. > > > > > > > [[alternative HTML version deleted]] > > > >______________________________________________ > >R-help@stat.math.ethz.ch 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. > > > > > > > > > > > > This message and any attachment are confidential and may be privileged > or otherwise protected from disclosure. If you are not the intended > recipient, please telephone or email the sender and delete this > message and any attachment from your system. If you are not the > intended recipient you must not copy this message or attachment or > disclose the contents to any other person. Nothing contained in the > attached email shall be regarded as an offer to sell or as a > solicitation of an offer to buy any services, funds or products or an > expression of any opinion or views of the firm or its employees. > Nothing contained in the attached email shall be deemed to be an > advise of, or recommendation by, the firm or its employees. No > representation is made as to accuracy, completeness, reliability or > appropriateness of the information contained in the attached email. [[alternative HTML version deleted]] ______________________________________________ R-help@stat.math.ethz.ch 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.