# NOT RUN {
set.seed(123) ; x_1 <- runif(1000) ; x_2 <- runif(1000) ; y <- x_1 ^ 2 * x_2 ^ 2
B <- cbind(x_1, x_2)
## To find derivatives of y wrt 1st regressor for specific points of both regressors
dy.d_(B, y, wrt = c(1, 2), eval.points = t(c(.5, .5)))
## To find average partial derivative of y wrt 1st regressor,
only supply 1 value in [eval.points], or a vector of [eval.points]:
dy.d_(B, y, wrt = 1, eval.points = .5)
dy.d_(B, y, wrt = 1, eval.points = fivenum(B[,1]))
## To find average partial derivative of y wrt 1st regressor,
for every oberservation of 1st regressor:
apd <- dy.d_(B, y, wrt = 1, eval.points = "apd")
plot(B[,1], apd[,1]$First)
## 95% Confidence Interval to test if 0 is within
### Lower CI
LPM.VaR(.025, 0, apd[,1]$First)
### Upper CI
UPM.VaR(.025, 0, apd[,1]$First)
# }
Run the code above in your browser using DataLab