revdep/checks.noindex/spm/new/spm.Rcheck/spm-Ex.R

pkgname <- "spm"
source(file.path(R.home("share"), "R", "examples-header.R"))
options(warn = 1)
library('spm')

base::assign(".oldSearch", base::search(), pos = 'CheckExEnv')
base::assign(".old_wd", base::getwd(), pos = 'CheckExEnv')
cleanEx()
nameEx("RFcv")
### * RFcv

flush(stderr()); flush(stdout())

### Name: RFcv
### Title: Cross validation, n-fold for random forest (RF)
### Aliases: RFcv

### ** Examples

## Not run: 
##D data(hard)
##D data(petrel)
##D 
##D rfcv1 <- RFcv(petrel[, c(1,2, 6:9)], petrel[, 5], predacc = "ALL")
##D rfcv1
##D 
##D n <- 20 # number of iterations, 60 to 100 is recommended.
##D VEcv <- NULL
##D for (i in 1:n) {
##D rfcv1 <- RFcv(petrel[, c(1,2,6:9)], petrel[, 5], predacc = "VEcv")
##D VEcv [i] <- rfcv1
##D }
##D plot(VEcv ~ c(1:n), xlab = "Iteration for RF", ylab = "VEcv (%)")
##D points(cumsum(VEcv) / c(1:n) ~ c(1:n), col = 2)
##D abline(h = mean(VEcv), col = 'blue', lwd = 2)
##D 
##D n <- 20 # number of iterations, 60 to 100 is recommended.
##D measures <- NULL
##D for (i in 1:n) {
##D rfcv1 <- RFcv(hard[, c(4:6)], hard[, 17])
##D measures <- rbind(measures, rfcv1$ccr) # for kappa, replace ccr with kappa
##D }
##D plot(measures ~ c(1:n), xlab = "Iteration for RF", ylab = "Correct
##D classification rate  (%)")
##D points(cumsum(measures) / c(1:n) ~ c(1:n), col = 2)
##D abline(h = mean(measures), col = 'blue', lwd = 2)
## End(Not run)




cleanEx()
nameEx("avi")
### * avi

flush(stderr()); flush(stdout())

### Name: avi
### Title: Averaged variable importance based on random forest
### Aliases: avi

### ** Examples

## Not run: 
##D data(petrel)
##D set.seed(1234)
##D avi1 <- avi(petrel[, c(1,2, 6:9)], petrel[, 5], nsim = 10)
##D avi1
##D 
##D avi1 <- avi(petrel[, c(1), drop = FALSE], petrel[, 5], nsim = 10)
##D avi1
## End(Not run)




cleanEx()
nameEx("gbmcv")
### * gbmcv

flush(stderr()); flush(stdout())

### Name: gbmcv
### Title: Cross validation, n-fold for generalized boosted regression
###   modeling (gbm)
### Aliases: gbmcv

### ** Examples

## Not run: 
##D data(sponge)
##D 
##D gbmcv1 <- gbmcv(sponge[, -c(3)], sponge[, 3], cv.fold = 10,
##D family = "poisson", n.cores=2, predacc = "ALL")
##D gbmcv1
##D 
##D n <- 20 # number of iterations, 60 to 100 is recommended.
##D VEcv <- NULL
##D for (i in 1:n) {
##D gbmcv1 <- gbmcv(sponge[, -c(3)], sponge[, 3], cv.fold = 10,
##D family = "poisson",  n.cores=2, predacc = "VEcv")
##D VEcv [i] <- gbmcv1
##D }
##D plot(VEcv ~ c(1:n), xlab = "Iteration for gbm", ylab = "VEcv (%)")
##D points(cumsum(VEcv) / c(1:n) ~ c(1:n), col = 2)
##D abline(h = mean(VEcv), col = 'blue', lwd = 2)
## End(Not run)




cleanEx()
nameEx("gbmidwcv")
### * gbmidwcv

flush(stderr()); flush(stdout())

### Name: gbmidwcv
### Title: Cross validation, n-fold for the hybrid method of generalized
###   boosted regression modeling and inverse distance weighting (gbmidw)
### Aliases: gbmidwcv

### ** Examples

