[R] Linear regression equation and coefficient matrix
Greg.Snow at imail.org
Thu Aug 19 18:40:23 CEST 2010
Here is a quick example:
c1 <- cor(iris[,-5])
s1 <- sqrt(diag(var(iris[,-5])))
betas <- diag( s1 ) %*% c1 %*% diag( 1/s1 )
# now compare:
coef( lm( Sepal.Length ~ Sepal.Width, data=iris ) )
But if you cannot work that out on your own, then you really should review linear algebra and linear model theory.
Also when dealing with us "absent minded professor" types (I now have adjunct status at 2 universities, can I rationalize being twice as absent minded now?) it is best to include some context in your post (quote some of the previous conversation) to help us remember which of many discussions we have been part of recently you are asking about.
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
greg.snow at imail.org
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of ashz
> Sent: Thursday, August 19, 2010 3:02 AM
> To: r-help at r-project.org
> Subject: Re: [R] Linear regression equation and coefficient matrix
> Dear Greg,
> Thanks for the tip. As I am new in R can you please provide me a script
> do to so. It will help my learning process.
> View this message in context: http://r.789695.n4.nabble.com/Linear-
> Sent from the R help mailing list archive at Nabble.com.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help