bgreenwell / investr

Inverse estimation in R
22 stars 6 forks source link

x0 required for a glm with single predictor #41

Open EMG83 opened 5 years ago

EMG83 commented 5 years ago

Trying a very simple use of "invest" exactly as it is outlined in the documentation to get an LD50 and 95% CI, but am getting errors that additional arguments are needed:

Error in invest.glm(MOD_INJ.20, y0 = 0.5) : 'x0.name' is missing, please select a valid predictor variable In addition: Warning messages: 1: In min(.data[, x0.name]) : no non-missing arguments to min; returning Inf 2: In max(.data[, x0.name]) : no non-missing arguments to max; returning -Inf

Built the glm with the following code, and data is attached: MOD_INJ.20 <- glm(INJ.20~LNTREAT, family=binomial(link=logit)) INJ_14DAT_ALLAVG_LOGIT.txt

bgreenwell commented 5 years ago

That's a weird error, but I suspect it is because invest() does not know how to extract the raw data from your fitted model. You have two options: (1) refit the model with the data = <data-name> argument, or (2) supply the data via the data argument in invest():

invest(MOD_INJ.20, y0 = 0.5, data = df)
# estimate    lower    upper 
# 4.453411 4.201361 4.707759
bgreenwell commented 5 years ago

I'll leave this issue open so I can hopefully improve the code to provide a more informative error message!