error with get.real on sigma

31 views
Skip to first unread message

Kyleigh Fertitta

unread,
Nov 3, 2025, 8:44:41 PM11/3/25
to oSCR
Hi everyone!

I currently have a model where sex is a covariate on sigma. I used get.real to find the real values of detection and density for both male and female, but for some reason sigma isn't working. It provides the error: Error in eval(g., envir) : object 'sig.sex' not found.
I am not sure where the sig.sex is coming from, but I've tried sex, sig.sex, and sig.sexmale. Here is my code following https://www.ecography.org/sites/ecography.org/files/appendix/ecog-04551.pdf :

s.pred.df <- data.frame(session = rep(factor(1:6),each = 2),
                        sig.sex = rep(c(0,1),each=6),
                        sig.sexmale = rep(c(0,1),each=6),
                        sex = rep(c(0,1),each=6))
#now predict
s.preds <- get.real(model = model_oSCR_2yr_pop_D_sess_p0_sess_dep_sig_pop, type = "sig", newdata = s.pred.df)
s.preds$sex <- factor(s.preds$sex)
levels(s.preds$sex) <- c("Female","Male")
head(s.preds)

Thank you so much!

Daniel Linden

unread,
Nov 6, 2025, 10:12:04 AM11/6/25
to oSCR
Hi, when you create the data.frame for prediction, it should have the covariates named as they are in the original data.  So in your example, you've included "sig.sex" and "sig.sexmale", but those are not covariate names, they are potential names of coefficients in the model.  The error you are getting is because those covariates do not exist, so simply removing "sig.sex" and "sig.sexmale" from your newdata df (as shown below) should work. Note, the way you have the objects repeated actually causes a different mistake, but taking away "each" from the session construction works.  This wouldn't cause the error you were seeing, but it would prevent 12 unique rows in your df object.

s.pred.df <- data.frame(session = rep(factor(1:6), 2),
                        sex = rep(c(0,1),each=6))

Kyleigh Fertitta

unread,
Nov 6, 2025, 1:27:52 PM11/6/25
to oscr_p...@googlegroups.com
Hi Daniel!

Thank you so much for the reply. I originally started out with just "sex ="  but when I run that code I get:

> s.pred.df <- data.frame(session = rep(factor(1:6), 2),
+                         sex = rep(c(0,1),each=6))
> #now predict
> s.preds <- get.real(model = model_oSCR_2yr_pop_D_sess_p0_sess_dep_sig_pop, type = "sig", newdata = s.pred.df)
Error in eval(g., envir) : object 'sig.sex' not found

I added sig.sex in 's.pred.df after I got that error because when I only had 'sex =' I would get this error. The covariates in my model are:

model_oSCR_2yr_pop_D_sess_p0_sess_dep_sig_pop[["outStats"]]
          parameters         mle    std.er
1     p0.(Intercept)
2        p0.session2
3        p0.session3
4        p0.session4
5        p0.session5
6        p0.session6
7    sig.(Intercept)
8        sig.sexmale
9   t.beta.depth_std
10 t.beta.depth2_std
11    d0.(Intercept)
12   d.beta.session2
13   d.beta.session3
14   d.beta.session4
15   d.beta.session5
16   d.beta.session6
17      psi.constant
Which is why I attempted sig.sexmale too. Thank you so much for your help!
Best,
Kyleigh Fertitta


--
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 visit https://groups.google.com/d/msgid/oscr_package/e9980a4f-143b-495c-ab60-254e3ba3369en%40googlegroups.com.

Daniel Linden

unread,
Nov 6, 2025, 3:20:11 PM11/6/25
to oSCR
Hi Kyleigh, there is definitely a problem with the get.real function.  If you send me your data and model fit objects, I can help you generate some estimates in the meantime.

Jeffrey Thompson

unread,
Nov 6, 2025, 3:59:15 PM11/6/25
to oscr_p...@googlegroups.com




--
Dr. Jeffrey J. Thompson, Ph.D.
Investigador (Nivel III) - CONACYT
Investigador Asociado, Programa Yaguarete, Guyra Paraguay
email: jthomp...@gmail.com
https://www.jeffreyjthompson.org
@DrJJThompson

Kyleigh Fertitta

unread,
Nov 6, 2025, 4:08:58 PM11/6/25
to oscr_p...@googlegroups.com
Amazing! That worked! Thank you so much! For anyone who comes across this thread I still had to put something for sex=. Here is what my code looks like:

##SIGMA

model_oSCR_2yr_pop_D_sess_p0_sess_dep_sig_pop$outStats$parameters[8] <-"sig.sex"


s.pred.df <- data.frame(session = rep(factor(1:6), 2),
                        sig.sex = rep(c(0,1),each=6),

                        sex = rep(c(0,1),each=6))
#now predict
s.preds <- get.real(model = model_oSCR_2yr_pop_D_sess_p0_sess_dep_sig_pop, type = "sig", newdata = s.pred.df)
s.preds$sex <- factor(s.preds$sex)
levels(s.preds$sex) <- c("Female","Male")
head(s.preds)

Best,
Kyleigh Fertitta


Reply all
Reply to author
Forward
0 new messages