getSMR-methods | R Documentation |
Calculates the rate of observe value over expected value. It will also merge back the observed value, expected value and the ratio back to the population data set.
## S4 method for signature 'SpatVector,ANY,ANY,ANY,ANY'
getSMR(
popdata, model, casedata, regionCode , regionCodeCases ,
area.scale = 1, sex=c('m','f'),...
)
## S4 method for signature 'list,ANY,ANY,ANY,ANY'
getSMR(
popdata, model, casedata, regionCode , regionCodeCases ,
area.scale=1, sex=c('m','f'), ...
)
## S4 method for signature 'data.frame,ANY,missing,missing,missing'
getSMR(
popdata, model, casedata, regionCode , regionCodeCases ,
area.scale = 1, sex=c('m','f'),...
)
## S4 method for signature 'data.frame,ANY,data.frame,missing,missing'
getSMR(
popdata, model, casedata, regionCode , regionCodeCases ,
area.scale = 1, sex=c('m','f'),...
)
## S4 method for signature 'data.frame,ANY,data.frame,character,missing'
getSMR(
popdata, model, casedata, regionCode , regionCodeCases ,
area.scale = 1, sex=c('m','f'),...
)
## S4 method for signature 'data.frame,ANY,missing,character,missing'
getSMR(
popdata, model, casedata, regionCode , regionCodeCases ,
area.scale = 1, sex=c('m','f'),...
)
## S4 method for signature 'data.frame,ANY,data.frame,character,character'
getSMR(
popdata, model, casedata, regionCode , regionCodeCases ,
area.scale = 1, sex=c('m','f'),...
)
popdata |
the name of population data set |
model |
rates, either fitted model (usually a |
casedata |
the name of case data set |
regionCode |
the name of district area column in population data set |
regionCodeCases |
the name of district area column in case data set |
area.scale |
scale the unit of area. e.g $10^6$: if your spatial coordinates are metres and you want intensity in cases per km2 |
sex |
possible subsetting of cases and population, set |
... |
additional arguments. When |
If model
is numeric, it's assumed to be a vector of rates, with the names of the elements corresponding to columns of the population data set. Names do not need to match exactly (can have M in one set of names, male in another for instance).
Otherwise, model
is passed to the predict
function.
Returns a new population data set contains expected number of cases, observed number of cases and SMR. It has the same format as the population data set which put into the function.
data(kentucky)
kentucky = terra::unwrap(kentucky)
kentucky2 = getSMR(kentucky, larynxRates, larynx,
regionCode="County")
terra::values(kentucky2)[1:10,grep("^F|^M", names(kentucky2), invert=TRUE)]
theBreaks = signif(seq(0, max(kentucky2$SMR, na.rm=TRUE), len=9),1)
theCol = heat.colors(length(theBreaks)-1)
terra::plot(kentucky2, col=theCol, breaks = theBreaks)
legend('left', fill=theCol, legend = paste(theBreaks[-length(theBreaks)], ' - ', theBreaks[-1]))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.