I have the data like this:
    df <- tibble::tibble(
        id = rep(c(1:50), each = 5),
        y = runif(250,min = 0, max = 1),
        x1 = rnorm(250, mean = 0, sd=1),
        x2 = rnorm(250, mean = 0, sd=1),
        x3 = rnorm(250, mean = 0, sd=1),
        x4 = rnorm(250, mean = 0, sd=1), 
        x5 = rnorm(250, mean = 0, sd=1), 
) %>% 
        group_by(id) %>% 
        mutate(year = rep(c(2001:2005)))
I would like to estimate the probit model for every year to get (1)coefficient estimates,and (2) predicted value of y, and (3) number of observations used to estimate the model:
probit_model <- function(df) {
        glm (y ~ x1 + x2 + x3 + x4+ x5,
            family = binomial(link = "probit"),
            data = df)
}
Do you know how we can get the coefficient estimates, predicted value for every year and then combine them with the original data (that is df) here? I know what we can do with OLS model (by using map function to estimate for multiple models). But I do not know how to do with probit regression.
Thank you so much.
 
     
    