if (FALSE) {
##### Now we make a model for the risk. We will use an SPDE model with these
##### parameters for the linear predictor on the logist scale, which are chosen
##### to be of practical interest:
beta0=-2.9 # intercept
gamma=-1 # urban effect
rho=(1/3)^2 # spatial variance
effRange = 400 # effective spatial range in km
sigmaEpsilon=sqrt(1/2.5) # cluster (nugget) effect standard deviation
# simulate the population! Note that this produces multiple dense
# nEA x nsim and nIntegrationPoint x nsim matrices. In the future
# sparse matrices will and chunk by chunk computations may be incorporated.
simPop = simPopSPDE(nsim=1, easpa=easpaKenyaNeonatal,
popMat=popMatKenya, targetPopMat=popMatKenyaNeonatal,
poppsub=poppsubKenya, spdeMesh=kenyaMesh,
margVar=rho, sigmaEpsilonSq=sigmaEpsilon^2,
gamma=gamma, effRange=effRange, beta0=beta0,
seed=123, inla.seed=12, nHHSampled=25,
stratifyByUrban=TRUE, subareaLevel=TRUE,
doFineScaleRisk=TRUE,
min1PerSubarea=TRUE)
pixelPop = simPop$pixelPop
subareaPop = pixelPopToArea(pixelLevelPop=pixelPop, eaSamples=pixelPop$eaSamples,
areas=popMatKenya$subarea, stratifyByUrban=TRUE,
targetPopMat=popMatKenyaNeonatal, doFineScaleRisk=TRUE)
# get areas associated with each subarea for aggregation
tempAreasFrom = popMatKenya$subarea
tempAreasTo = popMatKenya$area
areasFrom = sort(unique(tempAreasFrom))
areasToI = match(areasFrom, tempAreasFrom)
areasTo = tempAreasTo[areasToI]
# do the aggregation from subareas to areas
outAreaLevel = areaPopToArea(areaLevelPop=subareaPop,
areasFrom=areasFrom, areasTo=areasTo,
stratifyByUrban=TRUE, doFineScaleRisk=TRUE)
}
Run the code above in your browser using DataLab