## Not run: 
##D data(sponge)
##D 
##D gbmidwcv1 <- gbmidwcv(sponge[, c(1,2)], sponge[, -c(3)], sponge[, 3],
##D cv.fold = 10, family = "poisson", n.cores=2, predacc = "ALL")
##D gbmidwcv1
##D 
##D n <- 20 # number of iterations, 60 to 100 is recommended.
##D VEcv <- NULL
##D for (i in 1:n) {
##D gbmidwcv1 <- gbmidwcv(sponge[, c(1,2)], sponge[, -c(3)], sponge[, 3],
##D cv.fold = 10, family = "poisson", n.cores=2, predacc = "VEcv")
##D VEcv [i] <- gbmidwcv1
##D }
##D plot(VEcv ~ c(1:n), xlab = "Iteration for gbmidw", ylab = "VEcv (%)")
##D points(cumsum(VEcv) / c(1:n) ~ c(1:n), col = 2)
##D abline(h = mean(VEcv), col = 'blue', lwd = 2)
## End(Not run)




cleanEx()
nameEx("gbmidwpred")
### * gbmidwpred

flush(stderr()); flush(stdout())

### Name: gbmidwpred
### Title: Generate spatial predictions using the hybrid method of
###   generalized boosted regression modeling and inverse distance
###   weighting (gbmidw)
### Aliases: gbmidwpred

### ** Examples

## Not run: 
##D data(petrel)
##D data(petrel.grid)
##D gbmidwpred1 <- gbmidwpred(petrel[, c(1,2)], petrel[, c(1,2, 6:9)], petrel[, 3],
##D   petrel.grid[, c(1,2)], petrel.grid, family = "gaussian", n.cores=6,
##D   nmax = 12)
##D names(gbmidwpred1)
## End(Not run)




cleanEx()
nameEx("gbmokcv")
### * gbmokcv

flush(stderr()); flush(stdout())

### Name: gbmokcv
### Title: Cross validation, n-fold for the hybrid method of generalized
###   boosted regression modeling and ordinary kriging (gbmok)
### Aliases: gbmokcv

### ** Examples

## Not run: 
##D data(sponge)
##D 
##D gbmokcv1 <- gbmokcv(sponge[, c(1,2)], sponge[,-c(3)], sponge[, 3],
##D cv.fold = 10, family = "poisson", n.cores=2, predacc = "ALL")
##D gbmokcv1
##D 
##D n <- 20 # number of iterations, 60 to 100 is recommended.
##D VEcv <- NULL
##D for (i in 1:n) {
##D gbmokcv1 <- gbmokcv(sponge[, c(1,2)], sponge[, -c(3)], sponge[, 3],
##D cv.fold = 10, family = "poisson", n.cores=2, predacc = "VEcv")
##D VEcv [i] <- gbmokcv1
##D }
##D plot(VEcv ~ c(1:n), xlab = "Iteration for gbmok", ylab = "VEcv (%)")
##D points(cumsum(VEcv) / c(1:n) ~ c(1:n), col = 2)
##D abline(h = mean(VEcv), col = 'blue', lwd = 2)
## End(Not run)




cleanEx()
nameEx("gbmokgbmidwcv")
### * gbmokgbmidwcv

flush(stderr()); flush(stdout())

### Name: gbmokgbmidwcv
### Title: Cross validation, n-fold for the average of the hybrid method of
###   generalized boosted regression modeling and ordinary kriging and the
###   hybrid method of generalized boosted regression modeling and inverse
###   distance weighting (gbmokgbmidw)
### Aliases: gbmokgbmidwcv

### ** Examples

## Not run: 
##D data(sponge)
##D 
##D gbmokgbmidw1 <- gbmokgbmidwcv(sponge[, c(1,2)], sponge[, -c(3)], sponge[, 3],
##D cv.fold = 10, family = "poisson", n.cores=2, predacc = "ALL")
##D gbmokgbmidw1
##D 
##D n <- 20 # number of iterations, 60 to 100 is recommended.
##D VEcv <- NULL
##D for (i in 1:n) {
##D gbmokgbmidw1 <- gbmokgbmidwcv(sponge[, c(1,2)], sponge[, -c(3)], sponge[, 3],
##D cv.fold = 10, family = "poisson", n.cores=2, predacc = "VEcv")
##D VEcv [i] <- gbmokgbmidw1
##D }
##D plot(VEcv ~ c(1:n), xlab = "Iteration for gbmokgbmidw", ylab = "VEcv (%)")
##D points(cumsum(VEcv) / c(1:n) ~ c(1:n), col = 2)
##D abline(h = mean(VEcv), col = 'blue', lwd = 2)
## End(Not run)




cleanEx()
nameEx("gbmokgbmidwpred")
### * gbmokgbmidwpred

flush(stderr()); flush(stdout())

### Name: gbmokgbmidwpred
### Title: Generate spatial predictions using the average of the hybrid
###   method of generalized boosted regression modeling and ordinary
###   kriging and the hybrid method of generalized boosted regression
###   modeling and inverse distance weighting (gbmokgbmidw)
### Aliases: gbmokgbmidwpred

### ** Examples

