Deming {MethComp} | R Documentation |
Regression with errors in both variables (Deming regression)
Description
The formal model underlying the procedure is based on a so called functional relationship:
x_i=\xi_i + e_{1i}, \qquad y_i=\alpha + \beta \xi_i + e_{2i}
with \mathrm{var}(e_{1i})=\sigma
,
\mathrm{var}(e_{2i})=\lambda\sigma
,
where \lambda
is the known variance ratio.
Usage
Deming(
x,
y,
vr = sdr^2,
sdr = sqrt(vr),
boot = FALSE,
keep.boot = FALSE,
alpha = 0.05
)
Arguments
x |
a numeric variable |
y |
a numeric variable |
vr |
The assumed known ratio of the (residual) variance of the |
sdr |
do. for standard deviations. Defaults to 1. |
boot |
Should bootstrap estimates of standard errors of parameters be done? If |
keep.boot |
Should the 4-column matrix of bootstrap samples be returned? If |
alpha |
What significance level should be used when displaying confidence intervals? |
Details
The estimates of the residual variance is based on a weighting of
the sum of squared deviations in both directions, divided by n-2
.
The ML estimate would use 2n
instead, but in the model we actually
estimate n+2
parameters — \alpha, \beta
and
the n
\xi s
.
This is not in Peter Sprent's book (see references).
Value
If boot==FALSE
a named vector with components
Intercept
, Slope
, sigma.x
, sigma.y
, where x
and y
are substituted by the variable names.
If boot==TRUE
a matrix with rows Intercept
,
Slope
, sigma.x
, sigma.y
, and colums giving the estimates,
the bootstrap standard error and the bootstrap estimate and c.i. as the 0.5,
\alpha/2
and 1-\alpha/2
quantiles of the sample.
If keep.boot==TRUE
this summary is printed, but a matrix with columns
Intercept
,
Slope
, sigma.x
, sigma.y
and boot
rows is returned.
Author(s)
Bendix Carstensen, Steno Diabetes Center, bendix.carstensen@regionh.dk, http://BendixCarstensen.com
References
Peter Sprent: Models in Regression, Methuen & Co., London 1969, ch.3.4.
WE Deming: Statistical adjustment of data, New York: Wiley, 1943.
Examples
# 'True' values
M <- runif(100,0,5)
# Measurements:
x <- M + rnorm(100)
y <- 2 + 3 * M + rnorm(100,sd=2)
# Deming regression with equal variances, variance ratio 2.
Deming(x,y)
Deming(x,y,vr=2)
Deming(x,y,boot=TRUE)
bb <- Deming(x,y,boot=TRUE,keep.boot=TRUE)
str(bb)
# Plot data with the two classical regression lines
plot(x,y)
abline(lm(y~x))
ir <- coef(lm(x~y))
abline(-ir[1]/ir[2],1/ir[2])
abline(Deming(x,y,sdr=2)[1:2],col="red")
abline(Deming(x,y,sdr=10)[1:2],col="blue")
# Comparing classical regression and "Deming extreme"
summary(lm(y~x))
Deming(x,y,vr=1000000)