How to resolve invalid class “unmarkedFrame” object: obsCovData does not have M*obsNum rows.?

60 Views Asked by At

I am trying to make an occupancy model using the R Package unmarked. I have a dataset which has occupancy, obvs covariates, and and site covarites, and I have written the code as follows:

umf <- unmarkedFrameOccu(y=as.matrix(Grebe_Presence_Data[,c("V1", "V2", "V3", "V4", "V5")]),   siteCovs=Grebe_Presence_Data[,c("Percent_Wetland", "Depth", "Distance_National_Park", "Distance_Shore", "Nets", "Aquaculture", "Distance_Settlement", "Distance_Road")],   obsCovs=Grebe_Presence_Data[,c("Percent_Wetland", "Transect_Length", "ObsTeam", "Methodology")])

And I get the following error:

Error in validObject(.Object) : 
  invalid class “unmarkedFrame” object: obsCovData does not have M*obsNum rows.

I tried to write it slighly differently, as follows:

umf <- unmarkedFrameOccu(y=as.matrix(Grebe_Presence_Data[,c("V1", "V2", "V3", "V4", "V5")]),   siteCovs=Grebe_Presence_Data[,c("Percent_Wetland", "Depth", "Distance_National_Park", "Distance_Shore", "Nets", "Aquaculture", "Distance_Settlement", "Distance_Road")],   obsCovs=list(date=Grebe_Presence_Data[,c("Percent_Wetland", "Transect_Length", "ObsTeam", "Methodology")]))

But only get the following error message

Error in FUN(X[[i]], ...) : 
  At least one element of obsCovs has incorrect number of dimensions.

I have checked and all the columns have the same number of rows, so I am not sure what the issue is. Does anyone have a solution?

0

There are 0 best solutions below