Trial and error tests with log base (groups) vs natural log.
devtools::load_all()
Test the difference between total and black/white segregation using ln and base(groups)
# test the difff between ln and log(groups) detroit_mod <- detroit_race %>% mutate(newrace=NA_real_, white_bw = white/(white+black), black_bw=black/(white+black), pop_bw = population*(white+black)) %>% summarize( divln = divergence(across(black:hispanic), population=population, summed=T), divln1 = divergence(white_bw, black_bw, population=pop_bw, summed=T), divbase = divergence(across(black:hispanic), population=population, logBase=4, summed=T), divbase1 = divergence(white_bw, black_bw, newrace, population=pop_bw, logBase=2, summed=T)) detroit_mod t <- detroit_race %>% select(-tract) %>% mutate(place_name = ifelse(grepl('Detroit',place_name), place_name,'Other')) decompose_divergence(t, groupCol='place_name',popCol='population', output='all') decompose_divergence(t, groupCol='place_name',popCol='population', output='all', logBase=6)
Test whether adding a new group that is completely uniform changes the scores
detroit_new <- detroit_race %>% mutate(across(black:nhpi, ~(.x*.8),), newRace = 0.2) %>% summarize( divln = divergence(across(black:nhpi), population=population, summed=T), divln1 = divergence(across(black:newRace), population=population, summed=T), divbase = divergence(across(black:nhpi), population=population, logBase=6, summed=T), divbase1 = divergence(across(black:newRace), population=population, logBase=7, summed=T)) detroit_new
Using ln means that adding a completely desgregated group does nothing to the score - the total amount of measured segregation is still there. Using base (group) diminishes the segregation - the average segregation has gone down.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.