sgd_lm {SGDinference} | R Documentation |
Averaged SGD in Linear Mean Regression
Description
Compute the averaged SGD estimator for the coefficients in linear mean regression.
Usage
sgd_lm(
formula,
data,
gamma_0 = NULL,
alpha = 0.501,
burn = 1,
bt_start = NULL,
studentize = TRUE,
no_studentize = 100L,
intercept = TRUE,
path = FALSE,
path_index = c(1)
)
Arguments
formula |
formula. The response is on the left of a ~ operator. The terms are on the right of a ~ operator, separated by a + operator. |
data |
an optional data frame containing variables in the model. |
gamma_0 |
numeric. A tuning parameter for the learning rate (gamma_0 x t ^ alpha). Default is NULL and it is determined by the adaptive method: 1/sd(y). |
alpha |
numeric. A tuning parameter for the learning rate (gamma_0 x t ^ alpha). Default is 0.501. |
burn |
numeric. A tuning parameter for "burn-in" observations. We burn-in up to (burn-1) observations and use observations from (burn) for estimation. Default is 1, i.e. no burn-in. |
bt_start |
numeric. (p x 1) vector, excluding the intercept term. User-provided starting value. Default is NULL. |
studentize |
logical. Studentize regressors. Default is TRUE. |
no_studentize |
numeric. The number of observations to compute the mean and std error for studentization. Default is 100. |
intercept |
logical. Use the intercept term for regressors. Default is TRUE. If this option is TRUE, the first element of the parameter vector is the intercept term. |
path |
logical. The whole path of estimation results is out. Default is FALSE. |
path_index |
numeric. A vector of indices to print out the path. Default is 1. |
Value
An object of class "sgdi"
, which is a list containing the following
coefficients
a vector of estimated parameter values
path_coefficients
The path of coefficients.
Note
The dimension of coefficients
is (p+1) if intercept
=TRUE or p otherwise.
Examples
n = 1e05
p = 5
bt0 = rep(5,p)
x = matrix(rnorm(n*(p-1)), n, (p-1))
y = cbind(1,x) %*% bt0 + rnorm(n)
my.dat = data.frame(y=y, x=x)
sgd.out = sgd_lm(y~., data=my.dat)