knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(malariaAtlas); library(pr2ar); library(data.table)
## Choose location and years of estimation
loc <- "UGA"
years <- 2000:2015

## Pull shapefile and PfPR raster
shp <- getShp(ISO = loc)
PfPR2_10 <- getRaster(surface = "Plasmodium falciparum PR2-10", shp = shp, year = years)
PfPR2_10_df <- as.MAPraster(PfPR2_10)
autoplot(PfPR2_10_df, shp_df = shp)

## reformation into a matrix
pixPerRast <- table(PfPR2_10_df$raster_name)[[1]]
M = matrix(PfPR2_10_df$z, nrow = pixPerRast, ncol = length(years))
matplot(years, t(M[sample(1:nrow(M), 10),]), type = "l", )

# Set paramaeters of model
PAR = list(A = 0.1, rho = 0.6, Q = 0.95, In = 5, Cn = 2, dt = 10)

i = 650
AR = PR2AR(M[i,], Tx = rep(0.4, length(M[i,])), PAR = PAR)

plot(years[-1], M[i,-1], type = 'l', ylim = c(0, 1), xlab = "Years",  ylab = "Rate")
lines(years[-1], AR, lty = "dashed")
legend("topright",  legend = c("PfPR", "Attack-rate"), lty = 1:2)


# apply(M, 1, PR2AR, Tx = rep(0.1, length(years)),PAR = PAR)


aucarter/pr2ar documentation built on Nov. 3, 2019, 1:59 p.m.