# Re: [R] lm without error

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

On Fri, Jun 11, 2010 at 5:28 PM, ivo welch <ivo.welch_at_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)

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

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help