Predicting country ratings using macroeconomic information

In our clustering model, discussed in Chapter 6Visualizing Economic Problems in the European Union, using self-organizing maps, all the available data was used. Now, in order to train a model to be able to predict sovereign ratings, we need to split the data into two samples: train and test.

That's not new for us. When we tried to develop different models to predict a bank's failures, we used the caTools package to split the data, while considering our target variable.

The same procedure is used again here:

library(caTools) index = sample.split(macroeconomic_data$RatingMayT1, SplitRatio = .75) train_macro<-subset(macroeconomic_data, index == TRUE)test_macro<-subset(macroeconomic_data, ...

Get Machine Learning with R Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.