Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 121 lines (98 sloc) 3.337 kB
1d011a6 remove MM's test using survival from strict regression testing
ripley authored
1 ### Regression tests for which the printed output is the issue
2 ### May fail, e.g. by needing Recommended packages
3
2f2f99c use pdf for testing examples
ripley authored
4 pdf("reg-tests-3.pdf", encoding = "ISOLatin1.enc")
1d011a6 remove MM's test using survival from strict regression testing
ripley authored
5
6 ## str() for character & factors with NA (levels), and for Surv objects:
7 ff <- factor(c(2:1, NA), exclude = NULL)
8 str(levels(ff))
9 str(ff)
10 str(ordered(ff, exclude=NULL))
11 if(require(survival)) {
12 (sa <- Surv(aml$time, aml$status))
13 str(sa)
14 detach("package:survival")
15 }
16 ## were different, the last one failed in 1.6.2 (at least)
1a927ea handle cases with hat = 1 better in lm.influence.
ripley authored
17
18
19 ## lm.influence where hat[1] == 1
20 if(require(MASS)) {
109e3b1 summary.infl was not handling NaNs correctly
ripley authored
21 fit <- lm(formula = 1000/MPG.city ~ Weight + Cylinders + Type + EngineSize + DriveTrain, data = Cars93)
22 print(lm.influence(fit))
23 ## row 57 should have hat = 1 and resid=0.
24 summary(influence.measures(fit))
1a927ea handle cases with hat = 1 better in lm.influence.
ripley authored
25 }
109e3b1 summary.infl was not handling NaNs correctly
ripley authored
26 ## only last two cols in row 57 should be influential
5837bcc fixes for PR#6624/33/40
ripley authored
27
28
29 ## PR#6640 Zero weights in plot.lm
30 if(require(MASS)) {
31 fm1 <- lm(time~dist, data=hills, weights=c(0,0,rep(1,33)))
32 plot(fm1)
33 }
34 ## gave warnings in 1.8.1
535a0e9 fix PR#7829
ripley authored
35
36
37 ## PR#7829 model.tables & replications
38 if(require(MASS)) {
39 oats.aov <- aov(Y ~ B + V + N + V:N, data=oats[-1,])
40 model.tables(oats.aov, "means", cterms=c("N", "V:N"))
41 }
42 ## wrong printed output in 2.1.0
4e7649b add test for Windows sprintf changes
ripley authored
43
c3e1a19 gaussian()$aic was based on case weights
ripley authored
44
e4a9dd4 fix drop1.lm for weighted fits
ripley authored
45 ## drop1 on weighted lm() fits
46 if(require(MASS)) {
47 hills.lm <- lm(time ~ 0 + dist + climb, data=hills, weights=1/dist^2)
48 print(drop1(hills.lm))
49 print(stats:::drop1.default(hills.lm))
50 hills.lm2 <- lm(time/dist ~ 1 + I(climb/dist), data=hills)
51 drop1(hills.lm2)
52 }
53 ## quoted unweighted RSS etc in 2.2.1
54
4e7649b add test for Windows sprintf changes
ripley authored
55
56 ## tests of ISO C99 compliance (Windows fails without a workaround)
57 sprintf("%g", 123456789)
58 sprintf("%8g", 123456789)
59 sprintf("%9.7g", 123456789)
60 sprintf("%10.9g", 123456789)
61 sprintf("%g", 12345.6789)
62 sprintf("%10.9g", 12345.6789)
63 sprintf("%10.7g", 12345.6789)
64 sprintf("%.7g", 12345.6789)
65 sprintf("%.5g", 12345.6789)
66 sprintf("%.4g", 12345.6789)
67 sprintf("%9.4g", 12345.6789)
68 sprintf("%10.4g", 12345.6789)
69 ## Windows used e+008 etc prior to 2.3.0
c3e1a19 gaussian()$aic was based on case weights
ripley authored
70
71
72 ## weighted glm() fits
73 if(require(MASS)) {
74 hills.glm <- glm(time ~ 0 + dist + climb, data=hills, weights=1/dist^2)
75 print(AIC(hills.glm))
76 print(extractAIC(hills.glm))
77 print(drop1(hills.glm))
78 stats:::drop1.default(hills.glm)
79 }
80 ## wrong AIC() and drop1 prior to 2.3.0.
8b81a9f don't allow representation error to determine the calculated number o…
ripley authored
81
82 ## calculating no of signif digits
83 print(1.001, digits=16)
e3d4ea1 several deparse issues, including clarifying the precision used for n…
ripley authored
84 ## 2.4.1 gave 1.001000000000000
8b81a9f don't allow representation error to determine the calculated number o…
ripley authored
85 ## 2.5.0 errs on the side of caution.
3b4ba2c bugfix for as.matrix.data.frame
ripley authored
86
87
88 ## as.matrix.data.frame with coercion
89 library(survival)
90 soa <- Surv(1:5, c(0, 0, 1, 0, 1))
91 df.soa <- data.frame(soa)
92 as.matrix(df.soa) # numeric result
93 df.soac <- data.frame(soa, letters[1:5])
94 as.matrix(df.soac) # character result
95 ## failed in 2.8.1
851631a fulfil wish of PR13505
ripley authored
96
97 ## wish of PR#13505
98 utils::data(npk, package="MASS")
99 npk.aov <- aov(yield ~ block + N * P + K, npk)
100 foo <- proj(npk.aov)
101 cbind(npk, foo)
102 ## failed in R < 2.10.0
c050076 more regression tests to tests/ and avoid loading Matrix/methods earl…
ripley authored
103
104
ceb5760 fix xtabs(*, sparse=TRUE, exclude=*) bug reported by Felix Andrews
maechler authored
105 if(suppressMessages(require("Matrix"))) {
c050076 more regression tests to tests/ and avoid loading Matrix/methods earl…
ripley authored
106 print(cS. <- contr.SAS(5, sparse = TRUE))
107 stopifnot(all(contr.SAS(5) == cS.),
b9f0836 contr.sum and contr.helmert had incorrect colnames, broke a MASS example
ripley authored
108 all(contr.helmert(5, sparse = TRUE) == contr.helmert(5)))
ceb5760 fix xtabs(*, sparse=TRUE, exclude=*) bug reported by Felix Andrews
maechler authored
109
110 x1 <- x2 <- c('a','b','a','b','c')
111 x3 <- x2; x3[4:5] <- x2[5:4]
112 print(xtabs(~ x1 + x2, sparse= TRUE, exclude = 'c'))
113 print(xtabs(~ x1 + x3, sparse= TRUE, exclude = 'c'))
114 ## failed in R <= 2.13.1
c050076 more regression tests to tests/ and avoid loading Matrix/methods earl…
ripley authored
115 }
b9f0836 contr.sum and contr.helmert had incorrect colnames, broke a MASS example
ripley authored
116
117 ## regression tests for dimnames (broken on 2009-07-31)
118 contr.sum(4)
119 contr.helmert(4)
120 contr.sum(2) # needed drop=FALSE at one point.
Something went wrong with that request. Please try again.