Description Usage Arguments Value Examples
Calculates rates from 'observed' count and a denominator data
1 |
traj |
[matrix (numeric)] longitudinal (e.g.
observed count) data ( |
denomin |
[matrix (numeric)] longitudinal (denominator)
data of the same column as 'traj' ( |
id_field |
[numeric or character] Default is |
multiplier |
[numeric] A quantify by which to the ratio
|
An object which comprised of four output variables, namely: (i) '$common_ids' - individual ids present in both 'traj' (trajectory data) and 'denomin' (denominator data); (ii) '$ids_unique_to_traj_data' - individual ids unique to trajectory data (i.e. not present in the denominator data); (iii) '$ids_unique_to_denom_data' - individual ids unique to denominator data (i.e. not present in the trajectory data); (iv) “ - a dataframe of rates estimates. Note: only the individual ids in '$rates_estimates' are used in the 'rates' estimation.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | traj2 <- data_imputation(traj, id_field = TRUE, method = 2,
replace_with = 1, fill_zeros = FALSE)
pop <- popl #read denominator data
pop2 <- as.data.frame(matrix(0, nrow(popl), ncol(traj)))
colnames(pop2) <- names(traj2$CompleteData)
pop2[,1] <- as.vector(as.character(pop[,1]))
pop2[,4] <- as.vector(as.character(pop[,2]))
pop2[,8] <- as.vector(as.character(pop[,3]))
list_ <- c(2, 3, 5, 6, 7, 9, 10) #vector of missing years
#fill the missing fields with 'NA'
for(u_ in seq_len(length(list_))){
pop2[,list_[u_]] <- "NA"
}
#estimate missing fields
pop_imp_result <- data_imputation(pop2, id_field = TRUE, method = 2,
replace_with = 1, fill_zeros = FALSE)
#calculate rates i.e. crimes per 200 population
crime_rates <- rates(traj2$CompleteData, denomin=pop_imp_result$CompleteData,
id_field=TRUE, multiplier = 200)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.