Learn R Programming

SPOT (version 2.1.10)

generateMCPrediction: generateMCPrediction

Description

Predict results on test data using the tuned MarkovChain mode. Result has the required data format for a submission to the Kaggle COVID-19 challenge.

Usage

generateMCPrediction(
  testData,
  models,
  startSimulation = "2020-01-22",
  write = FALSE
)

Arguments

testData

'data.frame': obs. of 3 variables:

ForecastId

int 1 2 3 4 5 6 7 8 9 10 ...

Region

Factor w/ 313 levels "Afghanistan/",..: 1 1 1 1 1 1 1 1 1 1 ...

Date

Date, format: "2020-04-02" "2020-04-03" "2020-04-04" "2020-04-05" ...

models

'data.frame': obs. of 7 variables:

p

num [0;1] proportion of confirmed cases

beta

num 13.8 13.8 16.3 11.5 29.2 ...

gamma

num 13.8 13.8 16.3 11.5 29.2 ...

CFR

num 0.14 0.14 0.2319 0.0312 0.0705 ...

cost

num 658 256 1207 1091 300 ...

region

chr, e.g., "Afghanistan/" "Albania/" "Algeria/" "Andorra/" ...

startSimulation

chr start of the simulation period, e.g., "2020-01-22". startSimulation must be at or before the Date from testData. Simulations can start earlier, because some use R=0. This enables a warm-up period.

write

logical. Default FALSE. If TRUE, results are written to the file submit.csv.

Value

returns data.frame with obs. of the following 3 variables:

ForecastId

int: Forecast Id taken from the regionTest data set.

ConfirmedCases

num: Cumulative number of confirmed cases.

Fatalities

num: Cumulative number of fatalities.

Details

Output from parseTunedRegionModel is processed-

Examples

Run this code
# NOT RUN {
require(SimInf)
data <- preprocessInputData(regionTrain, regionPopulation)
testData <- preprocessTestData(regionTest)
# Select the first region:
testData <- testData[testData$Region==levels(testData$Region)[1], ]
testData$Region <- droplevels(testData$Region)
# Very small number of function evaluations:
n <- 6
res <- lapply(data[1], tuneRegionModel, pops=NULL, 
control=list(funEvals=n, designControl=list(size=5), model = buildLM))
parsedList <- parseTunedRegionModel(res)
pred <- generateMCPrediction(testData = testData, models = parsedList$models, write = FALSE)
# }

Run the code above in your browser using DataLab