## Not run: 
##D data(petrel)
##D data(petrel.grid)
##D gbmokgbmidwpred1 <- gbmokgbmidwpred(petrel[, c(1,2)], petrel[, c(1,2, 6:9)],
##D petrel[, 3], petrel.grid[, c(1,2)], petrel.grid, family = "gaussian",
##D n.cores=6, nmaxidw = 12, nmaxok = 12, vgm.args = ("Sph"))
##D names(gbmokgbmidwpred1)
## End(Not run)




cleanEx()
nameEx("gbmokpred")
### * gbmokpred

flush(stderr()); flush(stdout())

### Name: gbmokpred
### Title: Generate spatial predictions using the hybrid method of
###   generalized boosted regression modeling and ordinary kriging (gbmok)
### Aliases: gbmokpred

### ** Examples

## Not run: 
##D data(petrel)
##D data(petrel.grid)
##D gbmokpred1 <- gbmokpred(petrel[, c(1,2)], petrel[, c(1,2, 6:9)], petrel[, 3],
##D   petrel.grid[, c(1,2)], petrel.grid, family = "gaussian", n.cores=6,
##D   nmax = 12, vgm.args = ("Sph"))
##D names(gbmokpred1)
## End(Not run)




cleanEx()
nameEx("gbmpred")
### * gbmpred

flush(stderr()); flush(stdout())

### Name: gbmpred
### Title: Generate spatial predictions using generalized boosted
###   regression modeling (gbm)
### Aliases: gbmpred

### ** Examples

## Not run: 
##D data(sponge)
##D data(sponge.grid)
##D gbmpred1 <- gbmpred(sponge[, -c(3)], sponge[, 3], sponge.grid[, c(1:2)],
##D sponge.grid, family = "poisson", n.cores=2)
##D names(gbmpred1)
## End(Not run)




cleanEx()
nameEx("idwcv")
### * idwcv

flush(stderr()); flush(stdout())

### Name: idwcv
### Title: Cross validation, n-fold for inverse distance weighting (IDW)
### Aliases: idwcv

### ** Examples

## Not run: 
##D library(sp)
##D data(swmud)
##D data(petrel)
##D 
##D idwcv1 <- idwcv(swmud[, c(1,2)], swmud[, 3], nmax = 12, idp = 2)
##D idwcv1
##D 
##D n <- 20 # number of iterations, 60 to 100 is recommended.
##D VEcv <- NULL
##D for (i in 1:n) {
##D idwcv1 <- idwcv(petrel[, c(1,2)], petrel[, 3], nmax = 12, predacc = "VEcv")
##D VEcv [i] <- idwcv1
##D }
##D plot(VEcv ~ c(1:n), xlab = "Iteration for IDW", ylab = "VEcv (%)")
##D points(cumsum(VEcv) / c(1:n) ~ c(1:n), col = 2)
##D abline(h = mean(VEcv), col = 'blue', lwd=2)
##D 
##D n <- 20 # number of iterations, 60 to 100 is recommended.
##D measures <- NULL
##D for (i in 1:n) {
##D idwcv1 <- idwcv(swmud[, c(1,2)], swmud[, 3], predacc = "ALL")
##D measures <- rbind(measures, idwcv1$vecv)
##D }
##D plot(measures ~ c(1:n), xlab = "Iteration for IDW", ylab="VEcv (%)")
##D points(cumsum(measures) / c(1:n) ~ c(1:n), col = 2)
##D abline(h = mean(measures), col = 'blue', lwd = 2)
## End(Not run)




cleanEx()
nameEx("idwpred")
### * idwpred

flush(stderr()); flush(stdout())

### Name: idwpred
### Title: Generate spatial predictions using inverse distance weighting
###   (IDW)
### Aliases: idwpred

### ** Examples

## Not run: 
##D library(sp)
##D data(swmud)
##D data(sw)
##D idwpred1 <- idwpred(swmud[, c(1,2)], swmud[, 3], sw, nmax = 12, idp = 2)
##D names(idwpred1)
## End(Not run)




cleanEx()
nameEx("okcv")
### * okcv

flush(stderr()); flush(stdout())

### Name: okcv
### Title: Cross validation, n-fold for ordinary kriging (OK)
### Aliases: okcv

### ** Examples

