0

I'm using a Unobserved Components Model (rucm package )to predict future values using several independent variables.

Demand <- read.csv2("Demand.csv") 
# e.g. sample(x = 800 : 15000, size =50)
Cars <- read.csv2("Cars.csv")
#e.g. sample(x = 500 : 800, size =50)
...
Duration (1-60), Distance (300 and 3000) Rain (between 0 and 500), Sun_hrs (0-12), Temperatur (-3 to 27), Wind (0 to 80)
Multivariate_DataFrame <- data.frame(Demand, Cars, Duration, Distance, Rain, Sun, Temperature, Wind)
head(Multivariate_DataFrame)

library(rucm)

ucm_xyz <- ucm(formula = Demand ~ Cars + Duration + Distance + Rain + Regulars + Sun + Temperature + Wind, data = Multivariate_DataFrame, level = TRUE, slope = TRUE, irregular = TRUE, season = TRUE, season.length =12)
ucm_xyz$model

returns:

Call:
SSModel(formula = as.formula(ssm.formula), data = data, H = H)

State space model object of class SSModel

Dimensions:
[1] Number of time points: 46
[1] Number of time series: 1
[1] Number of disturbances: 3
[1] Number of states: 21
Names of the states:
 [1]  Cars Duration Distance Rain Regulars Sun Temperature 
 [8]  Wind level slope sea_dummy1 sea_dummy2 sea_dummy3 sea_dummy4     
[15]  sea_dummy5 sea_dummy6 sea_dummy7 sea_dummy8 sea_dummy9 sea_dummy10     sea_dummy11  
    
Distributions of the time series:
[1]  gaussian

Object is a valid object of class SSModel.

The summary function states that model has the length of 14, Class is SSModel and Mode is list.

When forecasting:

predict(ucm_xyz["model"],n.ahead = 6, newdata = Multivariate_Dataframe)

The error message:

Error in UseMethod("predict") : 
  no applicable method for 'predict' applied to an object of class "list"

occurs.

Any help would be fantastic

Marco_V
  • 1
  • 1
  • Please read the information at the top of the [tag:r] tag page. In particular provide complete, self contained reproducible and minimal code and input so that anyone else can easily reproduce the problems using copy and paste into their R session. – G. Grothendieck Nov 26 '21 at 14:23
  • @G.Grothendieck. Sorry, that would have been helpful for viewers. I updated the question with all relevant information. – Marco_V Nov 26 '21 at 15:36

0 Answers0