Re: [R] lm without error

From: Joris Meys <jorismeys_at_gmail.com>
Date: Sat, 12 Jun 2010 02:26:10 +0200

did it again...

it has to be
> getOut <- which(colSums(is.na(y))==dim(y)[1])
> lm( y[,-getOut] ~ x )

off course.
Cheers
Joris

On Sat, Jun 12, 2010 at 2:22 AM, Joris Meys <jorismeys_at_gmail.com> wrote:
> On Fri, Jun 11, 2010 at 5:28 PM, ivo welch <ivo.welch@gmail.com> wrote:
>> thanks, everybody.
>>
>> joris---let me disagree with you, please.  there are so many
>> possibilities of how lm.fit could fail that by the time I am done with
>> pre-checking, I may as well write my own lm() routine.
> If we all would agree, life would be boring, no? ;-) I see your point,
> but the thing is that if the function returns only NA coefficients
> (and it can't do anything else than that, as a fit is mathematically
> not possible), you have literally no information about what went
> wrong. If I fit can't be done, I'd like to know why it happened, and
> not just get the answer "Not Available". That's an error message too.
>
> Checking your data before doing an analysis is what we call "Good
> Statistical Practice". Using a model on data you didn't check before
> is like starting to drive to another country without checking which
> direction you have to go. Pretty unlikely you're going to arrive at
> the right spot...
>
> This said, you gave us what we need.
>>  y= matrix(rnorm(1000), nrow=10, ncol=100)
>>  y[,28]= rep(NA, 10)
>>  x=rnorm(10)
>>  lm( y ~ x )
>>       ## now what do you do?  hunt for which column was responsible?
> I'd do :
> y= matrix(rnorm(1000), nrow=10, ncol=100)
>  y[,28]= rep(NA, 10)
>  x=rnorm(10)
>
> getOut <- which(colSums(is.na(y))==dim(y)[1])
>
>  lm( y[-getOut] ~ x )
>
> Cheers
> Joris
> --
> Joris Meys
> Statistical consultant
>
> Ghent University
> Faculty of Bioscience Engineering
> Department of Applied mathematics, biometrics and process control
>
> tel : +32 9 264 59 87
> Joris.Meys_at_Ugent.be
> -------------------------------
> Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
>

-- 
Joris Meys
Statistical consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
Joris.Meys_at_Ugent.be
-------------------------------
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

______________________________________________
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 Sat 12 Jun 2010 - 00:28:15 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 Sat 12 Jun 2010 - 00:50:30 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