data(stsNewport)
salm.Normal <- list()
salmDelayAsym <- list()
for (week in 43:45){
listWeeks <- as.Date(row.names(stsNewport@control$reportingTriangle$n), origin="1970-01-01")
dateObs <- listWeeks[isoWeekYear(listWeeks)$ISOYear==2011&
isoWeekYear(listWeeks)$ISOWeek==(week)]
stsC <- sts_observation(stsNewport,
dateObservation=dateObs,
cut=TRUE)
inWeeks <- which(formatDate(epoch(stsC), " isoWeekYear(as.Date(epoch(stsC)))$ISOWeek>=40 &
isoWeekYear(as.Date(epoch(stsC)))$ISOWeek<=48)
rangeTest <- inWeeks
alpha <- 0.07
# isoWeekYear(epoch(dataTrunc))$ISOWeek >39 &
# isoWeekYear(epoch(dataTrunc))$ISOWeek <=47)
# Control slot for Noufaily method
controlNoufaily <- list(range=rangeTest,noPeriods=10,
b=4,w=3,weightsThreshold=2.58,pastWeeksNotIncluded=26,
pThresholdTrend=1,thresholdMethod="nbPlugin",alpha=alpha*2,
limit54=c(0,50))
# Control slot for the Proposed algorithm with D=0 correction
controlNormal <- list(range = rangeTest, b = 4, w = 3,
reweight = TRUE, mc.munu=10000, mc.y=100,
verbose = FALSE,
alpha = alpha, trend = TRUE,
limit54=c(0,50),
noPeriods = 10, pastWeeksNotIncluded = 26,
delay=FALSE)
# Control slot for the Proposed algorithm with D=10 correction
controlDelayNorm <- list(range = rangeTest, b = 4, w = 3,
reweight = FALSE, mc.munu=10000, mc.y=100,
verbose = FALSE,
alpha = alpha, trend = TRUE,
limit54=c(0,50),
noPeriods = 10, pastWeeksNotIncluded = 26,
delay=TRUE,inferenceMethod="asym")
set.seed(1)
salm.Normal[[week]] <- farringtonFlexible(stsC, controlNoufaily)
salmDelayAsym[[week]] <- bodaDelay(stsC, controlDelayNorm)
}
par(mfrow=c(2,3))
lapply(salmDelayAsym[c(43,44,45)],plot, legend=NULL, main="", ylim=c(0,35))
lapply(salm.Normal[c(43,44,45)],plot, legend=NULL, main="", ylim=c(0,35))
Run the code above in your browser using DataLab