# Getting Started with NNS: Clustering and Regression" In NNS: Nonlinear Nonparametric Statistics

## NNS Dimension Reduction Regression

NNS.reg also provides a dimension reduction regression by including a parameter NNS.reg(x, y, dim.red.method = "cor", ...). Reducing all regressors to a single dimension using the returned equation NNS.reg(..., dim.red.method = "cor", ...)$equation. NNS.reg(iris[ , 1 : 4], iris[ , 5], dim.red.method = "cor", location = "topleft", ncores = 1)$equation
a = NNS.reg(iris[ , 1 : 4], iris[ , 5], dim.red.method = "cor", location = "topleft", ncores = 1, plot = FALSE)$equation Thus, our model for this regression would be: $$Species = \frac{r round(aCoefficient[1],3)Sepal.Length r round(aCoefficient[2],3)Sepal.Width +r round(aCoefficient[3],3)Petal.Length +r round(aCoefficient[4],3)Petal.Width}{4}$$ ### Threshold NNS.reg(x, y, dim.red.method = "cor", threshold = ...) offers a method of reducing regressors further by controlling the absolute value of required correlation. NNS.reg(iris[ , 1 : 4], iris[ , 5], dim.red.method = "cor", threshold = .75, location = "topleft", ncores = 1)$equation
a = NNS.reg(iris[ , 1 : 4], iris[ , 5], dim.red.method = "cor", threshold = .75, location = "topleft", ncores = 1, plot = FALSE)$equation Thus, our model for this further reduced dimension regression would be: $$Species = \frac{\: r round(aCoefficient[1],3)Sepal.Length + r round(aCoefficient[2],3)Sepal.Width +r round(aCoefficient[3],3)Petal.Length +r round(aCoefficient[4],3)Petal.Width}{3}$$ and the point.est = (...) operates in the same manner as the full regression above, again called with NNS.reg(...)$Point.est.

# Cross-Validation NNS.stack()

The NNS.stack routine cross-validates for a given objective function the n.best parameter in the multivariate NNS.reg function as well as the threshold parameter in the dimension reduction NNS.reg version. NNS.stack can be used for classification:

NNS.stack(..., type = "CLASS", ...)

or continuous dependent variables:

NNS.stack(..., type = NULL, ...).

Any objective function obj.fn can be called using expression() with the terms predicted and actual.

NNS.stack(IVs.train = iris[ , 1 : 4],
DV.train = iris[ , 5],
IVs.test = iris[1 : 10, 1 : 4],
dim.red.method = "cor",
obj.fn = expression( mean(round(predicted) == actual) ),
objective = "max", type = "CLASS",
folds = 1, ncores = 1)
Folds Remaining = 0
Current NNS.reg(... , threshold = 0.95 ) MAX Iterations Remaining = 2
Current NNS.reg(... , threshold = 0.78 ) MAX Iterations Remaining = 1
Current NNS.reg(... , threshold = 0.415 ) MAX Iterations Remaining = 0
Current NNS.reg(... , n.best = 1 ) MAX Iterations Remaining = 12
Current NNS.reg(... , n.best = 2 ) MAX Iterations Remaining = 11
Current NNS.reg(... , n.best = 3 ) MAX Iterations Remaining = 10
Current NNS.reg(... , n.best = 4 ) MAX Iterations Remaining = 9
Current NNS.reg(... , n.best = 5 ) MAX Iterations Remaining = 8
Current NNS.reg(... , n.best = 6 ) MAX Iterations Remaining = 7
Current NNS.reg(... , n.best = 7 ) MAX Iterations Remaining = 6
Current NNS.reg(... , n.best = 8 ) MAX Iterations Remaining = 5
Current NNS.reg(... , n.best = 9 ) MAX Iterations Remaining = 4
Current NNS.reg(... , n.best = 10 ) MAX Iterations Remaining = 3
Current NNS.reg(... , n.best = 11 ) MAX Iterations Remaining = 2
Current NNS.reg(... , n.best = 12 ) MAX Iterations Remaining = 1
Current NNS.reg(... , n.best = 150 ) MAX Iterations Remaining = 0
$OBJfn.reg [1] 0.9733333$NNS.reg.n.best
[1] 1

$probability.threshold [1] 0.5$OBJfn.dim.red
[1] 0.96

$NNS.dim.red.threshold [1] 0.78$reg
[1] 1 1 1 1 1 1 1 1 1 1

$dim.red [1] 1 1 1 1 1 1 1 1 1 1$stack
[1] 1 1 1 1 1 1 1 1 1 1

## Increasing Dimensions

Given multicollinearity is not an issue for nonparametric regressions as it is for OLS, in the case of an ill-fit univariate model a better option may be to increase the dimensionality of regressors with a copy of itself and cross-validate the number of clusters n.best via:

NNS.stack(IVs.train = cbind(x, x), DV.train = y, method = 1, ...).

set.seed(123)
x = rnorm(100); y = rnorm(100)

nns.params = NNS.stack(IVs.train = cbind(x, x),
DV.train = y,
method = 1, ncores = 1)
set.seed(123)
x = rnorm(100); y = rnorm(100)

nns.params = list()
nns.params$NNS.reg.n.best = 9 NNS.reg(cbind(x, x), y, n.best = nns.params$NNS.reg.n.best,
point.est = cbind(x, x),
residual.plot = TRUE,
ncores = 1)

# References

If the user is so motivated, detailed arguments further examples are provided within the following:

## Try the NNS package in your browser

Any scripts or data that you put into this service are public.

NNS documentation built on Jan. 8, 2023, 1:08 a.m.