Error in max(fit) : invalid 'type' (S4) of argument

Hi, I am new with RStudio software. I tried to calculate the Boyce index using a function in "ecospat" package (ecospat.boyce: Calculate Boyce Index in ecospat: Spatial Ecology Miscellaneous Methods):

ecospat.boyce (fit, obs, nclass=0, window.w="default", res=100, PEplot = TRUE)

I used a .csv file as "obs" and a raster map as "fit". I import this map (.asc) using "raster" package.

After run the function, I receive this message:

Error in max(fit) : invalid 'type' (S4) of argument

Please, can you help me to fix this problem? Thanks in advice..

From the documentation:

Fit: A vector or Raster-Layer containing the predicted suitability values

Check that fit is of class RasterLayer