# Autoregressive processes
autoreg <- subset(Master, select = c(conflictid, actorid, year, max_prev, min_prev,	mean_prev,	median_prev))
autoreg$year <- autoreg$year + 1
autoreg <- rename(autoreg, replace = c("max_prev" = "max_prev_lag", 
                                      "min_prev" = "min_prev_lag", 
                                      "mean_prev" = "mean_prev_lag", 
                                      "median_prev" = "median_prev_lag"),
                  warn_missing = T)
Master <- join(Master, autoreg, type = "left", match = "all", by = c("conflictid", "actorid", "year"))

rm(autoreg)