NNS.stack: NNS stack

Description Usage Arguments Value Note Author(s) References Examples

View source: R/Stack.R

Description

Prediction model using the predictions of the NNS base models NNS.reg as features (i.e. meta-features) for the stacked model.

Usage

1
2
3
NNS.stack(IVs.train, DV.train, IVs.test = NULL, CV.size = NULL,
  weight = "SSE", order = NULL, norm = NULL, method = c(1, 2),
  dim.red.method = "cor", seed = 123)

Arguments

IVs.train

a vector, matrix or data frame of variables of numeric or factor data types.

DV.train

a numeric or factor vector with compatible dimsensions to (IVs.train).

IVs.test

a vector, matrix or data frame of variables of numeric or factor data types.

CV.size

numeric [0, 1]; NULL (default) Sets the cross-validation size if (IVs.test = NULL). Defaults to 0.25 for a 25 percent random sampling of the training set under (CV.size = NULL).

weight

options: ("SSE", "Features") method for selecting model output weight; Set (weight = "SSE") for optimum parameters and weighting based on each base model's sum of squared errors. (weight = "Feautures") uses a weighting based on the number of features present, whereby logistic NNS.reg receives higher relative weights for more regressors. Defaults to "SSE".

order

integer; NULL (default) Sets the order for NNS.reg, where (order = 'max') is the k-nearest neighbors equivalent.

norm

options: ("std", "NNS", NULL); NULL (default) 3 settings offered: NULL, "std", and "NNS". Selects the norm parameter in NNS.reg.

method

numeric options: (1, 2); Select the NNS method to include in stack. (method = 1) selects NNS.reg; (method = 2) selects NNS.reg dimension reduction regression. Defaults to method = c(1, 2), including both NNS regression methods in the stack.

dim.red.method

options: ("cor", "NNS.cor", "NNS.caus", "all") method for determining synthetic X* coefficients. (dim.red.method = "cor") (default) uses standard linear correlation for weights. (dim.red.method = "NNS.cor") uses NNS.cor for nonlinear correlation weights, while (dim.red.method = "NNS.caus") uses NNS.caus for causal weights. (dim.red.method = "all") averages all methods for further feature engineering.

seed

numeric; 123 (default) Sets seed for CV sampling.

Value

Returns a vector of fitted values for the dependent variable test set for all models.

Note

If character variables are used, transform them first to factors using as.factor, or data.matrix to ensure overall dataset is numeric. A multifunction sapply can also be applied to the overall dataset: data <- sapply(data,function(x){as.factor(x) ; as.numeric(x)}). Then run NNS.stack with transormed variables.

Missing data should be handled prior as well using na.omit or complete.cases on the full dataset.

If error received:

"Error in is.data.frame(x) : object 'RP' not found"

reduce the CV.size.

Author(s)

Fred Viole, OVVO Financial Systems

References

Viole, F. (2016) "Classification Using NNS Clustering Analysis" https://ssrn.com/abstract=2864711

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
 ## Using 'iris' dataset where test set [IVs.test] is 'iris' rows 141:150.
 ## Not run: 
 NNS.stack(iris[1:140, 1:4], iris[1:140, 5], IVs.test = iris[141:150, 1:4])
## End(Not run)

 ## Using 'iris' dataset to determine [n.best] and [threshold] with no test set.
 ## Not run: 
 NNS.stack(iris[ , 1:4], iris[ , 5])
## End(Not run)

 ## Selecting NNS.reg and dimension reduction techniques.
 ## Not run: 
 NNS.stack(iris[1:140, 1:4], iris[1:140, 5], iris[141:150, 1:4], method = c(1, 2))
## End(Not run)

NNS documentation built on April 15, 2019, 5:05 p.m.