### small examples with earthquake data
data(quakes)
set.seed(2)
quakes <- quakes[ sample(1:nrow(quakes), 50), ]
quakes.geogam <- geoGAM(response = "mag",
covariates = c("depth", "stations"),
data = quakes,
seed = 2,
max.stop = 5,
cores = 1)
summary(quakes.geogam)
# \donttest{
data(quakes)
# create grouped factor with reduced number of levels
quakes$stations <- factor( cut( quakes$stations, breaks = c(0,15,19,23,30,39,132)) )
quakes.geogam <- geoGAM(response = "mag",
covariates = c("stations", "depth"),
coords = c("lat", "long"),
data = quakes,
max.stop = 10,
cores = 1)
summary(quakes.geogam)
summary(quakes.geogam, what = "path")
# }
# \donttest{
## Use soil data set of soil mapping study area near Berne
data(berne)
set.seed(1)
# Split data sets and
# remove rows with missing values in response and covariates
d.cal <- berne[ berne$dataset == "calibration" & complete.cases(berne), ]
d.val <- berne[ berne$dataset == "validation" & complete.cases(berne), ]
### Model selection for continuous response
ph10.geogam <- geoGAM(response = "ph.0.10",
covariates = names(d.cal)[14:ncol(d.cal)],
coords = c("x", "y"),
data = d.cal,
offset = TRUE,
sets = mboost::cv(rep(1, nrow(d.cal)), type = "kfold"),
validation.data = d.val,
cores = 1)
summary(ph10.geogam)
summary(ph10.geogam, what = "path")
### Model selection for binary response
waterlog100.geogam <- geoGAM(response = "waterlog.100",
covariates = names(d.cal)[c(14:54, 56:ncol(d.cal))],
coords = c("x", "y"),
data = d.cal,
offset = FALSE,
sets = sample( cut(seq(1,nrow(d.cal)),breaks=10,labels=FALSE) ),
validation.data = d.val,
cores = 1)
summary(waterlog100.geogam)
summary(waterlog100.geogam, what = "path")
### Model selection for ordered response
dclass.geogam <- geoGAM(response = "dclass",
covariates = names(d.cal)[14:ncol(d.cal)],
coords = c("x", "y"),
data = d.cal,
offset = TRUE,
non.stationary = TRUE,
seed = 1,
validation.data = d.val,
cores = 1)
summary(dclass.geogam)
summary(dclass.geogam, what = "path")
# }
Run the code above in your browser using DataLab