dy.d_: Partial Derivative dy/d_[wrt]

Description Usage Arguments Value Note Author(s) References Examples

View source: R/dy_d_wrt.R

Description

Returns the numerical partial derivate of y with respect to [wrt] any regressor for a point of interest. Finite difference method is used with NNS.reg estimates as f(x + h) and f(x - h) values.

Usage

1
2
3
dy.d_(x, y, wrt, eval.points = "median", order = NULL, stn = 0.99,
  h = 0.05, n.best = NULL, mixed = FALSE, plot = FALSE,
  noise.reduction = "mean")

Arguments

x

a numeric matrix or data frame.

y

a numeric vector with compatible dimsensions to x.

wrt

integer; Selects the regressor to differentiate with respect to.

eval.points

numeric or options: ("mean", median", "last"); Regressor points to be evaluated. (eval.points = "median") (default) to find partial derivatives at the median of every variable. Set to (eval.points = "last") to find partial derivatives at the last value of every variable. Set to (eval.points="mean") to find partial derivatives at the mean value of every variable. Set to (eval.points = "all") to find partial derivatives at every observation.

order

integer; NNS.reg "order", defaults to NULL.

stn

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

h

numeric [0, ...]; Percentage step used for finite step method. Defaults to h = .05 representing a 5 percent step from the value of the regressor.

n.best

integer; Sets the number of closest regression points to use in estimating finite difference points in NNS.reg. NULL (default) Uses ceiling(sqrt(ncol(x))).

mixed

logical; FALSE (default) If mixed derivative is to be evaluated, set (mixed = TRUE). Only for single valued eval.points.

plot

logical; FALSE (default) Set to (plot = TRUE) to view plot.

noise.reduction

the method of determing regression points options: ("mean", "median", "mode", "off"); In low signal to noise situations, (noise.reduction = "median") uses medians instead of means for partitions, while (noise.reduction = "mode") uses modes instead of means for partitions. (noise.reduction = "off") allows for maximum possible fit in NNS.reg. Default setting is (noise.reduction = "mean").

Value

Returns:

Retuns a vector of partial derivatives when (eval.points = "all").

Note

For known function testing and analysis, regressors should be transformed via expand.grid to fill the dimensions with (order = "max"). Example provided below.

Author(s)

Fred Viole, OVVO Financial Systems

References

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

Examples

1
2
3
4
5
6
7
8
9
set.seed(123) ; x_1 <- runif(100) ; x_2 <- runif(100) ; y <- x_1 ^ 2 * x_2 ^ 2
B = cbind(x_1, x_2)
## To find derivatives of y wrt 1st regressor
dy.d_(B, y, wrt = 1, eval.points = c(.5, .5))

## Known function analysis: [y = a ^ 2 * b ^ 2]
x_1 <- seq(0, 1, .1) ; x_2 <- seq(0, 1, .1)
B = expand.grid(x_1, x_2) ; y <- B[ , 1] ^ 2 * B[ , 2] ^ 2
dy.d_(B, y, wrt = 1, eval.points = c(.5, .5), order = "max")

NNS documentation built on May 15, 2018, 5:04 p.m.