Re: [Rd] make check-all fails (PR#7784)

2005-04-10 Thread Peter Dalgaard
M. Edward (Ed) Borasky [EMAIL PROTECTED] writes:

 [EMAIL PROTECTED] wrote:
 
 This looks more serious. 100 times machine precision is quite a large
 margin in these matters. Could you perhaps stick in a printout of the
 two terms and their difference?
 
 I have an ATLAS build on AMD64 and it passes all the checks, but it is
 using ATLAS 3.7.8, so you might want to try an upgrade.
 
 
 Attached ... you actually weren't very far off:
...
  print (f2[common])
  1  2  3  4  7  8  9 
  32.971099  37.113091  27.472204  16.891921  32.320560  -6.091053 -26.953745 
 12 13 14 15 16 17 18 
...
  41.798651  40.734935  40.285066  24.876177   8.442082  46.373463  72.652242 
118120121122123124125 
  65.983901  81.140660 101.389698  92.784665  86.803528  66.813059  76.464152 
126127128129130131132 
  85.562396  80.164720  55.046451  22.602751  38.602215  35.466808  28.565003 
133134135136137138139 
  30.487396  27.515347  17.475536  49.119123  11.994736  14.701687  49.795201 
140141142143144145146 
   5.664599  24.711067  20.426534  53.013693   5.758723  19.324367  41.190110 
147148149151152153 
  14.189862 -19.275130  35.155615  20.525269  40.584670  18.702940 
...

Aha! 100 times machine precision in not all that much when the numbers
themselves are in double digits. In fact, one is over 100. The case
that triggers the failure is #149

   147   148   149   151   152 
 -1.598721e-14 -1.065814e-14 -2.842171e-14 -1.065814e-14 -2.131628e-14 

which is 2 ULP off by my reckoning (scaling 35.15 to be between 0.5
and 1 makes the error 2.842e-14/64 =  4.44e-16 and [EMAIL PROTECTED]
is 2.22e-16).

So again, we might be too strict. I just wonder why we haven't heard
of this on any other platforms.

-- 
   O__   Peter Dalgaard Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics 2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark  Ph: (+45) 35327918
~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907

__
R-devel@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] make check-all fails (PR#7784)

2005-04-10 Thread p . dalgaard
Peter Dalgaard [EMAIL PROTECTED] writes:

 Aha! 100 times machine precision in not all that much when the numbers
 themselves are in double digits. In fact, one is over 100. The case
 that triggers the failure is #149
 
147   148   149   151   152 
  -1.598721e-14 -1.065814e-14 -2.842171e-14 -1.065814e-14 -2.131628e-14 
 
 which is 2 ULP off by my reckoning (scaling 35.15 to be between 0.5
 and 1 makes the error 2.842e-14/64 =  4.44e-16 and [EMAIL PROTECTED]
 is 2.22e-16).
 
 So again, we might be too strict. I just wonder why we haven't heard
 of this on any other platforms.

I've fixed the precision requirement (for this and the reg-tests-1
issue) in the repository and what should become tomorrow's beta
version.

-- 
   O__   Peter Dalgaard Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics 2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark  Ph: (+45) 35327918
~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907

