Instead of modeling the function as an ARIMA process, I am trying to use random forests and gradient boosting as regression techniques. In the problem setup, the predictors are t_2, and t_1 and the predicted variable is t. Using the period between January 1974 and December 1978 as a training set, and using 1979 as a test set. I am trying to make a Random Forest model in R, but I am stuck at the below part, where I am getting No. of variables tried at each split: 1 and sometimes OOB is 100%. Could anyone please help me out? Thanks In advance
library(randomForest)
library(caret)
library(e1071)
library(ranger)
#converting ldeath timeseries to vector
ldeathsVector <- as.vector(ldeaths)
#dividing the vectors into 3 vectors
t_2<- ldeathsVector[1:70]
t_1<- ldeathsVector[2:71]
t<-ldeathsVector[3:72]
ldeathDataFrame <- data.frame(t_2=t_2,t_1 =t_1,t=t)
ldeathTraining <- ldeathDataFrame[1:58,]
ldeathTesting <- ldeathDataFrame[59:70,]
ldeathTraining <- ldeathTraining[complete.cases(ldeathTraining),]
ldeathTesting <- ldeathTraining[complete.cases(ldeathTesting),]
formula <- paste(t, "~", paste(t_1, t_2 = " + "))
ldeathRandomForest <- randomForest(t ~ t_1+t_2,
ldeathTraining,
num.trees = 510,importance = TRUE)