[R] lm output

Brecknock, Peter Peter.Brecknock at bp.com
Sat Oct 10 00:04:58 CEST 2009


Fair point. 

Thanks.

-----Original Message-----
From: David Winsemius [mailto:dwinsemius at comcast.net] 
Sent: Friday, October 09, 2009 5:02 PM
To: Brecknock, Peter
Cc: Daniel Malter; r-help at r-project.org
Subject: Re: [R] lm output


On Oct 9, 2009, at 5:45 PM, Brecknock, Peter wrote:

> Daniel
>
> Thanks very much for the reply.
>
> If the data fails the underlying assumptions of regression wouldn't  
> it make sense to suppress all the output and not just the slope  
> coefficient?
>
> Incidently, if I run this simple example in Excel it returns the  
> slope as 0. Intuitively, this makes sense to me ... the best  
> estimate of y would be its mean for any value of x.

R gave you the best estimate for y. It was Excel that gave you an  
estimate for something for which it had no basis. There is no mean of  
dy/dx because dx=0.

-- 
David.
>
> Kind regards
>
> Pete
>
>
> -----Original Message-----
> From: Daniel Malter [mailto:daniel at umd.edu]
> Sent: Friday, October 09, 2009 4:24 PM
> To: Brecknock, Peter; r-help at r-project.org
> Subject: AW: [R] lm output
>
> That comes out as an NA because X'X is not invertible because it is  
> not full
> rank (one row/column is a linear combination of the other(s)). And  
> that
> means there is no unique solution to the system.
>
> y=c(10,12,17)
> x=c(5,5,5)
> X=cbind(1,x)
>
> X
> t(X)%*%X
> solve(t(X)%*%X)
>
> Therefore, nope, there is now way to make this come out as a zero,  
> because
> it fails the very assumptions of regression analysis.
>
> HTH,
> Daniel
>
> -------------------------
> cuncta stricte discussurus
> -------------------------
>
> -----Ursprüngliche Nachricht-----
> Von: r-help-bounces at r-project.org [mailto:r-help-bounces at r- 
> project.org] Im
> Auftrag von Brecknock, Peter
> Gesendet: Friday, October 09, 2009 5:12 PM
> An: r-help at r-project.org
> Betreff: [R] lm output
>
> Hi All
>
> I am running a linear regression using the lm object.
>
> In the event that my independent variable is the same across all
> observations the regression slope is returned as an NA.
>
> For example, if I have the following
>
> y=c(10,12,17)
> x=c(5,5,5)
>
> lm = lm(y~x)
> produces the following
>
> Coefficients:
> (Intercept)            x
>      13           NA
>
> Other than post-processing the results, is there a way to output the  
> slope
> as 0 rather than NA?
>
> Thanks
>
> Pete
>
>
> This e-mail may contain confidential or proprietary information  
> belonging to
> the BP group and is intended only for the use of the recipients  
> named above.
> If you are not the intended recipient, please immediately notify the  
> sender
> and either delete this email or return to the sender immediately.   
> You may
> not review, copy or distribute this email.  Within the bounds of  
> law, this
> part of BP retains all emails and IMs and may monitor them to ensure
> compliance with BP's internal policies and for other legitimate  
> business
> purposes.
>
>
> 	[[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.
>
> ______________________________________________
> 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.

David Winsemius, MD
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list