Error in [.default(DF, chr) : invalid subscript type 'list' when using timecov

35 views
Skip to first unread message

Julien Piquet

unread,
Aug 31, 2020, 9:59:52 AM8/31/20
to secr
Hi all,

So far I've been working fine with models using time-specific covariates (see http://www.phidot.org/forum/viewtopic.php?f=36&t=4049 for further details on the background). However, this week I tried to run the code below and R produced the error Error in [.default(DF, chr) : invalid subscript type 'list'. I do not know what the problem is because I followed the exact same steps as I did before, when it used to work. I attach the timecov dataset as a .csv file for further details. Any help will be really appreciated.

secr.negexp.time<-secr.fit(secr_data,model=list(g0~time),buffer=width,detectfn = 1,verify=F,timecov=timecov,start=start,method="Nelder-Mead",trace=F,CL=T)

Sincerely

Julien
timecov.csv

Murray Efford

unread,
Aug 31, 2020, 8:11:21 PM8/31/20
to secr
Three points, none of them very helpful I'm afraid (I haven't gone back to your earlier posts)
1. This could be another problem due to the changed default for stringsAsFactors in R 4.0. Which versions of R and 'secr' are you using?
2. Strictly we would need to see the dataframe 'timecov' rather than the csv file. Maybe show us head(timecov).
3. If 'time' represents sampling effort it would be better handled as 'usage'
Murray

Julien Piquet

unread,
Sep 1, 2020, 4:37:05 AM9/1/20
to secr
Hi Murray,

It seems to me that the error might be related to your first point. I am actually using R 4.0.2. When the error pops up and I show the  Traceback that's what I see:


However, as you can see, the verify argument is set to FALSE, and so it is in the secr data. Therefore, is there any way to avoid this error?

Regarding your point 2, here is the head(timecov):

> head(timecov)

  session_site     time

1          111  10.66667

2          111  17.66667

3          112  13.05000

4          112  16.50000

5          121  15.63333

6          121  13.81667

Finally, time represents daytime. I actually used effort as non-binary usage.

Thank you very much for your help

Julien

Julien Piquet

unread,
Sep 1, 2020, 4:38:31 AM9/1/20
to secr
Seems like the image I included in the message disappeared. I attach it to this message.
Captura.PNG

Murray Efford

unread,
Sep 2, 2020, 3:46:36 AM9/2/20
to secr
Thanks - that helps a lot. Can you confirm that timecov is a dataframe and not a matrix?

Julien Piquet

unread,
Sep 2, 2020, 7:28:37 AM9/2/20
to secr
Hi Murray, 
Yes, timecov is a dataframe!
Julien

Murray Efford

unread,
Sep 2, 2020, 5:00:35 PM9/2/20
to secr
I'm puzzled. From the traceback it seems to concern the individual covariates. I can't reproduce the problem with simulated data, so I'm guessing there is something peculiar about the individual covariates of your dataset (it checks these in the search for the 'time' variable). If you can't see anything then feel free to send me the data offline for a further check.
Murray

P.S. detectfn = 1 is not negexp; you have an awful lot of occasions; it is very inefficient to use a continuous cvariate like this - better to discretize with e.g.
timecov$hour <- trunc(timecov$time) + 0.5
timecov$early
<- timecov$time< 14.5
Enter code here...


Reply all
Reply to author
Forward
0 new messages