## Not run: 
##D library(sp)
##D data(swmud)
##D data(petrel)
##D 
##D okcv1 <- okcv(swmud[, c(1,2)], swmud[, 3], nmax = 7, transformation =
##D "arcsine", vgm.args = ("Sph"), predacc = "VEcv")
##D okcv1
##D 
##D n <- 20 # number of iterations,60 to 100 is recommended.
##D VEcv <- NULL
##D for (i in 1:n) {
##D okcv1 <- okcv(petrel[, c(1,2)], petrel[, 5], nmax = 12,
##D transformation = "arcsine", predacc = "VEcv")
##D VEcv [i] <- okcv1
##D }
##D plot(VEcv ~ c(1:n), xlab = "Iteration for OK", ylab = "VEcv (%)")
##D points(cumsum(VEcv) / c(1:n) ~ c(1:n), col = 2)
##D abline(h = mean(VEcv), col = 'blue', lwd = 2)
##D 
##D n <- 20 # number of iterations, 60 to 100 is recommended.
##D measures <- NULL
##D for (i in 1:n) {
##D okcv1 <- okcv(petrel[, c(1,2)], petrel[, 3], nmax = 12, transformation =
##D "arcsine", predacc = "ALL")
##D measures <- rbind(measures, okcv1$vecv)
##D }
##D plot(measures ~ c(1:n), xlab = "Iteration for OK", ylab = "VEcv (%)")
##D points(cumsum(measures) / c(1:n) ~ c(1:n), col = 2)
##D abline(h = mean(measures), col = 'blue', lwd = 2)
## End(Not run)




cleanEx()
nameEx("okpred")
### * okpred

flush(stderr()); flush(stdout())

### Name: okpred
### Title: Generate spatial predictions using ordinary kriging (OK)
### Aliases: okpred

### ** Examples

## Not run: 
##D library(sp)
##D data(swmud)
##D data(sw)
##D okpred1 <- okpred(swmud[, c(1,2)], swmud[, 3], sw, nmax = 7, transformation =
##D "arcsine", vgm.args = ("Sph"))
##D names(okpred1)
## End(Not run)




cleanEx()
nameEx("pred.acc")
### * pred.acc

flush(stderr()); flush(stdout())

### Name: pred.acc
### Title: Predictive error and accuracy measures for predictive models
###   based on cross-validation
### Aliases: pred.acc

### ** Examples

set.seed(1234)
x <- sample(1:30, 30)
e <- rnorm(30, 1)
y <- x + e
pred.acc(x, y)

y <- 0.8 * x + e
pred.acc(x, y)




cleanEx()
nameEx("rfidwcv")
### * rfidwcv

flush(stderr()); flush(stdout())

### Name: rfidwcv
### Title: Cross validation, n-fold for the hybrid method of random forest
###   and inverse distance weighting (RFIDW)
### Aliases: rfidwcv

### ** Examples

## Not run: 
##D data(petrel)
##D 
##D rfidwcv1 <- rfidwcv(petrel[, c(1,2)], petrel[, c(1,2, 6:9)], petrel[, 5],
##D predacc = "ALL")
##D rfidwcv1
##D 
##D n <- 20 # number of iterations, 60 to 100 is recommended.
##D VEcv <- NULL
##D for (i in 1:n) {
##D rfidwcv1 <- rfidwcv(petrel[, c(1,2)], petrel[, c(1,2,6:9)], petrel[, 5],
##D predacc = "VEcv")
##D VEcv [i] <- rfidwcv1
##D }
##D plot(VEcv ~ c(1:n), xlab = "Iteration for RFIDW", ylab = "VEcv (%)")
##D points(cumsum(VEcv) / c(1:n) ~ c(1:n), col = 2)
##D abline(h = mean(VEcv), col = 'blue', lwd = 2)
##D 
##D n <- 20 # number of iterations, 60 to 100 is recommended.
##D measures <- NULL
##D for (i in 1:n) {
##D rfidwcv1 <- rfidwcv(petrel[, c(1,2)], petrel[, c(1,2,6:9)], petrel[, 5],
##D predacc = "ALL")
##D measures <- rbind(measures, rfidwcv1$vecv)
##D }
##D plot(measures ~ c(1:n), xlab = "Iteration for RFIDW", ylab = "VEcv (%)")
##D points(cumsum(measures) / c(1:n) ~ c(1:n), col = 2)
##D abline(h = mean(measures), col = 'blue', lwd = 2)
## End(Not run)




cleanEx()
nameEx("rfidwpred")
### * rfidwpred

flush(stderr()); flush(stdout())

### Name: rfidwpred
### Title: Generate spatial predictions using the hybrid method of random
###   forest and inverse distance weighting (RFIDW)
### Aliases: rfidwpred

### ** Examples

## Not run: 
##D data(petrel)
##D data(petrel.grid)
##D rfidwpred1 <- rfidwpred(petrel[, c(1,2)], petrel[, c(1,2, 6:9)], petrel[, 3],
##D petrel.grid[, c(1,2)], petrel.grid, ntree = 500, idp = 2, nmax = 12)
##D names(rfidwpred1)
## End(Not run)




