RStudio Abort/ R Error

questions concerning anlysis/theory using program DENSITY and R package secr. Focus on spatially-explicit analysis.

RStudio Abort/ R Error

Postby Kubecka » Tue Feb 12, 2019 9:54 am

Hello,

I am working on a multi-session data set where I have gotten 2 of the sessions to run (simple models, evaluating detection functions, g0). However, the first session causes Rstudio to abort the session. Thus, I ran the code in the R GUI and received this message.

Error in row(object) :
a matrix-like object is required as argument to 'row'

I also tried importing just that session and running as a single session, and receive the same error. I used the make.capt hist to form the data design, and I assumed if there were any duplicates (which seems to make sense for a row matrix error?) in raw data, they would have been removed in this step (maybe bad assumption?). Am I missing something, or is there something wrong somewhere in my data? If it is a data error, what might the error arise from? The data-set is fairly large for this session (5944 captures), if that matters.

Attached was the code I used to do such:

#Read trap files from all sessions
alltraps<- read.traps(file = c("traps_session1.txt", "traps_session2.txt", "traps_session3.txt"), detector = "multi", binary.usage = TRUE, covnames = c("pland","lpi","mpa","feeder"))
# Get a summary from trap files
summary(alltraps)

#Read in captures file
allcaps<-read.delim(file = "all_caps16_18.txt")
allcaps$session<-as.factor(allcaps$session)
allcaps

bobCH<-make.capthist(captures = allcaps, traps = alltraps)
summary(bobCH)


#2016 Model Attempts
model.NEGEX.2016<- secr.fit(bobCH$`2016`, detectfn = "EX", trace=F, buffer=800)
model.HR.2016 <- secr.fit(bobCH$`2016`, trace=F, detectfn= "HR", buffer=800)
model.HN.2016<-secr.fit(bobCH$`2016`, trace=F, detectfn= "HN", buffer=800)


Best Regards,

Brad
Kubecka
 
Posts: 9
Joined: Wed Feb 06, 2019 12:35 pm

Re: RStudio Abort/ R Error

Postby murray.efford » Tue Feb 12, 2019 3:29 pm

Hi
This suggests something peculiar in the data, but the code should never just dump you out of R so I'd like to get to the bottom of it.

The call 'row(object)' appears only once in secr -- in animalID() -- and I can't yet see how that has anything to do with your example.

Would you be willing to send the relevant data offline so I can investigate?

Murray
murray.efford
 
Posts: 582
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand

Re: RStudio Abort/ R Error

Postby Kubecka » Tue Feb 12, 2019 4:04 pm

Indeed, I will send an email shortly.

Thanks!
Kubecka
 
Posts: 9
Joined: Wed Feb 06, 2019 12:35 pm

Re: RStudio Abort/ R Error

Postby murray.efford » Tue Feb 12, 2019 5:11 pm

I have the data - thanks - but I haven't yet been able to reproduce the error. This dataset is much bigger than anything I've worked on (>4000 animals, 20 occasions, ~300 traps) and likelihood evaluation is slow in 'secr'. I got a very plausible estimate with detectfn = 'HEX' for the first year from 'openCR.fit', but that won't help you with modeling density across space (which incidentally uses mask not trap covariates).

I see there are a few very long movements - if these are real then you'll need EX or HEX, as you've already probably guessed.

Which command in particular causes the error, and which version of 'secr' are you using?

Murray
murray.efford
 
Posts: 582
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand

Re: RStudio Abort/ R Error

Postby Kubecka » Tue Feb 12, 2019 6:18 pm

I believe those movements are real (albeit rare). In the first session, as noted, it required 20 days to complete trapping and the study species has been documented (via telemetry) to make movements like these (especially in this given time frame). I ran baseline models for 2017 and 2018 comparing HN, HR, and EX functions. HR had the most support- perhaps because of trap placement and lack of multiple spatial recaptures. Will most certainly add HEX to comparison of baseline detection functions.

I have been using university computers (better specs; 40 GB RAM, 4.4 ghz processors) to run the models because my laptop cannot allocate the required memory. I install the newest 'secr' from CRAN on every computer I log into-- I believe it is 'secr' 3.2.0. However, it seems the university has not updated R from 3.5.1 to 3.5.2 and I see that secr 3.2.0 was built under 3.5.2. Not sure if that would cause this error for 1 session but not others.

The command that causes the error is secr.fit. Any attempt to run a model from the 2016 session gives the error. The error does not arise from 2017 or 2018 session (which have substantially fewer captures).

Brad
Kubecka
 
Posts: 9
Joined: Wed Feb 06, 2019 12:35 pm

Re: RStudio Abort/ R Error

Postby Kubecka » Tue Feb 12, 2019 6:18 pm

I believe those movements are real (albeit rare). In the first session, as noted, it required 20 days to complete trapping and the study species has been documented (via telemetry) to make movements like these (especially in this given time frame). I ran baseline models for 2017 and 2018 comparing HN, HR, and EX functions. HR had the most support- perhaps because of trap placement and lack of multiple spatial recaptures. Will most certainly add HEX to comparison of baseline detection functions.

I have been using university computers (better specs; 40 GB RAM, 4.4 ghz processors) to run the models because my laptop cannot allocate the required memory. I install the newest 'secr' from CRAN on every computer I log into-- I believe it is 'secr' 3.2.0. However, it seems the university has not updated R from 3.5.1 to 3.5.2 and I see that secr 3.2.0 was built under 3.5.2. Not sure if that would cause this error for 1 session but not others.

The command that causes the error is secr.fit. Any attempt to run a model from the 2016 session gives the error. The error does not arise from 2017 or 2018 session (which have substantially fewer captures).

Brad
Kubecka
 
Posts: 9
Joined: Wed Feb 06, 2019 12:35 pm

Re: RStudio Abort/ R Error

Postby murray.efford » Tue Feb 12, 2019 6:34 pm

I just used HEX because I was trying openCR.fit that doesn't have EX - these should be equivalent. I generally avoid HR because density estimates depend (slightly) on size of mask.

Good to hear you have the latest. R version not an issue (I'm on 3.5.1).

I interrupted secr.fit after 25 apparently successful likelihood evaluations... One change I did make was to pre-compute a mask with reduced number of pixels (about 1000; faster).

Code: Select all
msk1 <- make.mask(traps(bobCH[[1]]), buffer = 800, type = 'trapbuffer', nx = 32)
model.NEGEX.2016<- secr.fit(bobCH[[1]], detectfn = "EX", mask = msk1)

Not sure where this leaves us - I'll keep thinking.
Murray
murray.efford
 
Posts: 582
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand

Re: RStudio Abort/ R Error

Postby Kubecka » Tue Feb 12, 2019 7:25 pm

I copied the code for pre-computing a mask with nx=32, and similarly, the model run has not yet aborted (about 60 iterations in). In other attempts, I would have received an error by now and R would have 'blown up.' Perhaps I will play with masks for a bit to limit integration across fewer pixels. Seems to be promising.

Thanks,

Brad
Kubecka
 
Posts: 9
Joined: Wed Feb 06, 2019 12:35 pm


Return to analysis help

Who is online

Users browsing this forum: No registered users and 1 guest