I would like to compute the linear regression and maximum likelihood slopes for each participant. This fine response explains how to do that for wide-form data, but mine are "long-form" longitudinal data, similar enough to Singer & Willet's data on alcohol use among teens:
alcohol1 <- read.table("https://stats.idre.ucla.edu/stat/r/examples/alda/data/alcohol1_pp.txt", header=T, sep=",")
Where, to exemplify, I would like to determine the linear regression (OLS) and maximum likelihood (MLE) slopes for alcuse across age for each id within the alcohol1 data set.
Output can be either another data frame in which each id has a corresponding variable that is the slope for their values or a column added to the original alcohola data that is this slope for each instance of that participant.
Like Singer & Willet, my participants do not all have the same number of occurences and some missing data, so I would like to account that as well.