Learn R Programming

diseasemapping (version 2.0.6)

getSMR-methods: Calculate the standardized mortality/morbidity ratios

Description

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.

Usage

# S4 method for SpatVector,ANY,ANY,ANY,ANY
getSMR(
popdata, model, casedata, regionCode , regionCodeCases , 
area.scale = 1,  sex=c('m','f'),...
)
# S4 method for list,ANY,ANY,ANY,ANY
getSMR(
popdata, model, casedata, regionCode , regionCodeCases , 
area.scale=1, sex=c('m','f'), ...
)
# S4 method for data.frame,ANY,missing,missing,missing
getSMR(
popdata, model, casedata, regionCode , regionCodeCases , 
area.scale = 1,  sex=c('m','f'),...
)

# S4 method for data.frame,ANY,data.frame,missing,missing getSMR( popdata, model, casedata, regionCode , regionCodeCases , area.scale = 1, sex=c('m','f'),... ) # S4 method for data.frame,ANY,data.frame,character,missing getSMR( popdata, model, casedata, regionCode , regionCodeCases , area.scale = 1, sex=c('m','f'),... ) # S4 method for data.frame,ANY,missing,character,missing getSMR( popdata, model, casedata, regionCode , regionCodeCases , area.scale = 1, sex=c('m','f'),... )

# S4 method for data.frame,ANY,data.frame,character,character getSMR( popdata, model, casedata, regionCode , regionCodeCases , area.scale = 1, sex=c('m','f'),... )

Value

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.

Arguments

popdata

the name of population data set

model

rates, either fitted model (usually a glm object), or a vector of rates.

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 sex='f' for females only.

...

additional arguments. When popdata is a list, arguments can be personYears (logical, convert rates to person years), years (a vector with the year of each dataset), or year.range (two dimensional vector with first and last year)

Details

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.

Examples

Run this code
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]))


Run the code above in your browser using DataLab