The R Project SVN R

Rev

Rev 68948 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 68948 Rev 74690
Line 1... Line 1...
1
% File src/library/stats/man/makepredictcall.Rd
1
% File src/library/stats/man/makepredictcall.Rd
2
% Part of the R package, https://www.R-project.org
2
% Part of the R package, https://www.R-project.org
3
% Copyright 1995-2014 R Core Team
3
% Copyright 1995-2018 R Core Team
4
% Distributed under GPL 2 or later
4
% Distributed under GPL 2 or later
5
 
5
 
6
\name{makepredictcall}
6
\name{makepredictcall}
7
\alias{makepredictcall}
7
\alias{makepredictcall}
8
\alias{makepredictcall.default}
8
\alias{makepredictcall.default}
Line 52... Line 52...
52
 
52
 
53
## using poly: this did not work in R < 1.5.0
53
## using poly: this did not work in R < 1.5.0
54
fm <- lm(weight ~ poly(height, 2), data = women)
54
fm <- lm(weight ~ poly(height, 2), data = women)
55
plot(women, xlab = "Height (in)", ylab = "Weight (lb)")
55
plot(women, xlab = "Height (in)", ylab = "Weight (lb)")
56
ht <- seq(57, 73, len = 200)
56
ht <- seq(57, 73, len = 200)
57
lines(ht, predict(fm, data.frame(height = ht)))
57
nD <- data.frame(height = ht)
-
 
58
pfm <- predict(fm, nD)
-
 
59
lines(ht, pfm)
-
 
60
pf2 <- predict(update(fm, ~ stats::poly(height, 2)), nD)
-
 
61
stopifnot(all.equal(pfm, pf2)) ## was off (rel.diff. 0.0766) in R <= 3.5.0
58
 
62
 
59
## see also example(cars)
63
## see also example(cars)
60
 
64
 
61
## see bs and ns for spline examples.
65
## see bs and ns for spline examples.
62
}
66
}