I am using the Deming function provided by Terry T. on this archived r-help thread. I am comparing two methods, so I have data that look like this:
y x stdy stdx
1 1.2 0.23 0.67
2 1.8 0.05 0.89
4 7.5 1.13 0.44
... ... ... ...
I have done my Deming regression (also called "total least squares regression") and I get a slope and intercept. I would like to get a correlation coefficient so I've start calculating the $R^2$. I have manually entered the formula:
R2 <- function(coef,i,x,y,sdty){
predy <- (coef*x)+i
stdyl <- sum((y-predy)^2) ### The calculated std like if it was a lm (SSres)
Reelstdy <- sum(stdy) ### the real stdy from the data (SSres real)
disty <- sum((y-mean(y))^2) ### SS tot
R2 <- 1-(stdyl/disty) ### R2 formula
R2avecstdyconnu <- 1-(Reelstdy/disty) ### R2 with the known stdy
return(data.frame(R2, R2avecstdyconnu, stdy, Reelstdy))
}
This formula works and gives me output.
- Which of the two $R^2$s makes more sense? (I personally think of both of them as kind of biased.)
- Is there a way to get a correlation coefficient from a total least squared regression?
OUTPUT FROM THE DEMING REGRESSION:
Call:
deming(x = Data$DS, y = Data$DM, xstd = Data$SES, ystd = Data$SEM, dfbeta = T)
Coef se(coef) z p
Intercept 0.3874572 0.2249302 3.1004680 2.806415e-10
Slope 1.2546922 0.1140142 0.8450883 4.549709e-02
Scale= 0.7906686
>