The optional tolerance argument [Design Issues]

posted by ElMaestro  – Denmark, 2019-12-23 15:37 (1557 d 20:25 ago) – Posting: # 21021
Views: 5,541

Hi Hötzi,

❝ ❝ ❝ For observation 8 we have -3.608225e-16, I think,

❝ ❝ I think, is around the "effective zero" for fits in R at default settings on 64- and 32-bit systems.


❝ Yes, it is. ;-)

x    <- -3.608225e-16

❝ zero <- .Machine$double.eps

❝ all.equal(x, zero)

[1] TRUE

❝ zero

[1] 2.220446e-16


This comparison in your context is just a test if the difference is less than about 10-8 since there is an implied tolerance argument for all.equal, the square root of .Machine$double.eps

Effective zero residuals will be somewhat better than 10-8 in practice. They will depend on the approach used to find the solution; in lm I believe the approach is via a qr decomposition of the model matrix, and R by defualt has a tol argument in that function of 10-7 which lm may be leaning on.

Here's an example of a perfect fit, therefore having effective zero residuals:

a=c(rep(1,5), rep(2,5), rep(3,5))
b=c(rep("A",5), rep("B",5), rep("C",5))
M=lm(a~0+b)
resid(M)


It may actually not be the best example since the dependents are all representable inernally in R's (and computer's) binary.

Perhaps this makes a better point:

a=c(rep(pi,5), rep(sin(1.5+pi),5), rep(log(pi),5))
b=c(rep("A",5), rep("B",5), rep("C",5))
M=lm(a~0+b)
resid(M)

Pass or fail!
ElMaestro

Complete thread:

UA Flag
Activity
 Admin contact
22,957 posts in 4,819 threads, 1,636 registered users;
129 visitors (0 registered, 129 guests [including 15 identified bots]).
Forum time: 12:02 CET (Europe/Vienna)

With four parameters I can fit an elephant,
and with five I can make him wiggle his trunk.    John von Neumann

The Bioequivalence and Bioavailability Forum is hosted by
BEBAC Ing. Helmut Schütz
HTML5