Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
606 B
4
Indexable
Never
{r, fig.align = 'center'}
#| echo: false
#| message: false

# Create groups of 20 years starting from 1860-79
vdem <- vdem |>
  mutate(period = cut(year, breaks = seq(1859, max(year), by = 20), labels = FALSE))

# Perform linear regression for each period
regression_results <- vdem |>
  group_by(period) |>
  summarise(
    coefficient = coef(lm(e_migdppcln ~ v2x_polyarchy))[2],
    period_start = min(year),
    period_end = max(year)
  )

# Filter out rows with period as "NA"
regression_results <- regression_results %>%
  filter(!is.na(period))

# Print the filtered results
print(regression_results)