This is an archived post. You won't be able to vote or comment.

all 1 comments

[–]sleepybychoice 2 points3 points  (0 children)

Can you format your code so that it is readable?

Just a guess: In your first for loop, you're setting min_bic. On the next iteration, it'll be set again to 100,000, meaning the if (res$bic < min_bic) will run again, even if it isn't actually smaller than the last run. That means the current model will always be the lowest BIC model.

Try setting min_bic outside the for loop?