I stored the models in a list, but you could just as easily create a dummy matrix and store predictions using the predict function within the loop. So I’ve provided some example code here to help those who are facing the same issue.įor the example, I fit a linear mixed effects model using lmer (just because I happen to be working with mixed models, and they throw back convergence errors more often than GLMs), then used the update function to challenge it with random draws from my dataframe. But I found it difficult to get the function to work, even after consulting the help file, and from searching R listservs/Stackoverflow. Luckily, there’s a function called next that does just that. I wanted the function to register an error for that entry, then skip to the next one and finish off the loop. ![]() The problem I was running into was the for loop screeching to a halt as soon as a model kicked back an error. Lately, I’ve been using loops to fit a number of different models and storing the models (or their predictions) in a list (or matrix)–for instance, when bootstrapping.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |