Learn R Programming

sptemExp (version 0.1.4)

abatchModel: A Batch Modeing Training Inner Functions

Description

This function is for a batch training models. The users can call parSpModel rather than this for training of multiple models.

Usage

abatchModel(td,bnd,fS,iF,iT,tidF,tids,mPath,idF="siteid",dateF="date",obsF="obs",nM)

Arguments

td

Training dataset

bnd

Map object used in spatial effect model. For specific format, refer to BayesX

fS

Formular string

iF

Staring time id

iT

Ending time id

tidF

Time field name

tids

Time vector

mPath

The path for the models trained to be saved

idF

location id name

dateF

Date or time field name

obsF

observed value field name

nM

number of models to be trained

Value

The trained models will be saved on the appointed path. No direct output for this function.

Details

This is an inner function to be called by parSpModel.

Examples

Run this code
# NOT RUN {
# }
# NOT RUN {
#An example of PM2.5 data from Shandong

dPath=tempdir()
modelPath=paste(dPath,"/models",sep="")
unlink(modelPath,recursive = TRUE)
dir.create(modelPath)

data("trainsample","bnd")
aform=paste0('logpm25 ~sx(rid,bs ="mrf",map =bnd)+sx(monthAv,bs="rw2")')
aform=paste0(aform,'+sx(ndvi,bs="rw2")+sx(aod,bs="rw2")+sx(wnd_avg,bs="rw2")')

formulaStrs=c(aform)

trainsample$tid=as.numeric(strftime(trainsample$date,format= "%j"))
trainsample$logpm25=log(trainsample$pm25)
tids=c(91)
abatchModel(trainsample,bnd,formulaStrs,1,1,"tid",tids,modelPath,"siteid","date","pm25",3)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab