Exercise

Probabilistic projection of migration

Here, we'll continue the previous application. The 1000 sets of estimates in ar1est is a result of an estimation using migration data for the United States. The task is to project the future distribution of the US migration rate for 15 time points using the whole estimation dataset instead of just one row. You will generate a set of 10000 trajectories of length 15, each of which makes use of one parameter set, thus each parameter row is re-used 10 times. You will also visualize the results using a preloaded function show_migration().

Instructions 1/4

undefined XP
    1
    2
    3
    4
  • Recall that function ar1_block_of_trajectories() generates a block of trajectories for a given row (in this example, a given ID) of the ar1est dataset. Write a function ar1_multiple_blocks_of_trajectories() that generates such blocks of trajectories for given vector of row identifiers ids.
    • The function has arguments ids and ....
    • Inside the function, use lapply to call ar1_block_of_trajectories() on each element of ids.
    • Bind the results by row using do.call().