Description Usage Arguments Value Examples
This function provides a vectorized version of the gradient computation
1 |
par |
Parameters values. |
X |
Data predictors. |
Y |
Response variables. |
verbose |
If set TRUE the function produce messages during the computation. |
Returns the vector containing the gradient scores.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # Having the parameters vector "par", the predictors matrix "X",
# and the outcome vector "Y",
# the gradient is calculated as follows:
set.seed(8675309)
# data simulation for example purposes
n = 1000
x1 = rnorm(n)
x2 = rnorm(n)
X <- cbind(rep(1,n),x1,x2)
Y = 1 + 0.5*x1 + 0.2*x2 + rnorm(n)
# random initial values for the parameters of the linear model
par <- rnorm(dim(X)[2])
# gradient calculation
my_grad(par, X, Y)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.