Hi,
I am having the same issue when I run a goodness of fit test on multiple season model data. I have a covariate labeled "cycle" that is meant to be a factor. I have used the following code and while forcing the covariate to be a factor in the current dataframe worked, I noticed that cycle is converted to a character after I create the .umf.
dat<- read.csv("HHB_occ2020.csv",stringsAsFactors=TRUE)
'data.frame': 4410 obs. of 32 variables:
$ loc : int 11 11 11 11 11 11 11 11 11 11 ...
$ site : int 1 1 1 1 1 1 1 1 1 1 ...
$ occasion : int 1 2 3 4 5 6 7 1 2 3 ...
$ season : int 1 1 1 1 1 1 1 2 2 2 ...
$ julian : int 242 243 237 238 239 240 241 292 293 287 ...
$ jDate : num 0.997 0.995 1 1 1 ...
$ det : int 1 1 0 0 0 1 1 1 1 0 ...
$ year : int 1 1 1 1 1 1 1 1 1 1 ...
$ region : int 1 1 1 1 1 1 1 1 1 1 ...
$ treehab : int 1 1 1 1 1 1 1 1 1 1 ...
$ cycle : Factor w/ 4 levels "lac","mate","preg",..: 1 1 1 1 1 1 1 2 2 2 ...
Bat.umf <- unmarkedMultFrame(y = y, numPrimary = 14, siteCovs = sitecovs,
obsCovs = list(temp=temp, wind=wind, rain=rain, month=month, seas=seas, julian=julian,jdate=jdate,humidity=humidity),
yearlySiteCovs = list(cycle = cycle, myt = myt, myr = myr, myw = myw, year=year,
mmStudyt=mmStudyt,mmStudyr=mmStudyr,mmStudyw=mmStudyw))
str(Bat.umf)
Formal class 'unmarkedMultFrame' [package "unmarked"] with 7 slots
..@ numPrimary : num 14
..@ yearlySiteCovs:'data.frame': 630 obs. of 8 variables:
.. ..$ cycle : chr [1:630] "lac" "mate" "prepreg" "preg" ...
.. ..$ myt : num [1:630] 10.7 10.7 10.7 10.7 11.5 ...
.. ..$ myr : num [1:630] 22.91 22.91 22.91 22.91 6.43 ...
.. ..$ myw : num [1:630] 4.17 4.17 4.17 4.17 3.8 ...
.. ..$ year : int [1:630] 1 1 1 1 2 2 2 2 3 3 ...
.. ..$ mmStudyt: num [1:630] 13.4 12.4 9.2 10.8 13.1 ...
.. ..$ mmStudyr: num [1:630] 9.29 15.06 14.13 6.37 8.57 ...
.. ..$ mmStudyw: num [1:630] 3.77 3.73 4.44 2.79 3.93 ...
..@ y : int [1:45, 1:98] 1 0 0 1 1 NA 1 1 1 1 ...
You can see that "cycle" is now a character instead of a factor. It seems in my case that this is an issue with unmarked rather than AICcmodavg, though I do obviously get the same message when I try to run the goodness of fit test: Error in UseMethod("droplevels") :
no applicable method for 'droplevels' applied to an object of class "character". Any ideas or workarounds? I know that the .umf is an S4 object and I'm not having luck converting the class after the fact. Similarly this code worked on previous versions of R but I am currently using 4.0.0. My Unmarked version is 0.13-2.
Cheers,
Rachel