Commit 5d8864ae authored by Grelot Frederic's avatar Grelot Frederic :swimmer_tone5:
Browse files

Correction data so_ii_onrn

	- calcul de balance en tenant compte de la population sur la période

Refs #9
Showing with 12 additions and 1 deletion
+12 -1
......@@ -266,10 +266,20 @@ result = merge(result, temp, by = "commune", all.x = TRUE)
### Bilan Sinistre - Prime : estimation
# result = read.csv2(geau::current_version("data-common/so-ii/onrn"))
#### Some data to compute premium per habitant
pop_france = 66992159 # INSEE (2018)
premium_france = 1670000000 # (CCR2019a pour 2018)
premium_hab = premium_france / pop_france
result[["balance"]] = (1 - result[["ratio"]]) * geau::so_ii_population[ , "2018"] * premium_hab
#### Need to compute cumulative population
period = seq(1995, 2018)
available = as.integer(dimnames(geau::so_ii_population)[[2]])
selection = as.character(available[sapply(period, function(x){which.min(abs(available - x))})])
pop_commune = rowSums(geau::so_ii_population[, selection])
result[["balance"]] = (1 - result[["ratio"]]) * pop_commune * premium_hab
result = result[c(
"commune", "n_catnat", "freq_sin", "cost", "cost_mean", "cost_hab", "ratio", "balance",
......@@ -279,6 +289,7 @@ result = result[c(
)]
write.csv2(result, sprintf("data-common/so-ii/onrn/onrn-%s.csv", today), row.names = FALSE)
# write.csv2(result, geau::current_version("data-common/so-ii/onrn"), row.names = FALSE)
unlink(onrn_raw, recursive = TRUE, force = TRUE)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment