I have a dataset:
dat <- structure(list(date = structure(c(18830, 18835, 18837, 18841,
18843, 18844, 18848, 18850, 18852, 18856, 18858, 18863, 18865,
18870, 18873, 18879, 18884, 18887, 18890, 18892, 18894, 18898,
18899, 18901, 18904, 18905, 18906, 18908, 18915, 18920, 18922,
18927, 18929, 18935, 18940, 18946, 18949, 18954, 18956, 18960,
18963, 18975, 18978, 18982, 18985, 18989, 18990), class = "Date"),
value = c(254183, 254552, 254702, 254792, 254840, 254860,
254953, 254994, 255043, 255134, 255198, 255310, 255354, 255473,
255543, 255677, 255900, 256162, 256338, 256451, 256570, 256812,
256866, 256991, 257164, 257226, 257280, 257398, 257812, 258114,
258232, 258528, 258680, 259110, 259401, 259754, 259930, 260219,
260328, 260575, 260748, 261454, 261630, 261863, 262036, 262266,
262330)), row.names = c(22L, 27L, 29L, 33L, 35L, 36L, 40L,
42L, 44L, 48L, 50L, 55L, 57L, 62L, 65L, 71L, 76L, 79L, 82L, 84L,
86L, 90L, 91L, 93L, 96L, 97L, 98L, 100L, 107L, 112L, 114L, 119L,
121L, 127L, 132L, 138L, 141L, 146L, 148L, 152L, 155L, 167L, 170L,
174L, 177L, 181L, 182L), class = "data.frame")
When doing:
smooth.spline(dat$date, dat$value, cv = TRUE)
I see the following message in red twice:
spar-finding: non-finite value inf; using BIG value
It is not an error because I get the expected output. My guess is that it is some kind of informative message. Does anyone know what it means and/or what might be causing it?
Can I suppress it. I don't want my code user to panic on seeing red messages that are in fact unimportant.
It is a FORTRAN-level message that cannot be suppressed by suppressMessages
or suppressWarnings
. But anyway, it is neither a warning nor an error. It just reports that Inf are bounded to some BIG values during computation. It is purely for "safety".
So why is this happening? My guess is as follows. The FORTRAN routine used by smooth.spline
is, to be honest, kind of old. It was developed in the late 1980's or the early 1990's using single-precision floating point numbers. This restricts the accuracy of numerical computation and there is a danger of overflow or underflow. As a result, the code does many clever tricks to stabilize the computations. Obviously, if a number goes beyond what single-precision could offer, it should be truncated to the maximum representable value.
I have been using smooth.spline
for many years and had never seen this message until your question. In fact, if I change your code
dat <- na.omit(dat)
smooth.spline(dat$date, dat$value, cv = TRUE)
to
dat <- na.omit(dat)
smooth.spline(dat$date, dat$value)
that is, if I use generalized cross-validation (GCV), the message is gone.
Note that for smoothing spline, GCV is in theory superior to raw CV. That is why cv = FALSE
is the default for smooth.spline
. I advise you stick to GCV.