Calculates rates from 'observed' count and a denominator data
rates(traj, denomin, id_field, multiplier)
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] "8 entries were found/filled!"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)#> [1] "77 entries were found/filled!"#calculate rates i.e. crimes per 200 population crime_rates <- rates(traj2$CompleteData, denomin=pop_imp_result$CompleteData, id_field=TRUE, multiplier = 200)