locpol(x, ...)
"locpol" (x, y, h = NULL, nbin = NULL, degree = 1 + as.numeric(drv), drv = FALSE, hat.bin = FALSE, ncv = 0, set.NA = FALSE, ...)
"locpol" (x, h = NULL, degree = 1 + as.numeric(drv), drv = FALSE, hat.bin = FALSE, ncv = 0, ...)
"locpol" (x, h = NULL, degree = 1, drv = FALSE, hat.bin = TRUE, ncv = 0, ...)
"locpol" (x, h = NULL, degree = 1 + as.numeric(drv), drv = FALSE, ncv = 0, ...)
locpolhcv(x, y, nbin = NULL, objective = c("CV", "GCV", "MASE"), degree = 1 + as.numeric(drv), drv = FALSE, hat.bin = FALSE, set.NA = FALSE, ncv = ifelse(objective == "GCV", 0, 1), cov = NULL, ...)
hcv.data
).TRUE
, the matrix of
estimated first derivatives is returned.TRUE
, the hat matrix of
the binned data is returned.TRUE
, sets binning cells
without data to missing.locpol.bin
(locpol +
bin data + grid par.). A bin.data
object
with the additional (some optional) 3 components:
nbin
) with
the local polynomial estimates. degree
degree
of the polinomial. h
bandwidth matrix.
rm
residual mean. rss
sum of
squared residuals. ncv
number of cells
ignored in each direction. hat
(if
requested) hat matrix of the binned data.
nrl0
(if appropriate) number of cells with
data (binw > 0
) and missing estimate (est ==
NA
). locpol.svar.bin
returns an S3 object of class
np.svar
(locpol semivar + bin semivar +
grid par.).locpol.bin.den
returns an S3 object of class
np.den
(locpol den + bin den + grid par.).
lp_raw
), in
which argument x
is a vector or matrix of
covariates (e.g. spatial coordinates). If parameter nbin
is not specified is set to
rep(25, ncol(x))
.
A multiplicative triweight kernel is used to compute the weights.
If ncv > 0
, estimates are computed by leaving out
cells with indexes within the intervals $[x_i - ncv +
1, x_i + ncv - 1]$, at each dimension i, where $x$
denotes the index of the estimation position. $ncv =
1$ corresponds with traditional cross-validation and
$ncv > 1$ with modified CV (see e.g. Chu and Marron,
1991, for the one dimensional case).
Setting set.NA = TRUE
(equivalent to
biny[binw == 0] <- NA
) may be useful for plotting
the binned averages $biny
(the hat matrix should
be handled with care).
locpolhcv
calls hcv.data
to obtain
an "optimal" bandwith (additional arguments ...
are passed to this function). Argument ncv
is only
used here at the bandwith selection stage (estimation is
done with all the data).
Rupert D. and Wand M.P. (1994) Multivariate locally weighted least squares regression. The Annals of Statistics, 22, 1346-1370.
binning
, data.grid
,
np.svariso
, svar.bin
,
np.den
, bin.den
,
hcv.data
.
lp <- locpol(earthquakes[, c("lon", "lat")], earthquakes$mag, h = diag(2, 2), nbin = c(41,41))
simage(lp, main = "Smoothed magnitude")
contour(lp, add = TRUE)
bin <- binning(earthquakes[, c("lon", "lat")], earthquakes$mag, nbin = c(41,41))
lp2 <- locpol(bin, h = diag(2, 2))
all.equal(lp, lp2)
## Alternatively:
## lp <- locpolhcv(earthquakes[, c("lon", "lat")], earthquakes$mag, ncv = 4)
den <- locpol(as.bin.den(bin), h = diag(1, 2))
plot(den, log = FALSE, main = 'Estimated density')
Run the code above in your browser using DataLab