[R] Fitting a line to a qqplot's points?

Uwe Ligges ligges at statistik.uni-dortmund.de
Fri Mar 23 08:35:14 CET 2007



Uwe Ligges wrote:
> 
> 
> Paul Lynch wrote:
>> I've made some normal plots of my data using qqplot, and now
>> I would like to fit a line to the points on the plot and
>> check the correlation coefficient to have a more objective measure
>> of how straight the line is.  Is there a simple way of doing that?
>> (I'm still pretty new to R.)
> 
> 
> See ?qqplot and what its value is:
> 
>  x <- rnorm(10)
>  y <- rnorm(10)
>  qq <- qqplot(x, y)
>  cor(qq$x, qq$y)

I forgot to finish:

for fitting a line based in least squares, you can go on:

fit <- lm(y ~ x, data = qq)
summary(fit)
abline(fit)


Uwe Ligges



More information about the R-help mailing list