The R Project SVN R

Rev

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

Rev 61162 Rev 61433
Line 55... Line 55...
55
require(graphics); require(stats)
55
require(graphics); require(stats)
56
ispl <- interpSpline( weight ~ height,  women )
56
ispl <- interpSpline( weight ~ height,  women )
57
opar <- par(mfrow = c(2, 2), las = 1)
57
opar <- par(mfrow = c(2, 2), las = 1)
58
plot(predict(ispl, nseg = 201),     # plots over the range of the knots
58
plot(predict(ispl, nseg = 201),     # plots over the range of the knots
59
     main = "Original data with interpolating spline", type = "l",
59
     main = "Original data with interpolating spline", type = "l",
60
     xlab = "height", ylab = "weight") 
60
     xlab = "height", ylab = "weight")
61
points(women$height, women$weight, col = 4)
61
points(women$height, women$weight, col = 4)
62
plot(predict(ispl, nseg = 201, deriv = 1),
62
plot(predict(ispl, nseg = 201, deriv = 1),
63
     main = "First derivative of interpolating spline", type = "l",
63
     main = "First derivative of interpolating spline", type = "l",
64
     xlab = "height", ylab = "weight") 
64
     xlab = "height", ylab = "weight")
65
plot(predict(ispl, nseg = 201, deriv = 2),
65
plot(predict(ispl, nseg = 201, deriv = 2),
66
     main = "Second derivative of interpolating spline", type = "l",
66
     main = "Second derivative of interpolating spline", type = "l",
67
     xlab = "height", ylab = "weight") 
67
     xlab = "height", ylab = "weight")
68
plot(predict(ispl, nseg = 401, deriv = 3),
68
plot(predict(ispl, nseg = 401, deriv = 3),
69
     main = "Third derivative of interpolating spline", type = "l",
69
     main = "Third derivative of interpolating spline", type = "l",
70
     xlab = "height", ylab = "weight") 
70
     xlab = "height", ylab = "weight")
71
par(opar)
71
par(opar)
72
}
72
}
73
\keyword{models}
73
\keyword{models}