Let’s focus on families with multiple problems only, and let’s assume that individuals born in families with multiple problems are indeed trapped, but that they do not necessarily resort to crime. Model an aging chain of kids, youngsters, adults and retirees. Initially, there are 1 million kids, 1 million youngsters, 3 million adults, and 750000 retirees within these families with multiple problems.
Suppose for the sake of simplicity that only retirees die, on average after an average time as retiree of 15 years, i.e. deaths equals retirees divided by average time as retiree. Similarly, adults flow after an average time as adult of 40 years from adults to retirees, youngsters after an average time as youngster of 12 years from youngsters to adults, and kids after an average time as kid of 12 years from kids to youngsters. Both adults and youngsters give birth: the birth inflow is thus the sum of the adults times the annual fertility rate of adults of 3 percent per adult per year and the youngsters times the annual fertility rate of youngsters of 0.3% per youngster per year.
Suppose 6 million crimes are committed annually by others, that is, by criminals that are not part of families with multiple problems. Apart from these crimes by others, crimes are committed by criminal kids at a rate of 2 criminal acts per criminal kid per year, by criminal youngsters at a rate of 4 criminal acts per criminal youngster per year, by criminal adults at a rate of 12 criminal acts per criminal adult per year, and by criminal retirees at a rate of 4 criminal acts per criminal retiree per year.
Suppose that, in these families with multiple problems, the percentage of kids with criminal behavior amounts to 5%, the percentage of youngsters with criminal behavior amounts to 50%, the percentage of adults with criminal behavior amounts to 60%, and the percentage of retirees with criminal behavior amounts to 10%.
Caso recuperado de Pruyt, E. (2013). Small system dynamics models for big issues (1ª ed.). TU Delft Library.
#En este primer chunk establecemos todas las variables que son mencionadas en el caso, es importante identificar correctamente las variables de estado, las de flujo y los parametros. Los parametros son valores establecidos por el autor y las variables de estado son acumulativas con el pasar del tiempo.
library(deSolve)
crimes <- function(t, state, parameters) {
with(as.list(c(state,parameters)), {
#Endogenous auxiliary variables
criminal.kids= kids*percentage.kids.criminal.behavior
criminal.youngsters= youngsters*percentage.youngsters.criminal.behavior
criminal.adults= adults*percentage.adults.criminal.behavior
criminal.retirees= retirees*percentage.retirees.criminal.behavior
crimes.by.kids= criminal.kids*crimactsperkid
crimes.by.youngsters= criminal.youngsters*crimactsperyoungster
crimes.by.adults= criminal.adults*crimactsperadult
crimes.by.retirees=criminal.retirees*crimactsperretiree
crimes= crimes.by.kids+crimes.by.youngsters+crimes.by.adults+crimes.by.retirees+ crimesbyothers
#Flow variables
adults.to.retirees = adults/avg.time.as.adult
youngsters.to.adults= youngsters/avg.time.as.youngster
kids.to.youngsters= kids/avg.time.as.kid
death= retirees/avg.time.as.retiree
birth= (adults*fertilityadults) + (youngsters*fertilityyoungsters)
crimes.by.kids= criminal.kids*crimactsperkid
crimes.by.youngsters= criminal.youngsters*crimactsperyoungster
crimes.by.adults= criminal.adults*crimactsperadult
crimes.by.retirees=criminal.retirees*crimactsperretiree
#State (stock) variables
dkids<- birth - kids.to.youngsters
dyoungsters <- kids.to.youngsters - youngsters.to.adults
dadults = youngsters.to.adults - adults.to.retirees
dretirees= adults.to.retirees-death
list(c(dkids,
dyoungsters,
dadults,
dretirees
))
})
}
parameters<-c(crimactsperkid = 2,
crimactsperyoungster = 4,
crimactsperadult = 12,
crimactsperretiree = 4,
fertilityyoungsters = .3/100,
fertilityadults=3/100,
crimesbyothers=6000000,
percentage.kids.criminal.behavior=5/100,
percentage.youngsters.criminal.behavior=50/100,
percentage.adults.criminal.behavior=60/100,
percentage.retirees.criminal.behavior=10/100,
avg.time.as.adult=40,
avg.time.as.retiree=15,
avg.time.as.youngster=12,
avg.time.as.kid=12)
#Las condiciones iniciales están dadas por el autor
InitialConditions <- c(kids = 1000000,
youngsters = 1000000,
adults=3000000,
retirees=750000)
#Ya que se nos solicita modelar 50 años la configuración de times queda de la siguiente manera
times <- seq(0 , #initial time
50, #end time
1 ) #time step, days
intg.method<-c("rk4")
out <- ode(y = InitialConditions,
times = times,
func = crimes,
parms = parameters,
method =intg.method )
plot(out,
col=c("blue"))
Para poder observar en una misma gráfica cada sector de población y observar el número de crimenes por año, genere dos gráficas nuevas.
knitr::opts_chunk$set(echo = FALSE)
library(deSolve)
Diagrama causal del caso
Es un diagrama complicado de
diseñar por el gran número de variables que tenemos presentes en este
caso, al realizar diagramas causales es importante marcar la polaridad
en cada causalidad.
Diagrama de stock y flujo
En este diagrama podemos identificar claramente las 4 variables de estado y observar las variables de flujo que las afectan directamente.