Description Usage Arguments Details Value Author(s) References See Also Examples
The function makes a regression of y on x, assuming that both x and y are measured with error. This problem only has an analytical solution if the ratio of the variances is known, hence this is required as an input parameter.
1 2 3 |
x |
numerical variable. |
y |
numerical 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? |
The formal model underlying the procedure is based on a so called functional relationship:
x_i=k_i + e_1i, y_i=alpha + beta k_i + e_2i
with var(e_1i)=s, var(e_2i)=VR*s, where VR is the known variance ratio.
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 k_i's.
This is not in Peter Sprent's book (see references).
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.
Bendix Carstensen, Steno Diabetes Center, bxc@steno.dk, http://BendixCarstensen.com.
Peter Sprent: Models in Regression, Methuen & Co., London 1969, ch.3.4.
WE Deming: Statistical adjustment of data, New York: Wiley, 1943. [This is a reference taken from a reference list — I never saw the book myself].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # '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, resp. 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)
|
Loading required package: nlme
Intercept Slope sigma.x sigma.y
0.8790873 3.3424617 1.1140694 1.1140694
Intercept Slope sigma.x sigma.y
1.252795 3.206296 1.069370 1.512318
y = alpha + beta* x
Estimate S.e.(boot) 50% 2.5% 97.5%
Intercept 0.8790873 0.78192861 0.8513765 -0.7698304 2.250194
Slope 3.3424617 0.24615506 3.3430884 2.9218856 3.870070
sigma.x 1.1140694 0.07038687 1.1008308 0.9691499 1.243525
sigma.y 1.1140694 0.07038687 1.1008308 0.9691499 1.243525
Estimate S.e.(boot) 50% 2.5% 97.5%
Intercept 0.8790873 0.79163147 0.8520398 -0.8987695 2.294932
Slope 3.3424617 0.26103801 3.3399717 2.9293248 3.963580
sigma.x 1.1140694 0.07109705 1.0971917 0.9598462 1.236436
sigma.y 1.1140694 0.07109705 1.0971917 0.9598462 1.236436
num [1:1000, 1:4] 1.8767 0.7007 1.0333 1.021 -0.0699 ...
- attr(*, "dimnames")=List of 2
..$ : NULL
..$ : chr [1:4] "Intercept" "Slope" "sigma.x" "sigma.y"
Call:
lm(formula = y ~ x)
Residuals:
Min 1Q Median 3Q Max
-7.1383 -2.2684 -0.1284 2.0472 6.8795
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 4.0960 0.5700 7.186 1.32e-10 ***
x 2.1703 0.1719 12.628 < 2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 3.201 on 98 degrees of freedom
Multiple R-squared: 0.6194, Adjusted R-squared: 0.6155
F-statistic: 159.5 on 1 and 98 DF, p-value: < 2.2e-16
Intercept Slope sigma.x sigma.y
4.095971994 2.170344488 0.003200742 3.200741562
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.