Hi dear, I may get some feedback on the following?
I was doing simple regression and planing to do Akaike information criterion ( AIC) or the Bayesian information criterion (BIC).
However, I encountered error message " Error in UseMethod("logLik") : no applicable method for 'logLik' applied to an object of class "c('tbl_df', 'tbl', 'data.frame')"
My data set and code are here:
data <- data.frame(s =c("lc", "tr", "fr", "ku","lc", "tr", "fr", "ku","lc", "lc", "fr"),
B = c("m","m","m","m","m", "m", "f","f","f","f","f"),
G = c("s","s","s","u","u", "u", "k","k","k","r","r"),
ZN =c(78,82,34,67,98,56,37,45,27,18,34),
lm =c(45,22,24,12,10,17,35,63,18,20,30),
GFR=c(120,100,90,60,100,110,100,90,95,87,96),
g1 = c(35, 2, 3, 4, 5, 6, 7, 10, 12, 41, 76),
g2 = c(20, 2, 7, 2, 8, 5, 5, 3, 7, 2, 12),
g3 = c(5, 0, 4, 5, 2, 4, 8, 9, 20, 1, 11),
g4 = c(1,3,4,5,7,3,1,5,7,3,10),
g5 = c(20,23, 27, 35, 12, 10, 17, 24, 21, 15, 16),
g6 = c(13,13,115,17,14,12,19,6,7,8,4),
g7 = c(5, 0, 4, 5, 2, 4, 8, 9, 20, 1, 11),
g8 = c(1,3,4,5,7,3,1,5,7,3,10),
g9 = c(20,23, 27, 35, 12, 10, 17, 24, 21, 15, 16),
g10 =c(13,13,115,17,14,12,19,6,7,8,4))
model1 <- data %>%
gather(Fac, value, -s:-GFR) %>%
split(.$Fac) %>%
map(~lm(GFR ~ value + ZN+ lm + B, data =.) %>%
tidy(.) %>%
select(estimate, std.error,statistic,p.value) %>%
slice(2)) %>% # Extracting regression Intercept
bind_rows(.id = "Variables")
BIC(model1)
AIC(model1)