data2oscr error

48 views
Skip to first unread message

Madison Thurber

unread,
Jun 14, 2026, 8:29:03 PMJun 14
to oSCR
Hi! 

I am running into an error that I cannot figure out. When I run 
model.oscr <- data2oscr(
  edf,
  sess.col = 1,
  id.col = 2,
  occ.col = 3,
  trap.col = 4,
  sex.col = 5,
  tdf = list(
    "North 2024" = northtrap.df,
    "South 2024" = southtrap.df
  ),
  K = K,
  ntraps = ntraps,
  sex.nacode = "U"
)

I get the error code >  Error in [.data.frame(xx, , (xx.check + 1):ncol(xx)) : undefined columns selected

I have two trap tdfs that I am using. I am not using trap covariates right now. I was trying to work through the error and removed the separator "/" column from both tdfs and the data2oscr worked. Do I need the separator column in the trap tdfs if I am not using covarates? Any thoughts on why I am getting this error when I have the separator column?

Thank you!
Madi

jar...@gmail.com

unread,
Jun 14, 2026, 8:34:02 PMJun 14
to oSCR

Hi Madi,


No, you should NOT include the separator "/" column if you don't have trap covariates. The separator is only needed when you have actual trap covariates to separate them from the trap operation columns.

Your tdf structure should be:

  • Without trap covariates[Name, X, Y] or [Name, X, Y, trap operations...]
  • With trap covariates[Name, X, Y, trap operations..., /, covariate1, covariate2, ...]

The error you're encountering is actually a bug in the code - it doesn't handle the case where "/" exists but has no covariates after it. By removing the separator column, you've worked around the issue correctly.  I may fix that in the near future if I can.


regards

andy

Madison Thurber

unread,
Jun 14, 2026, 9:07:32 PMJun 14
to oSCR

Hi Andy,

Woo! That makes me feel a lot better. Thank you for the quick response.

I have a follow-up question. I’m trying to model a behavioral effect on detection (p0). I’ve been looking through the OSCR cheat sheet, but I’m not sure whether the underlying OSCR models will actually account for a behavioral effect if I specify something like p0 ~ b. 

Thanks again!

Madi


Jeffrey Royle

unread,
Jun 14, 2026, 9:10:44 PMJun 14
to oscr_p...@googlegroups.com
Hi Madi,

Yes! The oSCR models do account for behavioral effects when you specify p0 ~ b.

When you use p0 ~ b, oSCR automatically creates a "previous capture" covariate that tracks whether each individual has been captured before at each trap-occasion. 
The model estimates two detection probabilities:

p0[1] = detection probability BEFORE first capture
p0[2] = detection probability AFTER first capture

You can also combine it with other effects:

p0 ~ b + sex (behavioral response + sex effect)
p0 ~ b + t (behavioral response + temporal variation)

The behavioral effect in oSCR is currently a "global" behavioral response (same effect for all individuals), not trap-specific.

regards
andy
> --
> 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/873a9331-a74d-4710-9a8b-fc9c7122ff49n%40googlegroups.com.

Madison Thurber

unread,
Jun 14, 2026, 9:29:44 PMJun 14
to oSCR
Great! Thank you so much for the help :)

Madison Thurber

unread,
Jul 13, 2026, 10:52:01 AM (5 days ago) Jul 13
to oSCR
Hi! 

I am trying to run

model10 <- oSCR.fit(model = list(D ~ 1, p0 ~ occasion, sig ~ sex), scrFrame = sf, ssDF = ss, plotit = FALSE, trimS = 8)

However it is not recognizing occasion as a covariate. Is this because we removed the seperator as I did not have any technical covariates? Should I add the seperator column and acknowledge occasion as a covariate in its own column or is there another way? I am working with black bears and hair snares and I have 8 weeks for the occasions that I am trying to see if the week impacts detection. 

Thanks! 

Jeffrey Royle

unread,
Jul 13, 2026, 10:54:12 AM (5 days ago) Jul 13
to oscr_p...@googlegroups.com
hi Madi,
 This should work if you have a trap covariate named "occasion" in your scrFrame.... can you confirm?


You received this message because you are subscribed to a topic in the Google Groups "oSCR" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/oscr_package/pENYjjw1j6Q/unsubscribe.
To unsubscribe from this group and all its topics, send an email to oscr_package...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/oscr_package/977fbb01-3050-47bd-8f5f-26d49461a6bcn%40googlegroups.com.

Madison Thurber

unread,
Jul 13, 2026, 1:42:46 PM (5 days ago) Jul 13
to oSCR
I do not have a trap covariate named occasion I just have the occasions as the 1-8 trap checks in my scrframe.

Jeffrey Royle

unread,
Jul 13, 2026, 1:52:59 PM (5 days ago) Jul 13
to oscr_p...@googlegroups.com
you can use the special notation "p0 ~ t" to model time effects on detection. This will use one parameter per occasion, so I don't recommend it generally speaking especially with a lot of occasions (8 may not seem like a lot, but 8 parameters is a lot....).
"t" works with other in-built models:

p0 ~ t + session # time and session effects 
p0 ~ t + sex # time and sex effects 
p0 ~ t + b # time and behavioral response

Often a better solution is to model a linear or quadratic trend in detection to account for seasonal variation in animal behavior that might affect detectability. For that you would have to create a covariate in the scrFrame that could just be integers 1 through 8 for occasion and then do things like:  p ~ occasion  for a linear effect  or p ~ occasion + I(occasion^2) for a quadratic. 








Chris Sutherland

unread,
Jul 13, 2026, 2:02:16 PM (5 days ago) Jul 13
to oscr_p...@googlegroups.com
Andy beat me to it - i echo everything here.

Also, for reference: 

image.png

Madison Thurber

unread,
Jul 13, 2026, 2:39:03 PM (4 days ago) Jul 13
to oSCR
Thank you both! 
Reply all
Reply to author
Forward
0 new messages