cleanEx()
nameEx("rfokcv")
### * rfokcv

flush(stderr()); flush(stdout())

### Name: rfokcv
### Title: Cross validation, n-fold for the hybrid method of random forest
###   and ordinary kriging (RFOK)
### Aliases: rfokcv

### ** Examples

## Not run: 
##D data(petrel)
##D 
##D rfokcv1 <- rfokcv(petrel[, c(1,2)], petrel[, c(1,2, 6:9)], petrel[, 5],
##D predacc = "ALL")
##D rfokcv1
##D 
##D n <- 20 # number of iterations, 60 to 100 is recommended.
##D VEcv <- NULL
##D for (i in 1:n) {
##D rfokcv1 <- rfokcv(petrel[, c(1,2)], petrel[, c(1,2,6:9)], petrel[, 5],
##D predacc = "VEcv")
##D VEcv [i] <- rfokcv1
##D }
##D plot(VEcv ~ c(1:n), xlab = "Iteration for RFOK", ylab = "VEcv (%)")
##D points(cumsum(VEcv) / c(1:n) ~ c(1:n), col = 2)
##D abline(h = mean(VEcv), col = 'blue', lwd = 2)
##D 
##D n <- 20 # number of iterations, 60 to 100 is recommended.
##D measures <- NULL
##D for (i in 1:n) {
##D rfokcv1 <- rfokcv(petrel[, c(1,2)], petrel[, c(1,2,6:9)], petrel[, 5],
##D predacc = "ALL")
##D measures <- rbind(measures, rfokcv1$vecv)
##D }
##D plot(measures ~ c(1:n), xlab = "Iteration for RFOK", ylab = "VEcv (%)")
##D points(cumsum(measures) / c(1:n) ~ c(1:n), col = 2)
##D abline(h = mean(measures), col = 'blue', lwd = 2)
## End(Not run)




cleanEx()
nameEx("rfokpred")
### * rfokpred

flush(stderr()); flush(stdout())

### Name: rfokpred
### Title: Generate spatial predictions using the hybrid method of random
###   forest and ordinary kriging (RFOK)
### Aliases: rfokpred

### ** Examples

## Not run: 
##D data(petrel)
##D data(petrel.grid)
##D rfokpred1 <- rfokpred(petrel[, c(1,2)], petrel[, c(1,2, 6:9)], petrel[, 3],
##D petrel.grid[, c(1,2)], petrel.grid, ntree = 500, nmax = 12, vgm.args =
##D ("Sph"))
##D names(rfokpred1)
## End(Not run)




cleanEx()
nameEx("rfokrfidwcv")
### * rfokrfidwcv

flush(stderr()); flush(stdout())

### Name: rfokrfidwcv
### Title: Cross validation, n-fold for the average of the hybrid method of
###   random forest and ordinary kriging and the hybrid method of random
###   forest and inverse distance weighting (RFOKRFIDW)
### Aliases: rfokrfidwcv

### ** Examples

## Not run: 
##D data(petrel)
##D 
##D rfokrfidwcv1 <- rfokrfidwcv(petrel[, c(1,2)], petrel[, c(1,2, 6:9)], petrel[, 5],
##D predacc = "ALL")
##D rfokrfidwcv1
##D 
##D n <- 20 # number of iterations, 60 to 100 is recommended.
##D VEcv <- NULL
##D for (i in 1:n) {
##D rfokrfidwcv1 <- rfokrfidwcv(petrel[, c(1,2)], petrel[, c(1,2,6:9)], petrel[, 5],
##D predacc = "VEcv")
##D VEcv [i] <- rfokrfidwcv1
##D }
##D plot(VEcv ~ c(1:n), xlab = "Iteration for RFOKRFIDW", ylab = "VEcv (%)")
##D points(cumsum(VEcv) / c(1:n) ~ c(1:n), col = 2)
##D abline(h = mean(VEcv), col = 'blue', lwd = 2)
##D 
##D n <- 20 # number of iterations, 60 to 100 is recommended.
##D measures <- NULL
##D for (i in 1:n) {
##D rfokrfidwcv1 <- rfokrfidwcv(petrel[, c(1,2)], petrel[, c(1,2,6:9)], petrel[, 5],
##D predacc = "ALL")
##D measures <- rbind(measures, rfokrfidwcv1$vecv)
##D }
##D plot(measures ~ c(1:n), xlab = "Iteration for RFOKRFIDW", ylab = "VEcv (%)")
##D points(cumsum(measures) / c(1:n) ~ c(1:n), col = 2)
##D abline(h = mean(measures), col = 'blue', lwd = 2)
## End(Not run)




