strengejacke / sjstats

Effect size measures and significance tests
https://strengejacke.github.io/sjstats
189 stars 21 forks source link

Error handling offset term when supplied to glm(...,offset=) argument #48

Closed joehoover closed 6 years ago

joehoover commented 6 years ago

Hi,

This fix does not appear to be working for me. I installed the latest sjstats:

devtools::install_github("strengejacke/sjstats")

and then I installed the dev versions in sequence as you suggest in the sjstats readme:

devtools::install_github("strengejacke/sjlabelled")
devtools::install_github("strengejacke/sjmisc")
devtools::install_github("strengejacke/sjstats")
devtools::install_github("strengejacke/ggeffects")
devtools::install_github("strengejacke/sjPlot")

The new installations had no effect on the errors thrown by the following code:

d = data.frame(x1 = rnorm(100, 0, 1), 
                        x2 = rnorm(100, 0, 1), 
                        pop = rpois(100, 100)) 

d$y = rpois(100, exp(0 + d$x1*.3 + d$x2*-.4 + d$x1*d$x2*.5)) 
d$log_pop = log(d$pop)
m <- glm(y ~ x1*x2, offset=log(pop), data=d)
plot_model(m, type = "pred", terms = c("x1", "x2", "pop")) 

is.na() applied to non-(list or vector) of type 'NULL'Error in names(datlist) <- names(first) : 'names' attribute [3] must be the same length as the vector [2]

m <- glm(y ~ x1*x2, offset=log_pop, data=d)
plot_model(m, type = "pred", terms = c("x1", "x2", "log_pop")) 

ERROR: is.na() applied to non-(list or vector) of type 'NULL'Error in names(datlist) <- names(first) : 

'names' attribute [3] must be the same length as the vector [2]

names(sjstats::model_frame(m))`

returns a model frame where the offset term is called (offset).