vignettes/Tutorials/Generate_GRIDs.Rmd
Generate_GRIDs.Rmd
To use more advanced fitting procedures in DDModeling, you must first generate a GRID. GRIDs can be understood as a kind of multidimensional mesh that connects the orthogonal axes spanned by the parameters of a given model and their representations. Mathematically speaking, a GRID represents a number of domain-codomain connections for a given function/model. Graphically speaking, a GRID resembles the evaluation of a model for certain parameter combinations.
In DDModeling GRIDs are used for two kinds of purposes. First, they help to reduce startvalue problems of local optimization procedures. Second, they resemble datasets that are quite useful for training deep learning networks, which in turn can help to improve local optimization methods.
GRID generation in DDModeling is simple. It is done by calling the function Generate_GRID()
which takes four arguments: model, path, name and eval_pts. The model takes a predefined DDModel object (see here for a tutorial). path specifies the directory where the GRID should be stored. Since GRIDs can be quite large DDModeling abstains from saving it in the R environment (which is limited by your RAM pool!) and saves them on your hard disk, so specifying a directory is crucial. name determines the file name of the GRID and further the name of the created subdirectory in the path. Finally, eval_pts specifies the number of evaluation points per parameter, i.e. a numerical vector with a length equal to the number of parameters found in the model is required. Its values must be natural numbers greater than 0! Let’s look at an example:
library(DDModeling) DSTP <- DDModel(model="DSTP",task = "flanker", CDF_perc = c(0.1,0.3,0.5,0.7,0.9), CAF_perc = c(0.0,0.2,0.4,0.6,0.8,1.0)) PTS <- rep(2,ncol(DSTP@DM)) Grid_DSTP <- Generate_GRID(model = DSTP, path = getwd(), name = "DSTP_Flanker", eval_pts = PTS)
Here we have created a GRID for the DSTP. We used 2 evaluation points per parameter (see PTS). The GRID resulting from Generate_GRID()
will always be equally spaced, i.e. in the example above Grid_DSTP is formed from the two parameter values per parameter, which divide the corresponding domain (specified in the DDModel) into three equally sized subsets. In a GRID every combination of all evaluation points is simulated, which leads to 128 (2 to the power of 7) evaluations in the example above. Note that you can specify ‘eval_pts’ as you wish, but I strongly recommend that you consider the computational requirement for a larger specification. Although the function takes advantage of all but one of your computer’s available threads, it can take quite a long time (on a Threadripper 1950X, the above example with eval_pts = rep(12,ncol(DSTP@DM)
takes about 7 days). You can also choose different values for different parameters:
PTS <- c(1,1,2,2,3,1,2) Grid_DSTP2 <- Generate_GRID(model = DSTP, path = getwd(), name = "DSTP_Flanker2", eval_pts = PTS)
Note that Generate_GRID()
will return the path of the directory for the GRID, which in turn can be used for further practices in DDModeling, like fitting or deep learning.