cleanEx()
nameEx("rfokrfidwpred")
### * rfokrfidwpred

flush(stderr()); flush(stdout())

### Name: rfokrfidwpred
### Title: Generate spatial predictions using the average of the hybrid
###   method of random forest and ordinary kriging and the hybrid method of
###   random forest and inverse distance weighting (RFOKRFIDW)
### Aliases: rfokrfidwpred

### ** Examples

## Not run: 
##D data(petrel)
##D data(petrel.grid)
##D rfokrfidwpred1 <- rfokrfidwpred(petrel[, c(1,2)], petrel[, c(1,2, 6:9)],
##D petrel[, 3], petrel.grid[, c(1,2)], petrel.grid, ntree = 500, idp = 2,
##D nmaxok = 12, nmaxidw = 12)
##D names(rfokrfidwpred1)
## End(Not run)




cleanEx()
nameEx("rfpred")
### * rfpred

flush(stderr()); flush(stdout())

### Name: rfpred
### Title: Generate spatial predictions using random forest (RF)
### Aliases: rfpred

### ** Examples

## Not run: 
##D data(petrel)
##D data(petrel.grid)
##D rfpred1 <- rfpred(petrel[, c(1,2, 6:9)], petrel[, 5], petrel.grid[, c(1,2)],
##D petrel.grid, ntree = 500)
##D names(rfpred1)
## End(Not run)




cleanEx()
nameEx("rgcv")
### * rgcv

flush(stderr()); flush(stdout())

### Name: rgcv
### Title: Cross validation, n-fold for random forest in ranger (RG)
### Aliases: rgcv

### ** Examples

## Not run: 
##D data(hard)
##D data(petrel)
##D 
##D rgcv1 <- rgcv(petrel[, c(1,2, 6:9)], petrel[, 5], predacc = "ALL")
##D rgcv1
##D 
##D n <- 20 # number of iterations, 60 to 100 is recommended.
##D VEcv <- NULL
##D for (i in 1:n) {
##D rgcv1 <- rgcv(petrel[, c(1,2,6:9)], petrel[, 5], predacc = "VEcv")
##D VEcv [i] <- rgcv1
##D }
##D plot(VEcv ~ c(1:n), xlab = "Iteration for RF", ylab = "VEcv (%)")
##D points(cumsum(VEcv) / c(1:n) ~ c(1:n), col = 2)
##D abline(h = mean(VEcv), col = 'blue', lwd = 2)
##D 
##D n <- 20 # number of iterations, 60 to 100 is recommended.
##D measures <- NULL
##D for (i in 1:n) {
##D rgcv1 <- rgcv(hard[, c(4:6)], hard[, 17])
##D measures <- rbind(measures, rgcv1$ccr) # for kappa, replace ccr with kappa
##D }
##D plot(measures ~ c(1:n), xlab = "Iteration for RF", ylab = "Correct
##D classification rate  (%)")
##D points(cumsum(measures) / c(1:n) ~ c(1:n), col = 2)
##D abline(h = mean(measures), col = 'blue', lwd = 2)
## End(Not run)




cleanEx()
nameEx("rgidwcv")
### * rgidwcv

flush(stderr()); flush(stdout())

### Name: rgidwcv
### Title: Cross validation, n-fold for the hybrid method of random forest
###   in ranger and inverse distance weighting (RGIDW)
### Aliases: rgidwcv

### ** Examples

## Not run: 
##D data(petrel)
##D 
##D rgidwcv1 <- rgidwcv(petrel[, c(1,2)], petrel[, c(1,2, 6:9)], petrel[, 5],
##D predacc = "ALL")
##D rgidwcv1
##D 
##D n <- 20 # number of iterations, 60 to 100 is recommended.
##D VEcv <- NULL
##D for (i in 1:n) {
##D rgidwcv1 <- rgidwcv(petrel[, c(1,2)], petrel[, c(1,2,6:9)], petrel[, 5],
##D predacc = "VEcv")
##D VEcv [i] <- rgidwcv1
##D }
##D plot(VEcv ~ c(1:n), xlab = "Iteration for RFIDW", ylab = "VEcv (%)")
##D points(cumsum(VEcv) / c(1:n) ~ c(1:n), col = 2)
##D abline(h = mean(VEcv), col = 'blue', lwd = 2)
##D 
##D n <- 20 # number of iterations, 60 to 100 is recommended.
##D measures <- NULL
##D for (i in 1:n) {
##D rgidwcv1 <- rgidwcv(petrel[, c(1,2)], petrel[, c(1,2,6:9)], petrel[, 5],
##D predacc = "ALL")
##D measures <- rbind(measures, rgidwcv1$vecv)
##D }
##D plot(measures ~ c(1:n), xlab = "Iteration for RFIDW", ylab = "VEcv (%)")
##D points(cumsum(measures) / c(1:n) ~ c(1:n), col = 2)
##D abline(h = mean(measures), col = 'blue', lwd = 2)
## End(Not run)




