Optimisers for fitting model parameters to spatial data
See RFfit
for a detailed description of
the fitting procedure.
optimiser
takes one of the values
"optim"
, "optimx"
, "soma"
, "nloptr"
,
"GenSA"
, "minqa"
, "pso"
or "DEoptim"
,
see the corresponding packages for a description.
If optimiser="nloptr"
, then the additional parameter
algorithm
must be given which takes the values
"NLOPT_GN_DIRECT"
,
"NLOPT_GN_DIRECT_L"
,
"NLOPT_GN_DIRECT_L_RAND"
,
"NLOPT_GN_DIRECT_NOSCAL"
,
"NLOPT_GN_DIRECT_L_NOSCAL"
,
"NLOPT_GN_DIRECT_L_RAND_NOSCAL"
,
"NLOPT_GN_ORIG_DIRECT"
,
"NLOPT_GN_ORIG_DIRECT_L"
,
"NLOPT_LN_PRAXIS"
,
"NLOPT_GN_CRS2_LM"
,
"NLOPT_LN_COBYLA"
,
"NLOPT_LN_NELDERMEAD"
,
"NLOPT_LN_SBPLX"
,
"NLOPT_LN_BOBYQA"
,
"NLOPT_GN_ISRES"
,
see nloptr for a description.
Martin Schlather, schlather@math.uni-mannheim.de, https://www.wim.uni-mannheim.de/schlather/
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set ## RFoptions(seed=NA) to make them all random again ## Not run: ## Here some alternative optimisers to 'optim' are considered. ## All but the \pkg{nloptr} algorithms are largely slower than 'optim'. ## Only a few of them return results as good as 'optim'. data(soil) str(soil) soil <- RFspatialPointsDataFrame( coords = soil[ , c("x.coord", "y.coord")], data = soil[ , c("moisture", "NO3.N", "Total.N", "NH4.N", "DOC", "N20N")], RFparams=list(vdim=6, n=1) ) dta <- soil["moisture"] \dontshow{if (RFoptions()$internal$examples_red) { warning("data have been reduced !") All <- 1:7 rm(soil) data(soil) soil <- RFspatialPointsDataFrame( coords = soil[All, c("x.coord", "y.coord")], data = soil[All, c("moisture", "NO3.N", "Total.N", "NH4.N", "DOC", "N20N")], RFparams=list(vdim=6, n=1) ) dta <- soil["moisture"] }} model <- ~1 + RMwhittle(scale=NA, var=NA, nu=NA) + RMnugget(var=NA) \dontshow{if (RFoptions()$internal$examples_red){model<-~1+RMwhittle(scale=NA,var=NA,nu=1/2)}} ## standard optimiser 'optim' print(system.time(fit <- RFfit(model, data=dta))) print(fit) opt <- "optimx" # 30 sec; better result print(system.time(fit2 <- try(RFfit(model, data=dta, optimiser=opt)))) print(fit2) \dontshow{\dontrun{ opt <- "soma" # 450 sec print(system.time(fit2 <- try(RFfit(model, data=dta, optimiser=opt)))) print(fit2) }} opt <- "minqa" # 330 sec print(system.time(fit2 <- try(RFfit(model, data=dta, optimiser=opt)))) print(fit2) opt <- "nloptr" algorithm <- RC_NLOPTR_NAMES \dontshow{if(!interactive()) algorithm <- RC_NLOPTR_NAMES[1]} for (i in 1:length(algorithm)) { print(algorithm[i]) print(system.time(fit2 <- try(RFfit(model, data=dta, optimiser=opt, algorithm=algorithm[i])))) print(fit2) } if (interactive()) { ## the following two optimisers are too slow to be run on CRAN. opt <- "pso" # 600 sec print(system.time(fit2 <- try(RFfit(model, data=dta, optimiser=opt)))) print(fit2) opt <- "GenSA" # 10^4 sec print(system.time(fit2 <- try(RFfit(model, data=dta, optimiser=opt)))) print(fit2) } ## End(Not run)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.