R How to evaluate a single input variable coefficient in a glm

103 views Asked by At

I have a R glm object and I want to evaluate the coefficient associate to a single input variable of a new data frame. Here is an example:

library(statmod)


data = tibble(X = c('a', 'b', 'c', 'd', 'e'), Z = c('a', 'c', 'c', 'c', 'a'), W = c(21:25), Y = c(0.1, 0.2, 0.3, 0.4, 0.88)) 
model = glm(Y ~ I(X %in% c('a', 'b')) + I(X %in% c('d', 'e')) + I(Z %in% c('a', 'c')) + I(log(W)), data=data, family=tweedie(var.power=1.44, link.power=0))
newdata = tibble(X = c('f', 'a'), Z = c('a', 'a'), W = c(5, 15))

I want to extract the coefficient associated to X = 'f' (which should be the based level, 0). I want to extract the coefficient associated to W = 5 (which should be log(5) * beta)

Thanks you,

John

0

There are 0 answers