__
R-devel@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] make check-all fails (PR#7784)

2005-04-10 Thread M. Edward (Ed) Borasky
Peter Dalgaard wrote:
M. Edward (Ed) Borasky [EMAIL PROTECTED] writes:
 

[EMAIL PROTECTED] wrote:
   

This looks more serious. 100 times machine precision is quite a large
margin in these matters. Could you perhaps stick in a printout of the
two terms and their difference?
I have an ATLAS build on AMD64 and it passes all the checks, but it is
using ATLAS 3.7.8, so you might want to try an upgrade.
 

Attached ... you actually weren't very far off:
   

...
 

print (f2[common])
 

1  2  3  4  7  8  9 
32.971099  37.113091  27.472204  16.891921  32.320560  -6.091053 -26.953745 
   12 13 14 15 16 17 18 
   

...
 

41.798651  40.734935  40.285066  24.876177   8.442082  46.373463  72.652242 
  118120121122123124125 
65.983901  81.140660 101.389698  92.784665  86.803528  66.813059  76.464152 
  126127128129130131132 
85.562396  80.164720  55.046451  22.602751  38.602215  35.466808  28.565003 
  133134135136137138139 
30.487396  27.515347  17.475536  49.119123  11.994736  14.701687  49.795201 
  140141142143144145146 
 5.664599  24.711067  20.426534  53.013693   5.758723  19.324367  41.190110 
  147148149151152153 
14.189862 -19.275130  35.155615  20.525269  40.584670  18.702940 
   

...
Aha! 100 times machine precision in not all that much when the numbers
themselves are in double digits. In fact, one is over 100. The case
that triggers the failure is #149
 

 147   148   149   151   152 
-1.598721e-14 -1.065814e-14 -2.842171e-14 -1.065814e-14 -2.131628e-14 
   

which is 2 ULP off by my reckoning (scaling 35.15 to be between 0.5
and 1 makes the error 2.842e-14/64 =  4.44e-16 and [EMAIL PROTECTED]
is 2.22e-16).
So again, we might be too strict. I just wonder why we haven't heard
of this on any other platforms.
 

I think it's an Atlas issue, and possibly an Atlas/Athlon32 issue. The 
built-in BLAS in R-beta don't show this. Is there enough detail on 
what's happening available for me to take this to the Atlas folks? 
They've done a lot of work, including assembler code, on Athlons and 
their 64-bit descendents. My main system, where I've been doing this 
testing, is a rather old Athlon T-Bird.

Incidentally, even though Atlas does have most parameters set to 
pre-defined values for the Athlon/Linux, it does in fact make *some* 
decisions when it compiles, which may be why I'm showing this and nobody 
else is. I'm using Gentoo Linux, which recompiles nearly everything from 
source, including Atlas and R, when it does an install. Most of the 
other Linux distros have pre-compiled binaries for the various packages. 
Debian, for example, has pre-compiled Atlas libraries for P3, P4 and Athlon.

__
R-devel@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] make check-all fails (PR#7784)

2005-04-10 Thread Prof Brian Ripley
On Sun, 10 Apr 2005, M. Edward (Ed) Borasky wrote:
Peter Dalgaard wrote:
M. Edward (Ed) Borasky [EMAIL PROTECTED] writes:

[EMAIL PROTECTED] wrote:

This looks more serious. 100 times machine precision is quite a large
margin in these matters. Could you perhaps stick in a printout of the
two terms and their difference?
I have an ATLAS build on AMD64 and it passes all the checks, but it is
using ATLAS 3.7.8, so you might want to try an upgrade.

Attached ... you actually weren't very far off:
...
print (f2[common])
1  2  3  4  7  8 
9 32.971099  37.113091  27.472204  16.891921  32.320560  -6.091053 
-26.95374512 13 14 15 16 
17 18 
...
41.798651  40.734935  40.285066  24.876177   8.442082  46.373463 
72.652242   118120121122123124 
125 65.983901  81.140660 101.389698  92.784665  86.803528  66.813059 
76.464152   126127128129130131 
132 85.562396  80.164720  55.046451  22.602751  38.602215  35.466808 
28.565003   133134135136137138 
139 30.487396  27.515347  17.475536  49.119123  11.994736  14.701687 
49.795201   140141142143144145 
146  5.664599  24.711067  20.426534  53.013693   5.758723  19.324367 
41.190110   147148149151152153 
14.189862 -19.275130  35.155615  20.525269  40.584670  18.702940 
...
Aha! 100 times machine precision in not all that much when the numbers
themselves are in double digits. In fact, one is over 100. The case
that triggers the failure is #149

 147   148   149   151   152 
-1.598721e-14 -1.065814e-14 -2.842171e-14 -1.065814e-14 -2.131628e-14 
which is 2 ULP off by my reckoning (scaling 35.15 to be between 0.5
and 1 makes the error 2.842e-14/64 =  4.44e-16 and [EMAIL PROTECTED]
is 2.22e-16).
So again, we might be too strict. I just wonder why we haven't heard
of this on any other platforms.

I think it's an Atlas issue, and possibly an Atlas/Athlon32 issue. The 
built-in BLAS in R-beta don't show this. Is there enough detail on what's 
happening available for me to take this to the Atlas folks? They've done a 
lot of work, including assembler code, on Athlons and their 64-bit 
descendents. My main system, where I've been doing this testing, is a 
rather old Athlon T-Bird.

Incidentally, even though Atlas does have most parameters set to pre-defined 
values for the Athlon/Linux, it does in fact make *some* decisions when it 
compiles, which may be why I'm showing this and nobody else is. I'm using 
Gentoo Linux, which recompiles nearly everything from source, including Atlas 
and R, when it does an install. Most of the other Linux distros have 
pre-compiled binaries for the various packages. Debian, for example, has 
pre-compiled Atlas libraries for P3, P4 and Athlon.
I think the issue is ATLAS on your old Athlon.  ATLAS 3.6.0 compiled from 
the sources works correctly with gcc-3.4.3 on my Athlon MP (and also on an 
Athlon XP), but AFAIR those have instructions the Athlon Thunderbird does 
not have.  (Both my machines with such Athlons fried their motherboards, 
so I no longer have access to one.)

Incidentally to Peter: ATLAS 3.7.8 is an unreleased unstable version, so I 
would hesitate to recommend it over 3.6.0.

--
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595
__
R-devel@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] make check-all fails (PR#7784)

2005-04-10 Thread Peter Dalgaard
Prof Brian Ripley [EMAIL PROTECTED] writes:

 I think the issue is ATLAS on your old Athlon.  ATLAS 3.6.0 compiled
 from the sources works correctly with gcc-3.4.3 on my Athlon MP (and
 also on an Athlon XP), but AFAIR those have instructions the Athlon
 Thunderbird does not have.  (Both my machines with such Athlons fried
 their motherboards, so I no longer have access to one.)
 
 Incidentally to Peter: ATLAS 3.7.8 is an unreleased unstable version,
 so I would hesitate to recommend it over 3.6.0.

To be precise, it's a release on an unstable branch. Hasn't changed
since 2004-07-23 though.. But you're right in principle; I had
forgotten about that.

-- 
   O__   Peter Dalgaard Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics 2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark  Ph: (+45) 35327918
~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907

__
R-devel@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] make check-all fails (PR#7784)

2005-04-09 Thread znmeb
Full_Name: Ed Borasky
Version: R-beta 2.1.0 2005-04-08
OS: Linux 2.6.11 GCC 3.3.5
Submission from: (NULL) (24.21.57.139)


I downloaded the latest R-beta tarball and did a build with the default options.
OS is Linux 2.6.11 and compiler is GCC 3.3.5. make check-all failed with the
following message:

make[3]: Entering directory `/home/znmeb/R-beta/tests'
running code in 'reg-tests-1.R' ...make[3]: *** [reg-tests-1.Rout] Error 1
make[3]: Leaving directory `/home/znmeb/R-beta/tests'
make[2]: *** [test-Reg] Error 2
make[2]: Leaving directory `/home/znmeb/R-beta/tests'
make[1]: *** [test-all-basics] Error 1
make[1]: Leaving directory `/home/znmeb/R-beta/tests'
make: *** [check-all] Error 2

I looked at tests/reg-tests-1.Rout.fail; it's 1427 lines long. The error given
is

 ## Comments:


 ## PR 796 (aic in binomial models is often wrong)
 ##
 a1 - glm(cbind(ncases, ncontrols) ~ agegp + tobgp * alcgp,
+ data = esoph, family = binomial())$aic
 a1
[1] 236.9645
 a2 - glm(ncases/(ncases+ncontrols) ~ agegp + tobgp * alcgp,
+ data = esoph, family = binomial(), weights=ncases+ncontrols)$aic
 a2
[1] 236.9645
 stopifnot(a1 == a2)
Error: a1 == a2 is not TRUE
Execution halted

I am running on an Athlon Thunderbird with Atlas 3.6.0 installed. If necessary,
I can back Atlas out and run this again.

__
R-devel@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] make check-all fails (PR#7784)

2005-04-09 Thread Peter Dalgaard
[EMAIL PROTECTED] writes:

 Full_Name: Ed Borasky
 Version: R-beta 2.1.0 2005-04-08
 OS: Linux 2.6.11 GCC 3.3.5
 Submission from: (NULL) (24.21.57.139)
 
 
 I downloaded the latest R-beta tarball and did a build with the default 
 options.
 OS is Linux 2.6.11 and compiler is GCC 3.3.5. make check-all failed with the
 following message:
 
 make[3]: Entering directory `/home/znmeb/R-beta/tests'
 running code in 'reg-tests-1.R' ...make[3]: *** [reg-tests-1.Rout] Error 1
 make[3]: Leaving directory `/home/znmeb/R-beta/tests'
 make[2]: *** [test-Reg] Error 2
 make[2]: Leaving directory `/home/znmeb/R-beta/tests'
 make[1]: *** [test-all-basics] Error 1
 make[1]: Leaving directory `/home/znmeb/R-beta/tests'
 make: *** [check-all] Error 2
 
 I looked at tests/reg-tests-1.Rout.fail; it's 1427 lines long. The error 
 given
 is
 
  ## Comments:
 
 
  ## PR 796 (aic in binomial models is often wrong)
  ##
  a1 - glm(cbind(ncases, ncontrols) ~ agegp + tobgp * alcgp,
 + data = esoph, family = binomial())$aic
  a1
 [1] 236.9645
  a2 - glm(ncases/(ncases+ncontrols) ~ agegp + tobgp * alcgp,
 + data = esoph, family = binomial(), weights=ncases+ncontrols)$aic
  a2
 [1] 236.9645
  stopifnot(a1 == a2)
 Error: a1 == a2 is not TRUE
 Execution halted
 
 I am running on an Athlon Thunderbird with Atlas 3.6.0 installed. If 
 necessary,
 I can back Atlas out and run this again.

Hmm, could you replace the a1 == a2 with all.equal(a1, a2) instead?
(inside reg-tests-1.R of course)

Asking for identity up to machine precision does look a bit optimistic...

-- 
   O__   Peter Dalgaard Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics 2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark  Ph: (+45) 35327918
~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907

__
R-devel@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] make check-all fails (PR#7784)

2005-04-09 Thread M. Edward (Ed) Borasky
Peter Dalgaard wrote:
[EMAIL PROTECTED] writes:
 

Full_Name: Ed Borasky
Version: R-beta 2.1.0 2005-04-08
OS: Linux 2.6.11 GCC 3.3.5
Submission from: (NULL) (24.21.57.139)
I downloaded the latest R-beta tarball and did a build with the default 
options.
OS is Linux 2.6.11 and compiler is GCC 3.3.5. make check-all failed with the
following message:
make[3]: Entering directory `/home/znmeb/R-beta/tests'
running code in 'reg-tests-1.R' ...make[3]: *** [reg-tests-1.Rout] Error 1
make[3]: Leaving directory `/home/znmeb/R-beta/tests'
make[2]: *** [test-Reg] Error 2
make[2]: Leaving directory `/home/znmeb/R-beta/tests'
make[1]: *** [test-all-basics] Error 1
make[1]: Leaving directory `/home/znmeb/R-beta/tests'
make: *** [check-all] Error 2
I looked at tests/reg-tests-1.Rout.fail; it's 1427 lines long. The error given
is
   

## Comments:
## PR 796 (aic in binomial models is often wrong)
##
a1 - glm(cbind(ncases, ncontrols) ~ agegp + tobgp * alcgp,
 

+ data = esoph, family = binomial())$aic
   

a1
 

[1] 236.9645
   

a2 - glm(ncases/(ncases+ncontrols) ~ agegp + tobgp * alcgp,
 

+ data = esoph, family = binomial(), weights=ncases+ncontrols)$aic
   

a2
 

[1] 236.9645
   

stopifnot(a1 == a2)
 

Error: a1 == a2 is not TRUE
Execution halted
I am running on an Athlon Thunderbird with Atlas 3.6.0 installed. If necessary,
I can back Atlas out and run this again.
   

Hmm, could you replace the a1 == a2 with all.equal(a1, a2) instead?
(inside reg-tests-1.R of course)
Asking for identity up to machine precision does look a bit optimistic...
 

That worked ... it got through reg-tests-1.R fine. However, it failed a 
little further down in the NA handling tests:

running tests of NA handling functions
make[3]: Entering directory `/home/znmeb/R-beta/tests'
running code in 'nafns.R' ...make[3]: *** [nafns.Rout] Error 1
make[3]: Leaving directory `/home/znmeb/R-beta/tests'
make[2]: *** [test-Nafns] Error 2
make[2]: Leaving directory `/home/znmeb/R-beta/tests'
make[1]: *** [test-all-devel] Error 1
make[1]: Leaving directory `/home/znmeb/R-beta/tests'
make: *** [check-all] Error 2
 sm(fitted(gfit2))
length 153 with 42 NAs
 sm(resid(gfit2))
length 153 with 42 NAs
 sm(predict(gfit2))
length 153 with 42 NAs
 (pp2 - predict(gfit2, nd))
6 25 26 27
NA -16.177404 1.688479 NA
 stopifnot(all.equal(pp, pp2))

 ## more precise tests.
 f1 - fitted(gfit)
 f2 - fitted(gfit2)
 common - match(names(f1), names(f2))
 stopifnot(max(abs(f1 - f2[common]))  100*.Machine$double.eps)
Error: max(abs(f1 - f2[common]))  100 * .Machine$double.eps is not TRUE
Execution halted
tests/nafns.Rout.fail
__
R-devel@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] make check-all fails (PR#7784)

2005-04-09 Thread p . dalgaard
M. Edward (Ed) Borasky [EMAIL PROTECTED] writes:

[snip]
 Hmm, could you replace the a1 == a2 with all.equal(a1, a2) instead?
 (inside reg-tests-1.R of course)
 
 Asking for identity up to machine precision does look a bit optimistic...
 
 
 That worked ... it got through reg-tests-1.R fine. However, it failed
 a little further down in the NA handling tests:
 
 running tests of NA handling functions
 make[3]: Entering directory `/home/znmeb/R-beta/tests'
 running code in 'nafns.R' ...make[3]: *** [nafns.Rout] Error 1
 make[3]: Leaving directory `/home/znmeb/R-beta/tests'
 make[2]: *** [test-Nafns] Error 2
 make[2]: Leaving directory `/home/znmeb/R-beta/tests'
 make[1]: *** [test-all-devel] Error 1
 make[1]: Leaving directory `/home/znmeb/R-beta/tests'
 make: *** [check-all] Error 2
 
   sm(fitted(gfit2))
 length 153 with 42 NAs
   sm(resid(gfit2))
 length 153 with 42 NAs
   sm(predict(gfit2))
 length 153 with 42 NAs
   (pp2 - predict(gfit2, nd))
 6 25 26 27
 NA -16.177404 1.688479 NA
   stopifnot(all.equal(pp, pp2))
  
   ## more precise tests.
   f1 - fitted(gfit)
   f2 - fitted(gfit2)
   common - match(names(f1), names(f2))
   stopifnot(max(abs(f1 - f2[common]))  100*.Machine$double.eps)
 Error: max(abs(f1 - f2[common]))  100 * .Machine$double.eps is not TRUE
 Execution halted
 tests/nafns.Rout.fail

This looks more serious. 100 times machine precision is quite a large
margin in these matters. Could you perhaps stick in a printout of the
two terms and their difference?

I have an ATLAS build on AMD64 and it passes all the checks, but it is
using ATLAS 3.7.8, so you might want to try an upgrade.

-- 
   O__   Peter Dalgaard Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics 2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark  Ph: (+45) 35327918
~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907

__
R-devel@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] make check-all fails (PR#7784)

2005-04-09 Thread M. Edward (Ed) Borasky
[EMAIL PROTECTED] wrote:
This looks more serious. 100 times machine precision is quite a large
margin in these matters. Could you perhaps stick in a printout of the
two terms and their difference?
I have an ATLAS build on AMD64 and it passes all the checks, but it is
using ATLAS 3.7.8, so you might want to try an upgrade.
 

Attached ... you actually weren't very far off:
 print (max(abs(f1 - f2[common])))
[1] 2.842171e-14
 print (100*.Machine$double.eps)
[1] 2.220446e-14
 stopifnot(max(abs(f1 - f2[common]))  100*.Machine$double.eps)
Error: max(abs(f1 - f2[common]))  100 * .Machine$double.eps is not TRUE
Execution halted
I'll go ahead and try ATLAS 3.7.8, but that takes a couple of hours to 
build. I've also got a Pentium III I can test this on.

R : Copyright 2005, The R Foundation for Statistical Computing
Version 2.1.0 beta (2005-04-08), ISBN 3-900051-07-0

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 a HTML browser interface to help.
Type 'q()' to quit R.

 ## Tests of functions handling NAs in fits
 ## These functions were introduced in 1.3.0.
 ## They are used by lm and glm in base R, and by
 ## packages MASS, rpart and survival.
 
 dim(airquality)
[1] 153   6
 nd - airquality[c(6,25:27), ]
 
 sm - function(x) cat(length, length(x), with, sum(is.na(x)), NAs\n)
 
 # default is to omit some rows
 fit - lm(Ozone ~ ., data=airquality, na.action=na.omit)
 summary(fit)

Call:
lm(formula = Ozone ~ ., data = airquality, na.action = na.omit)

Residuals:
Min  1Q  Median  3Q Max 
-37.014 -12.284  -3.302   8.454  95.348 

Coefficients:
 Estimate Std. Error t value Pr(|t|)
(Intercept) -64.11632   23.48249  -2.730  0.00742 ** 
Solar.R   0.050270.02342   2.147  0.03411 *  
Wind -3.318440.64451  -5.149 1.23e-06 ***
Temp  1.895790.27389   6.922 3.66e-10 ***
Month-3.039961.51346  -2.009  0.04714 *  
Day   0.273880.22967   1.192  0.23576
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 

Residual standard error: 20.86 on 105 degrees of freedom
Multiple R-Squared: 0.6249, Adjusted R-squared: 0.6071 
F-statistic: 34.99 on 5 and 105 DF,  p-value:  2.2e-16 

 sm(fitted(fit))
length 111 with 0 NAs
 sm(resid(fit))
length 111 with 0 NAs
 sm(predict(fit))
length 111 with 0 NAs
 (pp - predict(fit, nd))
 6 25 26 27 
NA -16.177404   1.688479 NA 
 
 fit2 - lm(Ozone ~ ., data=airquality, na.action=na.exclude)
 summary(fit2) # same as before

Call:
lm(formula = Ozone ~ ., data = airquality, na.action = na.exclude)

Residuals:
Min  1Q  Median  3Q Max 
-37.014 -12.284  -3.302   8.454  95.348 

Coefficients:
 Estimate Std. Error t value Pr(|t|)
(Intercept) -64.11632   23.48249  -2.730  0.00742 ** 
Solar.R   0.050270.02342   2.147  0.03411 *  
Wind -3.318440.64451  -5.149 1.23e-06 ***
Temp  1.895790.27389   6.922 3.66e-10 ***
Month-3.039961.51346  -2.009  0.04714 *  
Day   0.273880.22967   1.192  0.23576
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 

Residual standard error: 20.86 on 105 degrees of freedom
Multiple R-Squared: 0.6249, Adjusted R-squared: 0.6071 
F-statistic: 34.99 on 5 and 105 DF,  p-value:  2.2e-16 

 sm(fitted(fit2))
length 153 with 42 NAs
 sm(resid(fit2))
length 153 with 42 NAs
 sm(predict(fit2))
length 153 with 42 NAs
 (pp2 - predict(fit2, nd))
 6 25 26 27 
NA -16.177404   1.688479 NA 
 
 ## same as before: napredict is only applied to predictions on the
 ## original data, following Therneau's original code (and S-PLUS).
 ## However, as from R 1.8.0 there is a separate na.action arg to predict.lm()
 stopifnot(all.equal(pp, pp2))
 
 ## should fail
 try(fit3 - lm(Ozone ~ ., data=airquality, na.action=na.fail))
Error in na.fail.default(list(Ozone = c(41, 36, 12, 18, NA, 28, 23, 19,  : 
missing values in object
 
 ## more precise tests.
 f1 - fitted(fit)
 f2 - fitted(fit2)
 common - match(names(f1), names(f2))
 stopifnot(max(abs(f1 - f2[common]))  100*.Machine$double.eps)
 stopifnot(all(is.na(f2[-common])))
 
 r1 - resid(fit)
 r2 - resid(fit2)
 common - match(names(r1), names(r2))
 stopifnot(max(abs(r1 - r2[common]))  100*.Machine$double.eps)
 stopifnot(all(is.na(r2[-common])))
 
 p1 - predict(fit)
 p2 - predict(fit2)
 common - match(names(p1), names(p2))
 stopifnot(max(abs(p1 - p2[common]))  100*.Machine$double.eps)
 stopifnot(all(is.na(p2[-common])))
 
 
 ### now try out glm
 gfit - glm(Ozone ~ ., data=airquality,