abatchModel: A Batch Modeing Training Inner Functions

Description Usage Arguments Details Value Examples

Description

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

Usage

1
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

Details

This is an inner function to be called by parSpModel.

Value

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#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)

sptemExp documentation built on July 7, 2019, 9:02 a.m.