NNS.reg: NNS Regression

Description Usage Arguments Value Note Author(s) References Examples

View source: R/Regression.R

Description

Generates a nonlinear regression based on partial moment quadrant means.

Usage

1
2
3
4
5
6
7
NNS.reg(x, y, factor.2.dummy = TRUE, order = NULL, stn = 0.98,
  dim.red.method = NULL, tau = NULL, type = NULL, point.est = NULL,
  location = "top", return.values = TRUE, plot = TRUE,
  plot.regions = FALSE, residual.plot = TRUE, std.errors = FALSE,
  confidence.interval = NULL, threshold = 0, n.best = NULL,
  noise.reduction = "mean", norm = NULL, dist = "L2",
  multivariate.call = FALSE)

Arguments

x

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

y

a numeric or factor vector with compatible dimsensions to x.

factor.2.dummy

logical; TRUE (default) Automatically augments variable matrix with numerical dummy variables based on the levels of factors.

order

integer; Controls the number of partial moment quadrant means. Users are encouraged to try different (order = ...) integer settings with (noise.reduction = "off"). (order = "max") will force a limit condition perfect fit.

stn

numeric [0, 1]; Signal to noise parameter, sets the threshold of (NNS.dep) which reduces ("order") when (order = NULL). Defaults to 0.98 to ensure high dependence for higher ("order") and endpoint determination.

dim.red.method

options: ("cor", "NNS.cor", "NNS.caus", "all", NULL) method for determining synthetic X* coefficients. Selection of a method automatically engages the dimension reduction regression. The default is NULL for full multivariate regression. (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 = "cor") uses standard linear correlation for weights. (dim.red.method = "all") averages all methods for further feature engineering.

tau

options("ts", NULL); NULL(default) If (dim.red.method = "NNS.caus") or

(dim.red.method = "all") and the regression is using time-series data, set (tau = "ts") for more accurate causal analysis.

type

NULL (default). To perform a classification, set to (type = "CLASS").

point.est

a numeric or factor vector with compatible dimsensions to x. Returns the fitted value y.hat for any value of x.

location

Sets the legend location within the plot, per the x and y co-ordinates used in base graphics legend.

return.values

logical; TRUE (default), set to FALSE in order to only display a regression plot and call values as needed.

plot

logical; TRUE (default) To plot regression.

plot.regions

logical; FALSE (default). Generates 3d regions associated with each regression point for multivariate regressions. Note, adds significant time to routine.

residual.plot

logical; TRUE (default) To plot y.hat and Y.

std.errors

logical; FALSE (default) To provide standard errors of each linear segment in the "Fitted.xy" output.

confidence.interval

numeric [0, 1]; NULL (default) Plots the associated confidence interval with the estimate and reports the standard error for each individual segment.

threshold

numeric [0, 1]; (threshold = 0) (default) Sets the threshold for dimension reduction of independent variables when (dim.red.method) is not NULL.

n.best

integer; NULL (default) Sets the number of nearest regression points to use in weighting for multivariate regression at sqrt(# of regressors). (n.best = "all") will select and weight all generated regression points. Analogous to k in a k Nearest Neighbors algorithm. Different values of n.best are tested using cross-validation in NNS.stack.

noise.reduction

the method of determing regression points options: ("mean", "median", "mode", "off"); In low signal:noise situations,(noise.reduction = "mean") uses means for NNS.dep restricted partitions, (noise.reduction = "median") uses medians instead of means for NNS.dep restricted partitions, while (noise.reduction = "mode") uses modes instead of means for NNS.dep restricted partitions. (noise.reduction = "off") allows for maximum possible fit with a specific order.

norm

NULL (default) the method of normalization options: ("NNS", "std"); Normalizes x between 0 and 1 for multivariate regression when set to (norm = "std"), or normalizes x according to NNS.norm when set to (norm = "NNS").

dist

options:("L1", "L2") the method of distance calculation; Selects the distance calculation used. dist = "L2" (default) selects the Euclidean distance and (dist = "L1") seclects the Manhattan distance.

multivariate.call

Internal parameter for multivariate regressions.

Value

UNIVARIATE REGRESSION RETURNS THE FOLLOWING VALUES:

MULTIVARIATE REGRESSION RETURNS THE FOLLOWING VALUES:

Note

Please ensure point.est is of compatible dimensions to x, error message will ensue if not compatible. Also, upon visual inspection of the data, if a highly periodic variable is observed set (stn = 0) or (order = "max") to ensure a proper fit.

Identical regressors can be used as long as they do not share the same name. For instance, NNS.reg(cbind(x, 1 * x), y) will work as NNS.reg is not affected by multicollinearity.

NNS (>= v.0.3.4) has repurposed parameter (type = "CLASS"). (type = "CLASS") is now restricted to signifying a classification analysis for NNS.reg while (dim.red.method) enables dimension reduction regressions.

Author(s)

Fred Viole, OVVO Financial Systems

References

Viole, F. and Nawrocki, D. (2013) "Nonlinear Nonparametric Statistics: Using Partial Moments" http://amzn.com/1490523995

Vinod, H. and Viole, F. (2017) "Nonparametric Regression Using Clusters" https://link.springer.com/article/10.1007/s10614-017-9713-5

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
set.seed(123)
x <- rnorm(100) ; y <- rnorm(100)
NNS.reg(x, y)

## Manual {order} selection
## Not run: 
NNS.reg(x, y, order = 2)
## End(Not run)

## Maximum {order} selection
## Not run: 
NNS.reg(x, y, order = "max")
## End(Not run)

## x-only paritioning (Univariate only)
## Not run: 
NNS.reg(x, y, type = "XONLY")
## End(Not run)

## For Multiple Regression:
## Not run: 
x <- cbind(rnorm(100), rnorm(100), rnorm(100)) ; y <- rnorm(100)
NNS.reg(x, y, point.est = c(.25, .5, .75))
## End(Not run)

## For Multiple Regression based on Synthetic X* (Dimension Reduction):
## Not run: 
x <- cbind(rnorm(100), rnorm(100), rnorm(100)) ; y<-rnorm(100)
NNS.reg(x, y, point.est = c(.25, .5, .75), dim.red.method = "cor")
## End(Not run)

## IRIS dataset examples:
# Dimension Reduction:
## Not run: 
NNS.reg(iris[,1:4], iris[,5], dim.red.method = "cor", order = 5)
## End(Not run)

# Dimension Reduction using causal weights:
## Not run: 
NNS.reg(iris[,1:4], iris[,5], dim.red.method = "NNS.caus", order = 5)
## End(Not run)

# Multiple Regression:
## Not run: 
NNS.reg(iris[,1:4], iris[,5], order = 2, noise.reduction = "off")
## End(Not run)

# Classification:
## Not run: 
NNS.reg(iris[,1:4], iris[,5], point.est = iris[1:10, 1:4], type = "CLASS")$Point.est
## End(Not run)

## To call fitted values:
## Not run: 
x <- rnorm(100) ; y <- rnorm(100)
NNS.reg(x, y)$Fitted
## End(Not run)

## To call partial derivative (univariate regression only):
## Not run: 
NNS.reg(x, y)$derivative
## End(Not run)

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