Hello, Dear all:
I am doing this regression lm by each patient ID. Then try to calculate confidence interval for coefficient. I got this error message in the end.
fitted_models = df31 %>% group_by(PatId) %>% do(model = lm(var1 ~ yr_findex, data = .))
t<- fitted_models%>%group_by(PatId) %>% do(confint(., "yr_findex", level=0.80))

Then I always this error as
Error in UseMethod("vcov") :
no applicable method for 'vcov' applied to an object of class "c('tbl_df', 'tbl', 'data.frame')"

Anyone knows why? I am a SAS newly converted R user...so still asking very simple questions here. Thanks a lot!

Right now I have another issue. Since I need to extract the coefficient from model by ID.
I did this.
fitted_models = df31 %>% group_by(PatId) %>% do(model = lm(eGFR_value ~ yr_findex, data = .))
fit_est<-fitted_models %>% tidy(model)%>% subset(term %in% "yr_findex")

In the end, I merge the CI for coefficient by ID to fit_est. If I used ungroup(). Then I can't have fit_est created correctly...
How to run one model. Then extract the slope and calculate CI as the results?