cleanEx()
nameEx("rgidwpred")
### * rgidwpred

flush(stderr()); flush(stdout())

### Name: rgidwpred
### Title: Generate spatial predictions using the hybrid method of random
###   forest in ranger and inverse distance weighting (RGIDW)
### Aliases: rgidwpred

### ** Examples

## Not run: 
##D data(petrel)
##D data(petrel.grid)
##D rgidwpred1 <- rgidwpred(petrel[, c(1,2)], petrel[, c(1,2, 6:9)], petrel[, 3],
##D petrel.grid[, c(1,2)], petrel.grid, num.trees = 500, idp = 2, nmax = 12)
##D names(rgidwpred1)
## End(Not run)




cleanEx()
nameEx("rgokcv")
### * rgokcv

flush(stderr()); flush(stdout())

### Name: rgokcv
### Title: Cross validation, n-fold for the hybrid method of random forest
###   in ranger and ordinary kriging (RGFOK)
### Aliases: rgokcv

### ** Examples

## Not run: 
##D data(petrel)
##D 
##D rgokcv1 <- rgokcv(petrel[, c(1,2)], petrel[, c(1,2, 6:9)], petrel[, 5],
##D predacc = "ALL")
##D rgokcv1
##D 
##D n <- 20 # number of iterations, 60 to 100 is recommended.
##D VEcv <- NULL
##D for (i in 1:n) {
##D rgokcv1 <- rgokcv(petrel[, c(1,2)], petrel[, c(1,2,6:9)], petrel[, 5],
##D predacc = "VEcv")
##D VEcv [i] <- rgokcv1
##D }
##D plot(VEcv ~ c(1:n), xlab = "Iteration for RFOK", ylab = "VEcv (%)")
##D points(cumsum(VEcv) / c(1:n) ~ c(1:n), col = 2)
##D abline(h = mean(VEcv), col = 'blue', lwd = 2)
##D 
##D n <- 20 # number of iterations, 60 to 100 is recommended.
##D measures <- NULL
##D for (i in 1:n) {
##D rgokcv1 <- rgokcv(petrel[, c(1,2)], petrel[, c(1,2,6:9)], petrel[, 5],
##D predacc = "ALL")
##D measures <- rbind(measures, rgokcv1$vecv)
##D }
##D plot(measures ~ c(1:n), xlab = "Iteration for RFOK", ylab = "VEcv (%)")
##D points(cumsum(measures) / c(1:n) ~ c(1:n), col = 2)
##D abline(h = mean(measures), col = 'blue', lwd = 2)
## End(Not run)




cleanEx()
nameEx("rgokpred")
### * rgokpred

flush(stderr()); flush(stdout())

### Name: rgokpred
### Title: Generate spatial predictions using the hybrid method of random
###   forest in ranger and ordinary kriging (RGOK)
### Aliases: rgokpred

### ** Examples

## Not run: 
##D data(petrel)
##D data(petrel.grid)
##D rgokpred1 <- rgokpred(petrel[, c(1,2)], petrel[, c(1,2, 6:9)], petrel[, 3],
##D petrel.grid[, c(1,2)], petrel.grid, num.trees = 500, nmax = 12, vgm.args =
##D ("Sph"))
##D names(rgokpred1)
## End(Not run)




cleanEx()
nameEx("rgokrgidwcv")
### * rgokrgidwcv

flush(stderr()); flush(stdout())

### Name: rgokrgidwcv
### Title: Cross validation, n-fold for the average of the hybrid method of
###   random forest in ranger (RG) and ordinary kriging and the hybrid
###   method of RG and inverse distance weighting (RGOKRGIDW)
### Aliases: rgokrgidwcv

### ** Examples

