Error in goodness of fit test using unmarked

Hi there,

I am trying to conduct a goodness of fit test using the mb.gof.test from the unmarked package. It gives me the following error:

Error in hist.mat[j, ] <- ifelse(strip.hist == "1", preds.p.not.na[j, :
number of items to replace is not a multiple of replacement length

my code is as follows

#########################################################################################################
## Canis Mesomelas Survey Template
## Richard Carkeek
## Zoology Honours Project 2020
#########################################################################################################
setwd()
#########################################################################################################
## Relative abundance indeces
RAI_N_L <- read.csv("RAI_N_L2.csv", header = T, sep = ";", dec = ".")
View(RAI_N_L)

#########################################################################################################
## Scale Data
RAI_N_L[,1:11] <- scale(RAI_N_L[,1:11], center = TRUE, scale = TRUE)

DFRAI_N_L <- data.frame(RAI_N_L)
View(DFRAI_N_L)
#########################################################################################################
## Spearmans Correlation

corL = cor(DFRAI_N_L, method = "spearman")
View(corL)

#########################################################################################################
## Remove correlated variables
# med + large prey
# megaherb
# med pred
# Human

DFRAI_N_L[,c(3, 4, 5, 7)] <- NULL
DFRAI_N_L[,6] <- NULL

#########################################################################################################
## Replace Standardized values with words for habitat and road (Potentially Camera traps as well)

DFRAI_N_L[,6] <- data.frame ("Habitat"=c ("BS",
                                          "GL",
                                          "ST",
                                          "BT",
                                          "FP",
                                          "ST",
                                          "ST",
                                          "GL",
                                          "GL",
                                          "GL",
                                          "BT",
                                          "GL",
                                          "GL"))

DFRAI_N_L[,7] <- data.frame ("Road"=c ("Path",
                                       "Path",
                                       "Road",
                                       "Road",
                                       "Road",
                                       "Path",
                                       "Road",
                                       "Road",
                                       "Road",
                                       "Road",
                                       "Path",
                                       "Road",
                                       "Path"))

DFRAI_N_L[,1] <- data.frame ("CT" = c ("L1",
                                       "L3",
                                       "L4",
                                       "L5",
                                       "L6",
                                       "L7",
                                       "L8",
                                       "L9",
                                       "L10",
                                       "L11",
                                       "L12",
                                       "L13",
                                       "L14"))

#########################################################################################################
## Import Dection Data (Collapsed Intervals)

## 4 Day interval
D4L <- read.csv("4DL.csv", header = T, sep = ";", dec = ".")
View(D4L)

#########################################################################################################
## Detection tests (Unmarked and AIC)


## Unmarked Frame 4 Days
umfL4 <- unmarkedFrameOccu(y = D4L, siteCovs = DFRAI_N_L)
umfL4

fmL4 <- occu(~1~ Small_Prey + Small_Pred + Large_Pred + Habitat + Road, data = umfL4)
fmL4

#########################################################################################################
## This all works fine
#########################################################################################################

## This is the line of code for the goodness of fit test which produces the error

RL4 <- mb.gof.test(fmL4, plot.hist = TRUE, nsim = 1000)
RL4

## The Error

> RL4 <- mb.gof.test(fmL4, plot.hist = TRUE, nsim = 1000)
Error in hist.mat[j, ] <- ifelse(strip.hist == "1", preds.p.not.na[j,  : 
  number of items to replace is not a multiple of replacement length

Any advice or help will be greatly appreciated, Thanks!

Hi!

To help us help you, could you please prepare a reproducible example (reprex) illustrating your issue?

You provided code, but not the data that would be required to reproduce your issue.

Please have a look at this guide, to see how to create a reprex:

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.