-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathpredictSurface.html
236 lines (192 loc) · 8.12 KB
/
predictSurface.html
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
<!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: Evaluates a fitted function or the prediction error as a...</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 predictSurface {fields}"><tr><td>predictSurface {fields}</td><td style="text-align: right;">R Documentation</td></tr></table>
<h2>
Evaluates a fitted function or the prediction error as a surface that is suitable for plotting with
the image, persp, or contour functions.
</h2>
<h3>Description</h3>
<p>Evaluates a a fitted model or the prediction error on a 2-D grid keeping any other variables constant.
The resulting object is suitable for use with functions for viewing 3-d
surfaces.
</p>
<h3>Usage</h3>
<pre>
## Default S3 method:
predictSurface(object, grid.list = NULL,
extrap = FALSE, chull.mask = NA, nx = 80, ny = 80,
xy = c(1,2), verbose = FALSE, ...)
## S3 method for class 'fastTps'
predictSurface(object, grid.list = NULL,
extrap = FALSE, chull.mask = NA, nx = 80, ny = 80,
xy = c(1,2), verbose = FALSE, ...)
## S3 method for class 'Krig'
predictSurface(object, grid.list = NULL, extrap = FALSE, chull.mask = NA,
nx = 80, ny = 80, xy = c(1, 2), verbose = FALSE, ZGrid = NULL,
drop.Z = FALSE, just.fixed=FALSE, ...)
## S3 method for class 'mKrig'
predictSurface(object, ...)
## Default S3 method:
predictSurfaceSE( object, grid.list = NULL, extrap =
FALSE, chull.mask = NA, nx = 80, ny = 80, xy = c(1,2), verbose =
FALSE, ...)
## S3 method for class 'surface'
predict(object,...)
</pre>
<h3>Arguments</h3>
<table summary="R argblock">
<tr valign="top"><td><code>object</code></td>
<td>
<p>An object from fitting a function to data. In fields this is usually a
Krig, mKrig, or fastTps object.
</p>
</td></tr>
<tr valign="top"><td><code>grid.list</code></td>
<td>
<p>A list with as many components as variables describing the surface.
All components should have a single value except the two that give the
grid points for evaluation. If the matrix or data frame has column names,
these must appear in the grid list. See the grid.list help file for more
details. If this is omitted and the fit just depends on two variables the
grid will be made from the ranges of the observed variables.
(See the function <code>fields.x.to.grid</code>.)
</p>
</td></tr>
<tr valign="top"><td><code>extrap</code></td>
<td>
<p>Extrapolation beyond the range of the data. If <code>FALSE</code> (the
default) the predictions will be restricted to the convex hull of the observed
data or the convex hull defined from the points from the argument chull.mask.
This function may be slightly faster if this logical is set to
<code>TRUE</code> to avoid checking the grid points for membership in the
convex hull. For more complicated masking a low level creation of a bounding
polygon and testing for membership with <code>in.poly</code> may be useful.
</p>
</td></tr>
<tr valign="top"><td><code>chull.mask</code></td>
<td>
<p>Whether to restrict the fitted surface to be on a convex hull, NA's
are assigned to values outside the
convex hull. chull.mask should be a sequence of points defining a convex
hull. Default is to form the convex hull from the observations if this
argument is missing (and extrap is false).
</p>
</td></tr>
<tr valign="top"><td><code>nx</code></td>
<td>
<p>Number of grid points in X axis. </p>
</td></tr>
<tr valign="top"><td><code>ny</code></td>
<td>
<p>Number of grid points in Y axis. </p>
</td></tr>
<tr valign="top"><td><code>xy</code></td>
<td>
<p> A two element vector giving the positions for the "X" and "Y"
variables for the surface. The positions refer to the columns of the x
matrix used to define the multidimensional surface. This argument is
provided in lieu of generating the grid list. If a 4 dimensional surface
is fit to data then <code> xy= c(2,4)</code> will evaluate a surface using the
second and fourth variables with variables 1 and 3 fixed at their median
values. NOTE: this argument is ignored if a grid.list argument is
passed. </p>
</td></tr>
<tr valign="top"><td><code>drop.Z</code></td>
<td>
<p>If TRUE the fixed part of model depending on covariates is omitted.</p>
</td></tr>
<tr valign="top"><td><code>just.fixed</code></td>
<td>
<p>If TRUE the nonparametric surface is omitted.</p>
</td></tr>
<tr valign="top"><td><code>...</code></td>
<td>
<p>Any other arguments to pass to the predict function associated with the fit
object.
Some of the usual arguments for several of the fields fitted objects include:
</p>
<dl>
<dt>ynew</dt><dd><p> New values of y used to reestimate the surface.</p>
</dd>
<dt>Z</dt><dd><p>A matrix of covariates for the fixed part of model.</p>
</dd>
</dl>
</td></tr>
<tr valign="top"><td><code>ZGrid</code></td>
<td>
<p>An array or list form of covariates to use for
prediction. This must match the
<code>grid.list</code> argument. e.g. ZGrid and grid.list describe the same
grid.
If ZGrid is an array then the first two indices are the x and y
locations in the
grid. The third index, if present, indexes the covariates. e.g. For
evaluation on
a 10X15 grid and with 2 covariates. <code> dim( ZGrid) == c(10,15, 2)</code>.
If ZGrid is a list then the components x and y shold match those of
grid.list and
the z component follows the shape described above for the no list
case.
</p>
</td></tr>
<tr valign="top"><td><code>verbose</code></td>
<td>
<p>If TRUE prints out some imtermediate results for debugging.</p>
</td></tr>
</table>
<h3>Details</h3>
<p> This
function creates the right grid using the grid.list information or the
attribute in xg, calls the predict function for the object with these
points and also adding any extra arguments passed in the ... section,
and then reforms the results as a surface object (as.surface). To
determine the what parts of the prediction grid are in the convex hull
of the data the function <code>in.poly</code> is used. The argument
inflation in this function is used to include a small margin around
the outside of the polygon so that point on convex hull are
included. This potentially confusing modification is to prevent
excluding grid points that fall exactly on the ranges of the
data. Also note that as written there is no computational savings for
evaluting only the convex subset compared to the full grid.
</p>
<p><code>predictSurface.fastTps</code> is a specific version ( m=2, and k=2)
that can be much more efficient because it takes advantage of a low
level FORTRAN call to evaluate the Wendland covariance function. Use
<code>predictSurface</code> or <code>predict</code> for other choices of m and k.
</p>
<p><code>predictSurface.Krig</code> is designed to also include covariates for the fixed in terms of grids. Due to similarity in output and the model. <code>predictSurface.mKrig</code> just uses the Krig method.
</p>
<p>NOTE: <code>predict.surface</code> has been depreciated and just prints out
a warning when called.
</p>
<h3>Value</h3>
<p>The usual list components for making contour and perspective plots
(x,y,z) along with labels for the x and y variables. For
<code>predictSurface.derivative</code> the component <code>z</code> is a three
dimensional array with <code>nx</code>, <code>ny</code>, 2.
</p>
<h3>See Also</h3>
<p>Tps, Krig, predict, grid.list, make.surface.grid, as.surface, surface,
in.poly
</p>
<h3>Examples</h3>
<pre>
fit<- Tps( BD[,1:4], BD$lnya) # fit surface to data
# evaluate fitted surface for first two
# variables holding other two fixed at median values
out.p<- predictSurface(fit)
surface(out.p, type="C")
#
# plot surface for second and fourth variables
# on specific grid.
glist<- list( KCL=29.77, MgCl2= seq(3,7,,25), KPO4=32.13,
dNTP=seq( 250,1500,,25))
out.p<- predictSurface(fit, glist)
surface(out.p, type="C")
out.p<- predictSurfaceSE(fit, glist)
surface(out.p, type="C")
</pre>
<hr /><div style="text-align: center;">[Package <em>fields</em> version 9.9 <a href="00Index.html">Index</a>]</div>
</body></html>