How to fix error in auto model.Rhyme using Time Series in R?

Asked

Viewed 61 times

0

My goal is to make a prediction using Time Series and for that I need to create a model using the auto.arima, but after several attempts the following error message is displayed:

Error in auto.arima(treino, seasonal = F) : No suitable ARIMA model found
In addition: Warning message:
The chosen unit root test encountered an error when testing for the first difference.
From -(): non-numeric argument to binary operator
0 differences will be used. Consider using a different unit root test. 

To help understand what is happening I will leave here the data Deput.

dput(head(dados, 50))
structure(c("2016-01-01", "2016-02-01", "2016-03-01", "2016-04-01", 
            "2016-05-01", "2016-06-01", "2016-07-01", "2016-08-01", "2016-09-01", 
            "2016-10-01", "2016-11-01", "2016-12-01", "2017-01-01", "2017-02-01", 
            "2017-03-01", "2017-04-01", "2017-05-01", "2017-06-01", "2017-07-01", 
            "2017-08-01", "2017-09-01", "2017-10-01", "2017-11-01", "2017-12-01", 
            "2018-01-01", "2018-02-01", "2018-03-01", "2018-04-01", "2018-05-01", 
            "2018-06-01", "2018-07-01", "2018-08-01", "2018-09-01", "2018-10-01", 
            "2018-11-01", "2018-12-01", "2019-01-01", "2019-02-01", "2019-03-01", 
            "2019-04-01", "2019-05-01", "2019-06-01", "2019-07-01", "2016-01", 
            "2016-02", "2016-03", "2016-04", "2016-05", "2016-06", "2016-07", 
            "2016-08", "2016-09", "2016-10", "2016-11", "2016-12", "2017-01", 
            "2017-02", "2017-03", "2017-04", "2017-05", "2017-06", "2017-07", 
            "2017-08", "2017-09", "2017-10", "2017-11", "2017-12", "2018-01", 
            "2018-02", "2018-03", "2018-04", "2018-05", "2018-06", "2018-07", 
            "2018-08", "2018-09", "2018-10", "2018-11", "2018-12", "2019-01", 
            "2019-02", "2019-03", "2019-04", "2019-05", "2019-06", "2019-07", 
            "2016", "2016", "2016", "2016", "2016", "2016", "2016", "2016", 
            "2016", "2016", "2016", "2016", "2017", "2017", "2017", "2017", 
            "2017", "2017", "2017", "2017", "2017", "2017", "2017", "2017", 
            "2018", "2018", "2018", "2018", "2018", "2018", "2018", "2018", 
            "2018", "2018", "2018", "2018", "2019", "2019", "2019", "2019", 
            "2019", "2019", "2019", " 1", " 2", " 3", " 4", " 5", " 6", " 7", 
            " 8", " 9", "10", "11", "12", " 1", " 2", " 3", " 4", " 5", " 6", 
            " 7", " 8", " 9", "10", "11", "12", " 1", " 2", " 3", " 4", " 5", 
            " 6", " 7", " 8", " 9", "10", "11", "12", " 1", " 2", " 3", " 4", 
            " 5", " 6", " 7", "65", "63", "60", "59", "59", "58", "56", "56", 
            "57", "58", "58", "59", "59", "57", "57", "58", "60", "59", "58", 
            "61", "61", "64", "62", "62", "63", "63", "63", "62", "61", "62", 
            "62", "60", "61", "62", "62", "62", "67", "65", "66", "69", "69", 
            "69", "69", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", 
            "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", 
            "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", 
            "5", "5", "5", "5", "5", "5", "5", "70", "68", "65", "65", "64", 
            "63", "61", "61", "63", "63", "63", "64", "64", "61", "62", "64", 
            "67", "64", "63", "65", "64", "67", "67", "69", "71", "69", "69", 
            "70", "67", "70", "68", "65", "68", "68", "64", "66", "73", "70", 
            "71", "75", "75", "74", "73", "8801", "8284", "8663", "8426", 
            "8757", "7807", "7909", "8085", "7342", "7766", "6917", "6524", 
            "6712", "5494", "6667", "5841", "6800", "5665", "6181", "6003", 
            "5448", "6149", "5955", "6100", "6107", "5267", "6024", "5742", 
            "5843", "5355", "5528", "5063", "4957", "5101", "4605", "4576", 
            "4887", "4496", "5400", "5867", "6147", "5620", "5301", "10162.76", 
            "10271.75", "10989.96", "10531.39", "11106.39", " 9847.93", "10067.73", 
            "10243.22", " 9073.81", " 9515.86", " 8374.93", " 8038.93", " 7971.49", 
            " 6494.01", " 8086.93", " 7011.61", " 8877.80", " 7118.37", " 7919.78", 
            " 7596.31", " 6827.23", " 7590.32", " 7301.27", " 7401.93", " 7639.75", 
            " 6677.50", " 7947.16", " 7399.59", " 7678.65", " 6989.26", " 7408.08", 
            " 6696.87", " 6587.59", " 6674.26", " 5825.55", " 5889.98", " 6497.34", 
            " 6080.41", " 7512.29", " 7962.22", " 8413.40", " 7153.09", " 7460.55", 
            "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", 
            "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", 
            "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", 
            "0", "0", "0", "0", "2551.90", "2572.25", "2743.67", "2631.71", 
            "2778.78", "2457.02", "2519.70", "2556.61", "2259.24", "2377.52", 
            "2106.13", "2019.27", "1990.19", "1627.00", "2037.52", "1762.58", 
            "2209.05", "1773.60", "1975.03", "2474.83", "2515.84", "2796.33", 
            "2683.44", "2729.78", "2815.84", "2461.95", "2927.25", "2720.48", 
            "2827.54", "2561.22", "2706.59", "2480.40", "2436.47", "2475.69", 
            "2162.47", "2289.03", "2530.65", "2216.30", "2763.20", "2952.07", 
            "3078.76", "2656.94", "2770.48", "10162.76", "10271.75", "10989.96", 
            "10531.39", "11106.39", " 9847.93", "10067.73", "10243.22", " 9073.81", 
            " 9515.86", " 8374.93", " 8038.93", " 7971.49", " 6494.01", " 8086.93", 
            " 7011.61", " 8877.80", " 7118.37", " 7919.78", " 7596.31", " 6827.23", 
            " 7590.32", " 7301.27", " 7401.93", " 7639.75", " 6677.50", " 7947.16", 
            " 7399.59", " 7678.65", " 6989.26", " 7408.08", " 6696.87", " 6587.59", 
            " 6674.26", " 5825.55", " 5889.98", " 6497.34", " 6080.41", " 7512.29", 
            " 7962.22", " 8413.40", " 7153.09", " 7460.55", "7610.86", "7699.50", 
            "8246.29", "7899.68", "8327.61", "7390.91", "7548.03", "7686.61", 
            "6814.57", "7138.34", "6268.80", "6019.66", "5981.30", "4867.01", 
            "6049.41", "5249.03", "6668.75", "5344.77", "5944.75", "5121.48", 
            "4311.39", "4793.99", "4617.83", "4672.15", "4823.91", "4215.55", 
            "5019.91", "4679.11", "4851.11", "4428.04", "4701.49", "4216.47", 
            "4151.12", "4198.57", "3663.08", "3600.95", "3966.69", "3864.11", 
            "4749.09", "5010.15", "5334.64", "4496.15", "4690.07", "144.31", 
            "154.95", "158.53", "156.16", "158.48", "157.65", "159.09", "158.34", 
            "154.42", "153.09", "151.31", "154.02", "148.43", "147.72", "151.63", 
            "150.08", "163.18", "157.03", "160.16", "158.15", "156.58", "154.22", 
            "153.19", "151.64", "156.35", "158.48", "164.98", "161.17", "164.40", 
            "163.27", "167.59", "165.32", "166.08", "163.55", "158.14", "160.93", 
            "166.23", "169.05", "173.95", "169.72", "171.14", "159.12", "175.97", 
            "1270083.5", "1283577.5", "1373321.1", "1315784.8", "1387838.9", 
            "1230737.3", "1258276.1", "1280181.6", "1133781.8", "1188912.1", 
            "1046583.8", "1004802.2", " 996245.0", " 811598.4", "1010886.1", 
            " 876616.5", "1109601.4", " 889594.1", " 989943.9", " 949354.6", 
            " 853027.0", " 948310.1", " 912227.5", " 925007.2", " 954813.4", 
            " 834704.3", " 993865.2", " 925454.2", " 960578.5", " 874308.5", 
            " 926427.2", " 837038.2", " 823264.2", " 834267.9", " 728220.8", 
            " 736436.8", " 812370.7", " 760062.2", " 939356.5", " 995718.7", 
            "1051979.5", " 894250.4", " 932838.4"), .Dim = c(43L, 15L), .Dimnames = list(
              NULL, c("DATA", "DATA2", "ANO", "MES", "QTDE_LOJA", "ID_ESTRELAS", 
                      "QTDE_ID_ENDERECO", "QTDE_TRANSACAO", "QTDE_VL_COMISSAO", 
                      "QTDE_VL_TAXA", "QTDE_VL_REEMBOLSO", "Receita_RPC", "Receita_Liquida", 
                      "Ticket_Medio", "VL_TRANSACIONADO")))

