如何抑制来自 stats::regularize.values 的警告? [英] How to suppress warnings from stats:::regularize.values?
问题描述
在较新版本的 R(我有 3.6 和以前有 3.2)中,stats::regularize
.values 函数已更改为将 warn.collapsing 的默认值设为 TRUE.此函数用于 splinefun
和 R 中的其他几个插值函数.在微观模拟模型中,我使用 splinefun
来平滑大量 (n > 100,000) 数据点形式为 (x, f(x)).这里,x 是正值缩放器的模拟向量,f(x) 是 (x) 的某个函数.当 n 如此大时,通常会有一些伪随机生成值的复制(即,并非所有 x 值都是唯一的).我的理解是 splinefun
摆脱了 x 值的联系.这对我来说不是问题,但是,由于新的默认设置,我每次都会收到一条警告消息(如下)
In newer versions of R (I have 3.6 and previously had 3.2), the stats::regularize
.values function has been changed to have a default value of warn.collapsing as TRUE. This function is used in splinefun
and several other interpolation functions in R. In a microsimulation model, I am using splinefun
to smooth a large amount (n > 100,000) of data points of the form (x, f(x)). Here, x is a simulated vector of positive-valued scalers, and f(x) is some function of (x). With an n that large, there are often some replications of pseudo-randomly generated values (i.e., not all values of x are unique). My understanding is that splinefun
gets rid of ties in the x values. That is not a problem for me, but, because of the new default, I get a warning message printed each time (below)
"在regularize.values(x, y, ties, missing(ties)) 中:折叠到唯一的 'x' 值"
"In regularize.values(x, y, ties, missing(ties)) : collapsing to unique 'x' values"
有没有办法将 stats::regularize.values
函数的 warn.collapsing 参数的默认值改回 F?或者我可以以某种方式抑制该特定警告?这很重要,因为它嵌入在一个很长的微观模拟代码中,当我更新它时,我经常遇到错误.所以我不能忽略警告信息.
Is there a way to either change the default of the warn.collapsing argument of the stats::regularize.values
function back to F? Or can I somehow suppress that particular warning? This matters because it's embedded in a long microsimulation code and when I update it I often run into bugs. So I can't just ignore warning messages.
我尝试使用formalize函数.我能够打印 stats::regularize.values
的默认参数,但是当我尝试使用 alist
函数分配新值时,它说没有对象'统计数据.
I tried using the formalize function. I was able to get the default arguments of stats::regularize.values
printed, but when I tried to assign new values using the alist
function it said there is no object 'stats'.
推荐答案
我也遇到了这个问题,通过在 splinefun()<的参数列表中添加
ties=min
解决了这个问题/代码>.missing(ties)
的值现在作为 warn.collapsing
传递给 regularize.values()
.
I had this problem too, and fixed it by adding ties=min
to the argument list of splinefun()
.
The value of missing(ties)
is now passed as warn.collapsing
to regularize.values()
.
https://svn.r-project.org/R/trunk/src/library/stats/R/splinefun.R
https://svn.r-project.org/R/trunk/src/library/stats/R/approx.R
另见:https://cran.r-project.org/doc/手册/r-release/NEWS.html并搜索 regularize.values()
.
这篇关于如何抑制来自 stats::regularize.values 的警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!