# dy.d_: Partial Derivative dy/d_[wrt] In OVVO-Financial/NNS: Nonlinear Nonparametric Statistics

## 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``` ```dy.d_(x, y, wrt, eval.points = "median", folds = 5, mixed = FALSE, plot = FALSE, messages = TRUE) ```

## 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", "all"); Regressor points to be evaluated. `(eval.points = "median")` (default) to find the average partial derivative at the median of the variable with respect to. Set to `(eval.points = "last")` to find the average partial derivative at the last observation of the variable with respect to (relevant for time-series data). Set to `(eval.points="mean")` to find the average partial derivative at the mean of the variable with respect to. Set to `(eval.points = "all")` to find the overall partial derivative at every observation of the variable with respect to. `folds` integer; 5 (default) Sets the number of `folds` in the NNS.stack procedure for optimal `n.best` parameter. `mixed` logical; `FALSE` (default) If mixed derivative is to be evaluated, set `(mixed = TRUE)`. `plot` logical; `FALSE` (default) Set to `(plot = TRUE)` to view plot. Default setting is `(noise.reduction = "mean")`. `messages` logical; `TRUE` (default) Prints status messages of cross-validation on `n.best` parameter for NNS.reg.

## Value

Returns:

• `dy.d_(...)\$"First Derivative"` the 1st derivative

• `dy.d_(...)\$"Second Derivative"` the 2nd derivative

• `dy.d_(...)\$"Mixed Derivative"` the mixed derivative (for two independent variables only).

## Author(s)

Fred Viole, OVVO Financial Systems

## References

Viole, F. and Nawrocki, D. (2013) "Nonlinear Nonparametric Statistics: Using Partial Moments" https://www.amazon.com/dp/1490523995

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18``` ```## Not run: 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 average partial derivative of y wrt 1st regressor, only supply 1 value in [eval.points] dy.d_(B, y, wrt = 1, eval.points = c(.5)) dy.d_(B, y, wrt = 1, eval.points = mean(B[, 1])) ## To find derivatives of y wrt 1st regressor and specified 2nd 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)) ## End(Not run) ```

OVVO-Financial/NNS documentation built on Feb. 14, 2020, 8:16 a.m.