I'm building a SIR model for a COVID-19 modeling project. In the model, we use the parameter ef to refer to the efficacy of % magnitude of social distancing (i.e. reduction in contact). I need to create age-specific ef parameters for four age groups, which change with respect to time (see conditional statements below). All the values for mag and ef&_& come from a spreadsheet where the values for our parameters are stored.
I'd like to write a for-loop to iterate four times, but I'm struggling with how to deal with the conditional statements and time triggers. Any input or syntax ideas are much appreciated.
Thanks in advance!
# change over time in efficacy of % mag SD among specific age groups
ef1 <- ifelse(t<t2, 0, ifelse(t<t3, mag1, ifelse(t<t4, mag2, ifelse(t<t5, mag3, ifelse(t<t6, mag4, ifelse(t< t7, ef1_1,ifelse(t<t8, ef1_2, ef1_3)))))))
ef2 <- ifelse(t<t2, 0, ifelse(t<t3, mag1, ifelse(t<t4, mag2, ifelse(t<t5, mag3, ifelse(t<t6, mag4, ifelse(t< t7, ef2_1,ifelse(t<t8, ef2_2, ef2_3)))))))
ef3 <- ifelse(t<t2, 0, ifelse(t<t3, mag1, ifelse(t<t4, mag2, ifelse(t<t5, mag3, ifelse(t<t6, mag4, ifelse(t< t7, ef3_1,ifelse(t<t8, ef3_2, ef3_3)))))))
ef4 <- ifelse(t<t2, 0, ifelse(t<t3, mag1, ifelse(t<t4, mag2, ifelse(t<t5, mag3, ifelse(t<t6, mag4, ifelse(t< t7, ef4_1,ifelse(t<t8, ef4_2, ef4_3)))))))