Commit e1fe3ed8 authored by Radford Neal's avatar Radford Neal

some tests and test output from R-2.15.1

parent 709f47d4
......@@ -91,7 +91,7 @@ clean:
-@rm -f testit.txt testit.html testit.tex testit-Ex.R
-@rm -f ver20.txt ver20.html ver20.tex ver20-Ex.R
-@rm -rf anRpackage myTst* myLib
-@rm -f *.tar.gz
-@rm -f *.tar.gz *.Rd
-@rm -f keepsource.tex test-system2 test-system.Rout
distclean: clean
......
......@@ -80,7 +80,7 @@ clean:
@rm -f testit.txt testit.html testit.tex testit-Ex.R
@rm -f ver20.txt ver20.html ver20.tex ver20-Ex.R
@rm -rf anRpackage myTst* myLib
@rm -f *.tar.gz
@rm -f *.tar.gz *.Rd
@rm -f keepsource.tex test-system2.exe test-system.Rout
@$(MK) -C Examples $@
@$(MK) -C Embedding $@
......
......@@ -714,7 +714,7 @@ F-statistic: 169 on 1 and 18 DF, p-value: 1.39e-10
Call:
lm(formula = y ~ x, data = dummy, weights = 1/w^2)
Residuals:
Weighted Residuals:
Min 1Q Median 3Q Max
-1.3205 -0.4492 -0.0088 0.5088 1.2656
......
......@@ -12,16 +12,17 @@ X <- hilbert(9)[,1:6]
stopifnot(abs(X - s$u %*% D %*% t(s$v)) < Eps)# X = U D V'
stopifnot(abs(D - t(s$u) %*% X %*% s$v) < Eps)# D = U' X V
# The signs of the vectors are not determined here.
X <- cbind(1, 1:7)
(s <- svd(X)); D <- diag(s$d)
s <- svd(X); D <- diag(s$d)
stopifnot(abs(X - s$u %*% D %*% t(s$v)) < Eps)# X = U D V'
stopifnot(abs(D - t(s$u) %*% X %*% s$v) < Eps)# D = U' X V
# test nu and nv
svd(X, nu = 0)
(s <- svd(X, nu = 7))
s <- svd(X, nu = 0)
s <- svd(X, nu = 7) # the last 5 columns are not determined here
stopifnot(dim(s$u) == c(7,7))
svd(X, nv = 0)
s <- svd(X, nv = 0)
# test of complex case
......
......@@ -58,73 +58,17 @@ $v
> stopifnot(abs(X - s$u %*% D %*% t(s$v)) < Eps)# X = U D V'
> stopifnot(abs(D - t(s$u) %*% X %*% s$v) < Eps)# D = U' X V
>
> # The signs of the vectors are not determined here.
> X <- cbind(1, 1:7)
> (s <- svd(X)); D <- diag(s$d)
$d
[1] 12.07 1.16
$u
[,1] [,2]
[1,] 0.09762 0.674356
[2,] 0.17884 0.503717
[3,] 0.26006 0.333078
[4,] 0.34128 0.162438
[5,] 0.42250 -0.008201
[6,] 0.50372 -0.178840
[7,] 0.58494 -0.349479
$v
[,1] [,2]
[1,] 0.1979 0.9802
[2,] 0.9802 -0.1979
> s <- svd(X); D <- diag(s$d)
> stopifnot(abs(X - s$u %*% D %*% t(s$v)) < Eps)# X = U D V'
> stopifnot(abs(D - t(s$u) %*% X %*% s$v) < Eps)# D = U' X V
>
> # test nu and nv
> svd(X, nu = 0)
$d
[1] 12.07 1.16
$v
[,1] [,2]
[1,] 0.1979 0.9802
[2,] 0.9802 -0.1979
> (s <- svd(X, nu = 7))
$d
[1] 12.07 1.16
$u
[,1] [,2] [,3] [,4] [,5] [,6] [,7]
[1,] 0.09762 0.674356 -0.38314 -0.35392 -0.32471 -0.29549 -0.26628
[2,] 0.17884 0.503717 -0.13857 0.05843 0.25543 0.45242 0.64942
[3,] 0.26006 0.333078 0.89399 -0.09282 -0.07963 -0.06644 -0.05326
[4,] 0.34128 0.162438 -0.10083 0.88314 -0.13289 -0.14891 -0.16494
[5,] 0.42250 -0.008201 -0.09566 -0.14090 0.81386 -0.23139 -0.27663
[6,] 0.50372 -0.178840 -0.09048 -0.16494 -0.23940 0.68614 -0.38831
[7,] 0.58494 -0.349479 -0.08531 -0.18898 -0.29265 -0.39633 0.50000
$v
[,1] [,2]
[1,] 0.1979 0.9802
[2,] 0.9802 -0.1979
> s <- svd(X, nu = 0)
> s <- svd(X, nu = 7) # the last 5 columns are not determined here
> stopifnot(dim(s$u) == c(7,7))
> svd(X, nv = 0)
$d
[1] 12.07 1.16
$u
[,1] [,2]
[1,] 0.09762 0.674356
[2,] 0.17884 0.503717
[3,] 0.26006 0.333078
[4,] 0.34128 0.162438
[5,] 0.42250 -0.008201
[6,] 0.50372 -0.178840
[7,] 0.58494 -0.349479
> s <- svd(X, nv = 0)
>
> # test of complex case
>
......
......@@ -10,6 +10,7 @@ pdf("reg-examples-2.pdf", encoding = "ISOLatin1.enc")
example(SSasympOrig)
example(SSlogis)
example(constrOptim)
example(cancor)
example(aov)
# signs for promax rotation are arbitrary
example(factanal)
......@@ -24,6 +25,7 @@ example(ls.diag)
example(model.tables)
example(nlminb)
example(optim)
example(prcomp)
example(step)
example(summary.manova)
example(uniroot)
......
......@@ -1785,11 +1785,11 @@ stopifnot(identical(names(tt), "a"))
## predict( VAR(p >= 2) )
set.seed(42)
u <- matrix(rnorm(200),100,2)
y <- filter(u,filter=0.8,"recursive")
est <- ar(y, aic=FALSE, order.max=2) ## Estimate VAR(2)
xpred <- predict(object=est, n.ahead=100, se.fit=FALSE)
stopifnot(dim(xpred) == c(100,2), abs(range(xpred)) < 1)
u <- matrix(rnorm(200), 100, 2)
y <- filter(u, filter=0.8, "recursive")
est <- ar(y, aic = FALSE, order.max = 2) ## Estimate VAR(2)
xpred <- predict(object = est, n.ahead = 100, se.fit = FALSE)
stopifnot(dim(xpred) == c(100, 2), abs(range(xpred)) < 1)
## values went to +- 1e23 in R <= 2.14.2
......@@ -1813,3 +1813,52 @@ merge(x, y, all = TRUE)
names(y)[3] <- "x"
stopifnot(inherits(try(merge(x, y, all = TRUE)), "try-error"))
## 'worked' in R < 2.15.1.
## misuse of seq() by package 'plotrix'
stopifnot(inherits(try(seq(1:50, by = 5)), "try-error"))
## gave 1:50 in R < 2.15.1, with warnings from seq().
## regression test for PR#14850 (misuse of dim<-)
b <- a <- matrix(1:2, ncol = 2)
`dim<-`(b, c(2, 1))
stopifnot(ncol(a) == 2)
## did not duplicate.
## deparsing needs escape characters in names (PR#14846)
f <- function(x) switch(x,"\\dbc"=2,3)
parse(text=deparse(f))
## Gave error about unrecognized escape
## hclust()'s original algo was not ok for "median" (nor "centroid") -- PR#4195
n <- 12; p <- 3
set.seed(46)
d <- dist(matrix(round(rnorm(n*p), digits = 2), n,p), "manhattan")
d[] <- d[] * sample(1 + (-4:4)/100, length(d), replace=TRUE)
hc <- hclust(d, method = "median")
stopifnot(all.equal(hc$height[5:11],
c(1.69805, 1.75134375, 1.34036875, 1.47646406,
3.21380039, 2.9653438476, 6.1418258), tol = 1e-9))
##
## 'infinity' partially matched 'inf'
stopifnot(as.numeric("infinity") == Inf)
## was NA in R < 2.15.1
## by() failed for a 0-row data frame
b <- data.frame(ppg.id=1, predvol=2)
a <- b[b$ppg.id == 2, ]
by(a, a["ppg.id"], function(x){
vol.sum = numeric()
id = integer();
if(dim(x)[1] > 0) {id = x$ppg.id[1]; vol.sum = sum(x$predvol)}
data.frame(ppg.id=id, predVolSum=vol.sum)
})
## failed in 2.15.0
proc.time()
......@@ -2611,3 +2611,13 @@ try(smooth.spline(aa, seq_along(aa)))
fit <- smooth.spline(aa, seq_along(aa), tol = 0.1)
# actual output is too unstable to diff.
## Better message from R 2.14.2
## PR#14840
d <- data.frame(x = 1:9,
y = 1:9 + 0.1*c(1, 2, -1, 0, 1, 1000, 0, 1, -1),
w = c(1, 0.5, 2, 1, 2, 0, 1, 2, 1))
fit <- lm(y ~ x, data=d, weights=w)
summary(fit)
## issue is how the 5-number summary is labelled
## (also seem in example(case.names))
......@@ -6837,3 +6837,32 @@ Error in smooth.spline(aa, seq_along(aa)) :
> # actual output is too unstable to diff.
> ## Better message from R 2.14.2
>
>
> ## PR#14840
> d <- data.frame(x = 1:9,
+ y = 1:9 + 0.1*c(1, 2, -1, 0, 1, 1000, 0, 1, -1),
+ w = c(1, 0.5, 2, 1, 2, 0, 1, 2, 1))
> fit <- lm(y ~ x, data=d, weights=w)
> summary(fit)
Call:
lm(formula = y ~ x, data = d, weights = w)
Weighted Residuals:
Min 1Q Median 3Q Max
-0.1883 -0.0310 0.0000 0.1006 0.1165
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.03949 0.08612 0.459 0.663
x 0.99788 0.01502 66.419 7.83e-10 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.1232 on 6 degrees of freedom
Multiple R-squared: 0.9986, Adjusted R-squared: 0.9984
F-statistic: 4412 on 1 and 6 DF, p-value: 7.834e-10
> ## issue is how the 5-number summary is labelled
> ## (also seem in example(case.names))
>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment