3
$\begingroup$

I want to perform a univariate regression but with substantial measurement error in both $x$ and $y$. I therefore want to try orthogonal regression with R. The best answer to my question so far have been this: How to perform orthogonal regression (total least squares) via PCA?

However, what I need is to pick out the intercept for the regression and its standard error. I'm not sure if/how this can be done via the PCA approach.

$\endgroup$

1 Answer 1

2
$\begingroup$

I suggest to use package deming. Here is an example of Deming regression using the package:

library(deming)
fit.lm <- lm(aes ~ aas, data=arsenate)

fit.deming <- deming(aes ~ aas, data=arsenate, stdpat = c(1, 0, 1, 0))
print(fit.deming)
#Call:
#deming(formula = aes ~ aas, data = arsenate, stdpat = c(1, 0,     1, 0))
#
#n= 30
#               Coef  se(coef) lower 0.95 upper 0.95
#Intercept 0.4293665 0.3079456 -0.1741959   1.032929
#Slope     0.8759571 0.1180054  0.6446708   1.107244
#
#   Scale= 0.7899665 

fit.errors <- deming(aes ~ aas, data=arsenate, xstd=se.aas, ystd=se.aes)
print(fit.errors)
#Call:
#deming(formula = aes ~ aas, data = arsenate, xstd = se.aas, ystd = se.aes)
#
#n= 30
#               Coef  se(coef) lower 0.95 upper 0.95
#Intercept 0.1064481 0.2477071 -0.3790489  0.5919451
#Slope     0.9729928 0.1429651  0.6927863  1.2531993
#
#   Scale= 1.165495 

plot(aes ~ aas, data=arsenate)
abline(fit.lm, lty = 2)
abline(fit.deming, col = "red")
abline(fit.errors, col = "blue")

legend("topleft", legend = c("Deming", "with measured errors","OLS"), 
       lty = c(1, 1:2), col = c("red", "blue","black"))

resulting plot

Apparently the Jackknife technique is used to get the standard errors. You probably should read the package vignette and have a look at the references therein.

$\endgroup$
1
  • $\begingroup$ Thank you! In case someone asks in future, I then used the following to extract intercept and se of intercept. Intercept = fit.deming$coefficients[1] . se = sqrt(diag(fit.deming$variance))[1] $\endgroup$
    – user90622
    Commented Sep 29, 2015 at 7:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.