~ubuntu-branches/ubuntu/trusty/r-cran-vgam/trusty

« back to all changes in this revision

Viewing changes to man/vsmooth.spline.Rd

  • Committer: Package Import Robot
  • Author(s): Chris Lawrence
  • Date: 2011-11-04 13:13:06 UTC
  • mfrom: (1.2.9)
  • mto: This revision was merged to the branch mainline in revision 14.
  • Revision ID: package-import@ubuntu.com-20111104131306-w9fd83i51rw60gxf
Tags: upstream-0.8-4
ImportĀ upstreamĀ versionĀ 0.8-4

Show diffs side-by-side

added added

removed removed

Lines of Context:
123
123
  nonlinear part, and using B-splines.
124
124
  The cost of the computation is \code{O(n M^3)}.
125
125
 
 
126
 
126
127
  The argument \code{spar} contains \emph{scaled} smoothing parameters.
127
128
 
 
129
 
128
130
}
129
131
\value{
130
132
  An object of class \code{"vsmooth.spline"} (see
139
141
\emph{Proceedings in Computational Statistics COMPSTAT 2000}.
140
142
Heidelberg: Physica-Verlag.
141
143
 
 
144
 
142
145
}
143
146
\author{ Thomas W. Yee }
144
147
\note{
148
151
  For \code{M = 1}, the results will be generally different,
149
152
  mainly due to the different way the knots are selected.
150
153
 
 
154
 
151
155
  The vector cubic smoothing spline which \code{s()} represents is
152
156
  computationally demanding for large \eqn{M}.
153
157
  The cost is approximately \eqn{O(M^3)}.
154
158
 
 
159
 
155
160
  Yet to be done: return the \emph{unscaled} smoothing parameters.
156
161
 
 
162
 
157
163
}
158
164
 
159
165
\seealso{
168
174
\examples{
169
175
nn = 20; x = 2 + 5*(nn:1)/nn
170
176
x[2:4] = x[5:7]      # Allow duplication
171
 
y1 = sin(x) + rnorm(nn, sd=0.13)
172
 
y2 = cos(x) + rnorm(nn, sd=0.13)
173
 
y3 = 1 + sin(x) + rnorm(nn, sd=0.13) # Run this for constraints
 
177
y1 = sin(x) + rnorm(nn, sd = 0.13)
 
178
y2 = cos(x) + rnorm(nn, sd = 0.13)
 
179
y3 = 1 + sin(x) + rnorm(nn, sd = 0.13) # Run this for constraints
174
180
y = cbind(y1, y2, y3)
175
181
ww = cbind(rep(3,nn), 4, (1:nn)/nn)
176
182
 
180
186
}
181
187
 
182
188
mat = matrix(c(1,0,1, 0,1,0), 3, 2)
183
 
(fit2 = vsmooth.spline(x, y, w=ww, df=5, iconstr=mat, xconstr=mat))
 
189
(fit2 = vsmooth.spline(x, y, w = ww, df = 5, iconstr = mat, xconstr = mat))
184
190
# The 1st and 3rd functions do differ by a constant:
185
 
mycols = c("red","blue","red")
186
 
\dontrun{ plot(fit2, lcol=mycols, pcol=mycols, las=1) }
 
191
mycols = c("orange", "blue", "orange")
 
192
\dontrun{ plot(fit2, lcol = mycols, pcol = mycols, las = 1) }
187
193
 
188
 
p = predict(fit, x=fit@x, deriv=0)
 
194
p = predict(fit, x = fit@x, deriv = 0)
189
195
max(abs(fit@y - with(p, y))) # Should be zero
190
196
 
191
 
par(mfrow=c(3,1))
 
197
par(mfrow = c(3, 1))
192
198
ux = seq(1, 8, len = 100)
193
199
for(d in 1:3) {
194
 
    p = predict(fit, x=ux, deriv = d)
195
 
\dontrun{with(p, matplot(x, y, type="l", main=paste("deriv =", d), lwd=2,
196
 
                         ylab="", cex.axis=1.5, cex.lab=1.5, cex.main=1.5))}
 
200
    p = predict(fit, x = ux, deriv = d)
 
201
\dontrun{with(p, matplot(x, y, type = "l", main = paste("deriv =", d),
 
202
                         lwd = 2, ylab = "", cex.axis = 1.5,
 
203
                         cex.lab = 1.5, cex.main = 1.5)) }
197
204
}
198
205
}
199
206
\keyword{regression}