guiblanchet / HMSC

Hierarchical modelling of species community
40 stars 13 forks source link

Problem using single records with predict.HMSC #14

Open rlrichards opened 6 years ago

rlrichards commented 6 years ago

Hello,

We've been attempting to perform Leave one out Cross Validation to tune parameters and have had some issues getting the predict.HMSC function to accept only a single row of data for X and Y. It appears that the main issue that cannot be fixed by altering the settings or the way the initial data are formatted is an error at line 126:

dimnames(res)[[1]]<-rownames(data$Y)

With only a single row in Y this line returns the error:

Error in dimnames(res)[[1]] <- rownames(data$Y) : 'dimnames' must be a list

I was able to circumvent this issue with the following slight change:

dimnames(res)[[1]]<-list(rownames(data$Y))

Assuming that this does not mess with anything else this change in the package could ease use for those attempting LOO-CV with HMSC.

Thanks so much for all your work, Robbie