vegandevs / vegan

R package for community ecologists: popular ordination methods, ecological null models & diversity analysis
https://vegandevs.github.io/vegan/
GNU General Public License v2.0
436 stars 95 forks source link

vif.cca Error in qr.X(Q) #622

Closed powerfulDie closed 3 months ago

powerfulDie commented 4 months ago

Thank you for the nice tool. I have a data frame named Env.bank which is the environment data. A total of 26 columns were in this data frame, and the first column was named Sample_ID. Then I ran:

rda_bank <- rda(Origin_bank_hell ~ ., data=Env.bank[,2:26], scale = TRUE))
vif_bank <- vif.cca(rda_bank)

Everything is OK.

But I want to use the while loop to delete the maximum vif value one by one. so I edited the Sample_ID as the rownames.

Env.bank.LOOP <- Env.bank%>%  column_to_rownames("Sample_ID")

Then I ran the same command as above:

(rda_bank1 <- rda(Origin_bank_hell ~ ., data=Env.bank.LOOP,scale = TRUE))
 vif_bank <- vif.cca(rda_bank1)

there was an error: **Error in qr.X(Q) : need larger value of 'ncol' as pivoting occurred**.

I searched for the reason in chatGPT. It commented that "it might indicate a potential issue with the collinearity or structure of your data. This error can occur when the design matrix used to fit the model is not full rank."

I am confused. Because there were different results when I used the same data to execute. Did you meet the same case? Would it be possible for you to help me?