Helping with backtransform (get.real)

90 views
Skip to first unread message

Marina FAVARINI

unread,
Feb 6, 2023, 5:27:24 AM2/6/23
to oSCR
Hi everybody,

I'm trying to make predictions on Detection probability and my best model has the variable behavior (p0 ~ b). So when I try the get.real appears an error:

pred.df <- data.frame(session = factor(c(1,2))) 
pred.det <- get.real(model = best_model, type= "det", newdata = pred.df) 

Error in eval(predvars, data, env) : object 'b' not found

Does anyone know how to resolve this error?

Best,
Marina


Daniel Linden

unread,
Feb 17, 2023, 7:00:24 AM2/17/23
to oSCR
Hi Marina, can you send your fitted model object to me?  The get.real function should be able to handle predictions of the behavioral effect without needing to specify.

Marco Salvatori

unread,
Jul 13, 2024, 9:45:12 AM7/13/24
to oSCR
Hi everybody,

I am having exactly the same error when extracting detectability predictions " Error in eval(predvars, data, env) : object 'b' not found ". I see there was no full answer to this question, does anybody know how to solve this problem?

Thanks,

Best

Marco

Chris Sutherland

unread,
Jul 13, 2024, 9:48:15 AM7/13/24
to oscr_p...@googlegroups.com

Hi Marco,

Can you send me the fitted object and the code you are using (offline: cs...@st-andrews.ac.uk) and I will see what's going on. Then post a general solution.


--
You received this message because you are subscribed to the Google Groups "oSCR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to oscr_package...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/oscr_package/a49f9887-f4ae-4575-90d5-65de238d98d9n%40googlegroups.com.

Marco Salvatori

unread,
Aug 2, 2024, 4:20:55 AM8/2/24
to oSCR
Hi all,

Thank to Chris's help I could solve the problem. I was using wrong data types in the "newdata" when extracting detection probability and sigma predictions. 
Sex must be specified as a binary factorial variable with 0 and 1 levels (0 for females and 1 for males).
The behavioral effect b instead must be expressed as a binary numerical (not factorial!) variable with 0 and 1.
Session is numerical. See example below:

# predict p
p_df <- data.frame(
  Session = 1,
  sex = factor(c(0,1,0,1)),
  b = c(0,0,1,1)
)
p_df <- get.real(mymod, type='det', newdata=p_df)

Best,
Marco
Reply all
Reply to author
Forward
0 new messages