Understanding Loess Errors in R

I try to fit the model using loess, and I get errors such as "pseudo-inversion used in 3", "radius of the neighborhood 1" and "the number of inverse conditions is 0". Here's the MWE:

x = 1:19
y = c(NA,71.5,53.1,53.9,55.9,54.9,60.5,NA,NA,NA
      ,NA,NA,178.0,180.9,180.9,NA,NA,192.5,194.7)
fit = loess(formula = y ~ x,
        control = loess.control(surface = "direct"),
        span = 0.3, degree = 1)
x2 = seq(0,20,.1)
library(ggplot2)
qplot(x=x2
    ,y=predict(fit, newdata=data.frame(x=x2))
    ,geom="line")

I understand that I can fix these errors by choosing a larger range value. However, I am trying to automate this fit as I have about 100,000 time series (each of them about 20) like this. Is there a way that I can automatically select a range value that will prevent these errors, while maintaining a fairly flexible fit to the data? Or can someone explain what these errors mean? I worked a bit in the functions loess () and simpleLoess (), but I gave up at the moment the C code was called.

+4
1

fit$fitted y. , - . , . . , , , . , degree=0 ksmooth. , span , Cross Validated.

> fit$fitted
 [1]  71.5  53.1  53.9  55.9  54.9  60.5 178.0 180.9 180.9 192.5 194.7
> y
 [1]    NA  71.5  53.1  53.9  55.9  54.9  60.5    NA    NA    NA    NA    NA 178.0
[14] 180.9 180.9    NA    NA 192.5 194.7

( ), .

fit
#Call:
#loess(formula = y ~ x, span = 0.3, degree = 1, control = loess.control(surface = "direct"))

#Number of Observations: 11 
#Equivalent Number of Parameters: 11 
#Residual Standard Error: Inf 

geom_smooth. ( geom_smooth(span=0.3) )

ggplot(data=data.frame(x, y), aes(x, y)) + 
  geom_point() + geom_smooth()

enter image description here

+6

Source: https://habr.com/ru/post/1568005/


All Articles