Re: [R] lm and NA

From: Rolf Turner <r.turner_at_auckland.ac.nz>
Date: Tue, 01 Jul 2008 09:41:24 +1200

On 1/07/2008, at 9:30 AM, Peter Alspach wrote:

> Georg
>
> ?lm suggests "'na.exclude' can be useful"

        But he (Georg) did indeed use na.action=na.exclude !!!

        So that's not the problem/solution.

	The difference between what he did and what you did is
	essentially that you (correctly) used the ***resid()*** function to
	extract the residuals.  Whereas Georg used (whatever)$residuals
	--- as one is repeatedly advised ***NOT*** to do!

		cheers,

			Rolf Turner

>
> Thus:
>
>> round(resid(lm(c(1:4,NA,9)~c(3:7,NA), na.action=na.exclude)), 5)
> 1 2 3 4 5 6
> 0 0 0 0 NA NA
>
> HTH ....
>
> Peter Alspach
>
>
>> -----Original Message-----
>> From: r-help-bounces_at_r-project.org
>> [mailto:r-help-bounces_at_r-project.org] On Behalf Of Georg Ehret
>> Sent: Tuesday, 1 July 2008 9:07 a.m.
>> To: r-help
>> Subject: [R] lm and NA
>>
>> Dear R community, Can I please get some advice on the
>> following: I wish
>> to obtain a list of residuals, padded by NAs for NAs in my
>> source data. I tried several options of "na.action", but did
>> not succeed...
>>
>> Example: I would like to get "0,0,0,0,NA,NA":
>>> a
>> [1] 1 2 3 4 NA 9
>>> b
>> [1] 3 4 5 6 7 NA
>>> lm(a~b)$residuals
>> 1 2 3 4
>> 0 0 0 0
>>> lm(a~b,na.action=na.exclude)$residuals
>> 1 2 3 4
>> 0 0 0 0
>>
>> Thank you and best regards!
>> Georg.
>> **************************
>> Georg Ehret
>> Johns Hopkins
>> Baltimore, USA
>>
>> [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> 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.
>>
>
> The contents of this e-mail are privileged and/or confidential to
> the named
> recipient and are not to be used by any other person and/or
> organisation.
> If you have received this e-mail in error, please notify the
> sender and delete
> all material pertaining to this e-mail.
>
> ______________________________________________
> 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.
######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}

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. Received on Mon 30 Jun 2008 - 21:45:02 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 01 Jul 2008 - 00:31:42 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive