View source: R/regression_hubreg.R
hubreg | R Documentation |
regression and scale using Huber's criterion
hubreg(y, X, c = NULL, sig0 = NULL, b0 = NULL, printitn = 0, iter_max = 2000, errortol = 1e-05)
y: |
Numeric data vector of size N x 1 (output, respones) |
X: |
Numeric data matrix of size N x p. Each row represents one observation, and each column represents one predictor (feature). If the model has an intercept, then first column needs to be a vector of ones. |
c: |
numeric threshold constant of Huber's function |
sig0: |
(numeric) initial estimator of scale |
b0: |
initial estimator of regression (default: LSE) |
printitn: |
print iteration number (default = 0, no printing) |
iter_max: |
maximum number of iterations. |
errortol: |
ERROR TOLERANCE FOR HALTING CRITERION. |
hubreg computes the joint M-estimates of regression and scale using Huber's criterion. Function works for both real- and complex-valued data.
b1: the regression coefficient vector estimate
sig1: the estimate of scale
iter: the # of iterations
uses ginv
from the MASS package
library(MASS) y <- c(1.0347, 0.7269, -0.3034, 0.2939, -0.7873) X <- matrix(c(0.884, -1.1471, -1.0689, -0.8095, -2.9443, 1.4384, 0.3252, -0.7549, 1.3703, -1.7115), 5, 2) hubreg(y, X) hubreg(y+1i, X) hubreg(y+1i, X+1i) hubreg(y, X+1i)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.