R Under development (unstable) (2024-06-25 r86831 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > # > # Tests of Thiel-Sen regresion > # > library(deming) > > # Data from Sen, JASA 1968 > # Note that his confidence interval is incorrect in the paper, since > # his list of values for (y_i - y_j)/(t_i - t_j) has mistakes > # He also does not use the large sample formula, but rather a table from > # Kendall for the width of the interval > sen <- data.frame(t=c(1, 2, 3, 4, 10, 12, 18), + y=c(9, 15, 19, 20, 45, 55, 78)) > fit <- theilsen(y ~ t, data=sen, conf=.93) > all.equal(coef(fit), c("(Intercept)"=6, "t"=4)) [1] TRUE > all.equal(fit$ci[2,], c(26/7, 35/8)) [1] TRUE > > # The data is strictly monotone, so the symmetric solution = usual one > fit2 <- theilsen(y ~ t, data=sen, symmetric=TRUE) > all.equal(coef(fit2), coef(fit)) [1] TRUE > > > # How do the symmetric and regular compare? > fcoef <- matrix(0, 7, 3) > for (i in 1:7) { + tfit1 <- theilsen(new.lot ~ old.lot, ferritin, subset=(period==i)) + tfit2 <- theilsen(new.lot ~ old.lot, ferritin, subset=(period==i), + symmetric=TRUE) + tfit3 <- pbreg(new.lot ~ old.lot, ferritin, subset=(period==i)) + fcoef[i,] <- c(tfit1$coef[2], tfit2$coef[2], tfit3$coef[2]) + } > # For this set Passing-Bablock and STS agree > # (When the slope is exactly 1 they must be identical, and these are close to 1). > all.equal(fcoef[,2], fcoef[,3]) [1] TRUE > > proc.time() user system elapsed 0.28 0.10 0.34