Step by step from what I did, I started turning my data into an array and then turned that matrix into a time series.

dados = as.matrix(dados)

VL_TR_TS = ts(dados[,c("VL_TRANSACIONADO")], start = c(2016,1), end = c(2019,7), frequency = 12)

Then I created my training base, test and my model using auto..

treino = window(VL_TR_TS, start=c(2016,1), end=c(2019,2))

teste = window(VL_TR_TS, start=c(2019,3), end=c(2019,7))


modelo_1 = auto.arima(treino, seasonal = F)

But when I run the template script, it displays the above mentioned error message. In the field seasonal left as FALSE, why it was another error that does not indicate seasonality and I spent my base from 2 to 3 years because I saw in some forums that for the sample base to work in the auto.arima would have to be more than 2 years, but still the error message continues.

What mistake am I making? What should I do to correct this error in the auto model.?

1 answer

1


Your data is in format character and not as numeric. I’ll post it right away by the information you’ve given me.

You can also fix this on import by viewing the parameters you used. If you do this recommend not turn into matrix, it is a step you do not need and if there are different formats it will force everything to be character because matrix can not have more than one format, other than one data.frame.

VL_TR_TS <- as.numeric(dados[,c("VL_TRANSACIONADO")])
VL_TR_TS = ts(VL_TR_TS, start = c(2016,1), end = c(2019,7), frequency = 12)

treino = window(VL_TR_TS, start=c(2016,1), end=c(2019,2))

teste = window(VL_TR_TS, start=c(2019,3), end=c(2019,7))


modelo_1 = auto.arima(treino, seasonal = F)
  • thanks for the reply, I will test.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.