I have a simple multivariate regression model testing the impact of two variables on another over one year (1971). I have a large data set that includes these data over a number of years and am being asked to use "reframe" to rerun the model over 48 years (1961-2018) and then create a scatterplot of the "BB" coefficients by year. I am having a difficult time understanding how to use "reframe" in this context and wondering if anyone can either point me in the right direction, or help me better understand. I will have no issues creating the plot, but I can't figure out the code to rerun the model 48 times and give me a dataframe with the results using "reframe".
fit <- Teams %>% filter(yearID == 1971) %>% mutate(BB = BB/G, HR = HR/G, R = R/G) %>% lm(R ~ BB + HR, data = .) tidy(fit, conf.int = TRUE) I have scoured Google and the R help file for "reframe" but still cannot figure out where to even start. I tried to just use the below code, but was given an error and of course I don't even think I'm even on the right track since I cannot figure out how to use "reframe" properly.
fit %>% reframe(Teams$yearID %in% 1961:2018) Error in UseMethod("reframe") : no applicable method for 'reframe' applied to an object of class "lm"
lm(R ~ (BB + HR) * factor(yearID), data = ...). You can even specify different residual variances between years using annlme:::glsmodel. Anyway, I believe you wantupdateand notreframe.tidy(update(fit, data=filter(data, yearID %in% 1961:2018)))library(nlme); fits <- lmList(R ~ BB + HR | yearID, data = DF); summary(fits).