transForecast_ann: Forecast - using Artificial Neural Networks

Description Usage Arguments Value Author(s) Examples

Description

This model implements a forecasting method using Artificial Neural Networks.

Usage

1
2
3
transForecast_ann(data, histData, predData_ann, startDate, endDate,
                    method, interval, snapshots, defind, depVar, indVars,  ratingCat, 
                    pct, hiddenlayers,activation,stepMax,rept, calibration)

Arguments

data

a table containing historical credit ratings data (i.e., credit migration data). A dataframe of size nRecords x 3 where each row contains an ID (column 1), a date (column 2), and a credit rating (column 3); The credit rating is the rating assigned to the corresponding ID on the corresponding date.

histData

historical macroeconomic,financial and non-financial data.

predData_ann

forecasting data.

startDate

start date of the estimation time window, in string or numeric format.

endDate

end date of the estimation time window, in string or numeric format.

method

estimation algorithm, in string format. Valid values are 'duration' or 'cohort'.

interval

the length of the transition interval under consideration, in years. The default value is 1, i.e., 1-year transition probabilities are estimated.

snapshots

integer indicating the number of credit-rating snapshots per year to be considered for the estimation. Valid values are 1, 4, or 12. The default value is 1, i.e., one snapshot per year. This parameter is only used in the 'cohort' algorithm.

defind

Default Indicator

depVar

dependent variable, as a string.

indVars

list containing the independent variables.

ratingCat

list containing the unique rating categories

pct

percent of data used in training dataset.

hiddenlayers

a vector of integers specifying the number of hidden neurons (vertices) in each layer.

activation

activation function. strings, 'logistic' and 'tanh' are possible for the logistic function and tangent hyperbolicus

stepMax

the maximum steps for the training of the neural network. Reaching this maximum leads to a stop of the neural network's training process.

rept

the number of repetitions for the neural network's training.

calibration

determines if code uses the caret package to find optimal parameter. 'Yes' and 'No'

Value

The output consists of a forecasted transition matrix using ANN.

Author(s)

Abdoulaye (Ab) N'Diaye

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
## Not run: 
library(dplyr)
library(plyr)
library(Matrix)


for (i in c(24,25,26)) {
 tic()
 data <- data
 
 histData <- histData.normz

 predData_ann2 <- predData_ann_Baseline
 predData_ann2 <- subset(
   predData_ann2,
   X == i,
   select = c(Market.Volatility.Index..Level..normz

   )
 )
 
 indVars   = c("Market.Volatility.Index..Level..normz"

 )
 
 
 startDate = "1991-08-16"
 endDate   = "2007-08-16"
 
 
 depVar <- c("end_rating")
 
 pct <- 1
 wgt <-  "mCount"
 ratingCat <- c("A", "B", "C", "D", "E", "F", "G")
 defind    <- "G"
 
 
 ratingCat <- as.numeric(factor(
   ratingCat,
   levels = c('A', 'B', 'C', 'D', 'E', 'F', 'G'),
   labels = c(1, 2, 3, 4, 5, 6, 7)
 ))
 
 defind <- as.numeric(factor(
   defind,
   levels = c('A', 'B', 'C', 'D', 'E', 'F', 'G'),
   labels = c(1, 2, 3, 4, 5, 6, 7)
 ))
 
 method    = "cohort"
 snapshots = 1
 interval  = 1
 hiddenlayers = c(1)
 activation = "logistic"
 stepMax = 1e9                #increase to make sure the DNN converges
 calibration = "FALSE"
 rept = 1
 
 ann_TM <-
   transForecast_ann(
     data,
     histData,
     predData_ann2,
     startDate,
     endDate,
     method,
     interval,
     snapshots,
     defind,
     depVar,
     indVars,
     ratingCat,
     pct,
     hiddenlayers,
     activation,
     stepMax,
     rept,
     calibration
   )
 print(ann_TM)
 
 toc()
}

## End(Not run)

RTransProb documentation built on May 2, 2019, 6:49 a.m.