r -r- rycatch()funtion-如何保存错误/警告消息?
我正在模拟多级数据并将其拟合到各种多级模型中。
我想制作一个函数,如果存在任何错误(例如“无法收敛”或“单数拟合”),我想保存它。
例如,我的模型是
lmer(y〜x1 + x2 +(1 | pid),data = sim_data)。
这是许多条件,因此将在此模型中拟合各种数据。
如何在数据框架或列表中保存错误或整个警告消息?
(例如,第一个数据集 - >无错误,第二个数据集 - 汇聚错误...等)
I am simulating multilevel data and fitting it to various Multilevel models.
I want to make a function that if there is any error (such as "failed to converge" or "singular fit"), I want to save it.
For example, my model is
lmer(y~ x1 + x2 + (1|pid), data=sim_data).
and here are many conditions so various data will be fitted into this model.
How can I save the error or warning message as a whole in the dataframe or list?
(like, first dataset -> no error, second dataset -> converge error...etc)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用for循环在条件下迭代或“各种数据”
。
0
:
You could use a for loop to iterate through the conditions or "various data":
0.Setting up a dummy function that might throw error:
1.Preparing a list to receive results
2.Iterating through different "conditions":