-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathsplint.html
More file actions
147 lines (108 loc) · 3.61 KB
/
Copy pathsplint.html
File metadata and controls
147 lines (108 loc) · 3.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Cubic spline interpolation</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="R.css" />
</head><body>
<table width="100%" summary="page for splint {fields}"><tr><td>splint {fields}</td><td style="text-align: right;">R Documentation</td></tr></table>
<h2>
Cubic spline interpolation
</h2>
<h3>Description</h3>
<p>A fast, FORTRAN based function for cubic spline interpolation.
</p>
<h3>Usage</h3>
<pre>
splint(x, y, xgrid, wt=NULL, derivative=0,lam=0, df=NA, lambda=NULL, nx=NULL)
</pre>
<h3>Arguments</h3>
<table summary="R argblock">
<tr valign="top"><td><code>x</code></td>
<td>
<p>The x values that define the curve or a two column matrix of
x and y values.
</p>
</td></tr>
<tr valign="top"><td><code>y</code></td>
<td>
<p>The y values that are paired with the x's.
</p>
</td></tr>
<tr valign="top"><td><code>xgrid</code></td>
<td>
<p>The grid to evaluate the fitted cubic interpolating curve.
</p>
</td></tr>
<tr valign="top"><td><code>derivative</code></td>
<td>
<p>Indicates whether the function or a a first or second derivative
should be evaluated.
</p>
</td></tr>
<tr valign="top"><td><code>wt</code></td>
<td>
<p>Weights for different obsrevations in the scale of reciprocal
variance.</p>
</td></tr>
<tr valign="top"><td><code>lam</code></td>
<td>
<p> Value for smoothing parameter. Default value is zero giving
interpolation.</p>
</td></tr>
<tr valign="top"><td><code>lambda</code></td>
<td>
<p>Same as <code>lam</code> just to make this easier to remember.</p>
</td></tr>
<tr valign="top"><td><code>df</code></td>
<td>
<p> Effective degrees of freedom. Default is to use lambda =0 or a
df equal to the number of observations.</p>
</td></tr>
<tr valign="top"><td><code>nx</code></td>
<td>
<p>If not NULL this should be the number of points
to evaluate on an equally spaced grid in the
range of <code>x</code></p>
</td></tr>
</table>
<h3>Details</h3>
<p>Fits a piecewise interpolating or smoothing cubic
polynomial to the x and y values.
This code is designed to be fast but does not many options in
<code>sreg</code> or other more statistical implementations.
To make the solution well posed the
the second and third derivatives are set to zero at the limits of the x
values. Extrapolation outside the range of the x
values will be a linear function.
</p>
<p>It is assumed that there are no repeated x values; use sreg followed by
predict if you do have replicated data.
</p>
<h3>Value</h3>
<p>A vector consisting of the spline evaluated at the grid values in <code>xgrid</code>.
</p>
<h3>References</h3>
<p>See Additive Models by Hastie and Tibshriani.
</p>
<h3>See Also</h3>
<p>sreg, Tps
</p>
<h3>Examples</h3>
<pre>
x<- seq( 0, 120,,200)
# an interpolation
splint(rat.diet$t, rat.diet$trt,x )-> y
plot( rat.diet$t, rat.diet$trt)
lines( x,y)
#( this is weird and not appropriate!)
# the following two smooths should be the same
splint( rat.diet$t, rat.diet$con,x, df= 7)-> y1
# sreg function has more flexibility than splint but will
# be slower for larger data sets.
sreg( rat.diet$t, rat.diet$con, df= 7)-> obj
predict(obj, x)-> y2
# in fact predict.sreg interpolates the predicted values using splint!
# the two predicted lines (should) coincide
lines( x,y1, col="red",lwd=2)
lines(x,y2, col="blue", lty=2,lwd=2)
</pre>
<hr /><div style="text-align: center;">[Package <em>fields</em> version 9.9 <a href="00Index.html">Index</a>]</div>
</body></html>