You can also embed plots, for example: First, I divided the set into a training and test set, with 20% of the observations held out.
library(dplyr)
electric<-aus_production %>%
select(c('Quarter', 'Electricity'))
training<-electric[1:174,]
test<-electric[175:218, ]
Then I used the NNETAR() function to produce a prediction and tested it, looking at RMSE, etc.
elecmod_2 <- training %>%
model(NNETAR(sqrt(Electricity)))
pred<-forecast(elecmod_2, h=20)
autoplot(pred, training)
library(kableExtra)
##
## Attaching package: 'kableExtra'
## The following object is masked from 'package:dplyr':
##
## group_rows
acc1=accuracy(pred, test)
acc1%>%kbl(caption="Neural Net")%>%kable_classic(html_font="Cambria")
| .model | .type | ME | RMSE | MAE | MPE | MAPE | MASE | RMSSE | ACF1 |
|---|---|---|---|---|---|---|---|---|---|
| NNETAR(sqrt(Electricity)) | Test | 1685.941 | 1972.243 | 1685.941 | 3.210316 | 3.210316 | NaN | NaN | 0.3063724 |
Note that the echo = FALSE parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.