Description Usage Arguments Value Examples
Return the prediction of a local regression model using region of influence (ROI) where the the residuals are further predicted by kriging.
1 |
x |
Data for trainging the model. |
xnew |
Data at new locations (Validation set). |
k |
Number of sites in the neighborhoods. |
trend |
Formula defining the trend. |
similarity |
Formula defining covariates used for forming region of influence based on Euclidien distance. |
kriging |
Formula defining the spatial covariates . used for predicting residuals with spatial correlation. |
ker |
Should a kernel be used in the local regression model. |
... |
More arguments to pass to kriging function |
model |
Variogram model. See |
pred |
Prediction at new sites. |
pred.se |
Standard deviation at new sites. |
trend |
Part of the prediction attributed to trend |
trend.se |
Standard deviation associated with the trend |
fitted |
Fitted values (training sites) |
fitted.se |
Standard deviaton of the fitted values |
vgm |
Sample variogram. |
model |
Fitted variogram model. |
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 | attach(canFlood)
## Transform data if necessary
xdf <- with(canFlood,
data.frame(y = log(L1),
area = scale(log(BASIN_AREA)),
wb = scale(log(WB_AREA_PC)),
stream = scale(log(STREAM_DEN)),
map = scale(log(PPTAVG_BAS)),
lon = ELON,
lat = ELAT))
# Note that the coordinates were transform to a Euclidean space using
# multidimentional scaling
## select a validation and training set
vid <- runif(nrow(xdf)) > .8
tid <- !vid
# formula of the relationship between flood quantile and descriptors
ftrend <- y ~ area + map + wb + stream
fsimilarity <- ~ area + map + wb + stream
## Fit a local regression model
fit <- FitRoi(x = xdf[tid,], xnew = xdf[vid,], k = 50,
ftrend, similarity = fsimilarity)
print(fit)
sd(xdf[vid,'y'] - fit$pred)
## Refit the model and perform the kriging of the residuals
fitk <- FitRoi(x = xdf[tid,], xnew = xdf[vid, ], k =50,
ftrend, loc = fsimilarity ,
kriging = ~ lon + lat)
print(fitk)
sd(xdf[vid,'y'] - fitk$trend)
sd(xdf[vid,'y'] - fitk$pred)
ifold0 <- sample(floor((1:n)/(n+1)*fold)+1)
## Perform cross-validation. Long to compute
## This speed up the computation as there is no search for a best model
f <- FitRoi.cv(x = xdf, k = seq(20,150, 10), fold = ifold0,
ftrend, similarity = ~ lon + lat,
verbose = TRUE, crit = 'mad')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.