## Not run: 
##D data(petrel)
##D 
##D rgokrgidwcv1 <- rgokrgidwcv(petrel[, c(1,2)], petrel[, c(1,2, 6:9)], petrel[, 5],
##D predacc = "ALL")
##D rgokrgidwcv1
##D 
##D n <- 20 # number of iterations, 60 to 100 is recommended.
##D VEcv <- NULL
##D for (i in 1:n) {
##D rgokrgidwcv1 <- rgokrgidwcv(petrel[, c(1,2)], petrel[, c(1,2,6:9)], petrel[, 5],
##D predacc = "VEcv")
##D VEcv [i] <- rgokrgidwcv1
##D }
##D plot(VEcv ~ c(1:n), xlab = "Iteration for RFOKRFIDW", ylab = "VEcv (%)")
##D points(cumsum(VEcv) / c(1:n) ~ c(1:n), col = 2)
##D abline(h = mean(VEcv), col = 'blue', lwd = 2)
##D 
##D n <- 20 # number of iterations, 60 to 100 is recommended.
##D measures <- NULL
##D for (i in 1:n) {
##D rgokrgidwcv1 <- rgokrgidwcv(petrel[, c(1,2)], petrel[, c(1,2,6:9)], petrel[, 5],
##D predacc = "ALL")
##D measures <- rbind(measures, rgokrgidwcv1$vecv)
##D }
##D plot(measures ~ c(1:n), xlab = "Iteration for RFOKRFIDW", ylab = "VEcv (%)")
##D points(cumsum(measures) / c(1:n) ~ c(1:n), col = 2)
##D abline(h = mean(measures), col = 'blue', lwd = 2)
## End(Not run)




cleanEx()
nameEx("rgokrgidwpred")
### * rgokrgidwpred

flush(stderr()); flush(stdout())

### Name: rgokrgidwpred
### Title: Generate spatial predictions using the average of the hybrid
###   method of random forest in ranger (RG) and ordinary kriging and the
###   hybrid method of RG and inverse distance weighting (RGOKRGIDW)
### Aliases: rgokrgidwpred

### ** Examples

## Not run: 
##D data(petrel)
##D data(petrel.grid)
##D rgokrgidwpred1 <- rgokrgidwpred(petrel[, c(1,2)], petrel[, c(1,2, 6:9)],
##D petrel[, 3], petrel.grid[, c(1,2)], petrel.grid, num.trees = 500, idp = 2,
##D nmaxok = 12, nmaxidw = 12)
##D names(rgokrgidwpred1)
## End(Not run)




cleanEx()
nameEx("rgpred")
### * rgpred

flush(stderr()); flush(stdout())

### Name: rgpred
### Title: Generate spatial predictions using random forest in ranger (RG)
### Aliases: rgpred

### ** Examples

## Not run: 
##D data(petrel)
##D data(petrel.grid)
##D set.seed(1234)
##D rgpred1 <- rgpred(petrel[, c(1,2, 6:9)], petrel[, 5], petrel.grid[, c(1,2)],
##D petrel.grid, num.trees = 500)
##D names(rgpred1)
## End(Not run)




cleanEx()
nameEx("rvi")
### * rvi

flush(stderr()); flush(stdout())

### Name: rvi
### Title: Relative variable influence based on generalized boosted
###   regression modeling (gbm)
### Aliases: rvi

### ** Examples

## Not run: 
##D data(sponge)
##D set.seed(1234)
##D rvi1 <- rvi(sponge[, -c(3)], sponge[, 3], family = "poisson", n.cores=2)
##D names(ri1)
##D impvar <- (1:ncol(sponge[, -c(3)]))[ri1$var]
## End(Not run)




cleanEx()
nameEx("tovecv")
### * tovecv

flush(stderr()); flush(stdout())

### Name: tovecv
### Title: Convert error measures to vecv
### Aliases: tovecv

### ** Examples

n <- 300
mu <- 15.5
sd <- 8.80
mse <- 50.43
rmse <- sqrt(mse)
rrmse <- rmse / mu * 100
srmse <- rmse / sd
msre <- mse / sd ^ 2
tovecv(n=n, mu=mu, s=sd, m=mse, measure="mse")

tovecv(n=n, mu=mu, s=sd, m=rmse, measure="rmse")

tovecv(n=n, mu=mu, s=sd, m=rrmse, measure="rrmse")

tovecv(n=n, mu=mu, s=sd, m=srmse, measure="srmse")

tovecv(n=n, mu=mu, s=sd, m=msre, measure="msre")




cleanEx()
nameEx("vecv")
### * vecv

flush(stderr()); flush(stdout())

### Name: vecv
### Title: Variance explained by predictive models based on
###   cross-validation
### Aliases: vecv

### ** Examples

set.seed(1234)
x <- sample(1:30, 30)
e <- rnorm(30, 1)
y <- x + e
vecv(x, y)

y <- 0.8 * x + e
vecv(x, y)




### * <FOOTER>
###
cleanEx()
options(digits = 7L)
base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n")
grDevices::dev.off()
###
### Local variables: ***
### mode: outline-minor ***
### outline-regexp: "\\(> \\)?### [*]+" ***
### End: ***
quit('no')
gbm-developers/gbm documentation built on Feb. 16, 2024, 6:13 p.m.