Title: | Optimal Convex M-Estimation for Linear Regression via Antitonic Score Matching |
---|---|
Description: | Performs linear regression with respect to a data-driven convex loss function that is chosen to minimize the asymptotic covariance of the resulting M-estimator. The convex loss function is estimated in 5 steps: (1) form an initial OLS (ordinary least squares) or LAD (least absolute deviation) estimate of the regression coefficients; (2) use the resulting residuals to obtain a kernel estimator of the error density; (3) estimate the score function of the errors by differentiating the logarithm of the kernel density estimate; (4) compute the L2 projection of the estimated score function onto the set of decreasing functions; (5) take a negative antiderivative of the projected score function estimate. Newton's method (with Hessian modification) is then used to minimize the convex empirical risk function. Further details of the method are given in Feng et al. (2024) <doi:10.48550/arXiv.2403.16688>. |
Authors: | Yu-Chun Kao [aut], Min Xu [aut, cre], Oliver Y. Feng [aut], Richard J. Samworth [aut] |
Maintainer: | Min Xu <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.2.0 |
Built: | 2024-11-24 04:55:05 UTC |
Source: | https://github.com/cran/asm |
Performs linear regression with a data-driven convex loss function
asm(formula, data = NULL, ...)
asm(formula, data = NULL, ...)
formula |
regression formula |
data |
input data frame |
... |
additional arguments for asm.fit |
asm
class object containing the following components:
betahat
:vector of estimated coefficients
std_errs
:vector of standard errors of the estimated coefficients
fitted.values
:fitted values
residuals
:residuals
zvals
:z-values
sig_vals
:p-values
info_asm
:antitonic information
I_mat
:estimated antitonic information matrix
Cov_mat
:covariance matrix of the estimated coefficients
psi
:estimated antitonic score function
asm(mpg ~ cyl + hp + disp, data=mtcars)
asm(mpg ~ cyl + hp + disp, data=mtcars)
Performs linear regression via M-estimation with respect to a data-driven convex loss function
asm.fit( X, Y, betapilot = "OLS", alt_iter = 1, intercept.selection = "mean", k = 3000, max_iter = 65, kernel_pts = 2^15, bw = "nrd0", kernel = "gaussian", verbose = FALSE, ... )
asm.fit( X, Y, betapilot = "OLS", alt_iter = 1, intercept.selection = "mean", k = 3000, max_iter = 65, kernel_pts = 2^15, bw = "nrd0", kernel = "gaussian", verbose = FALSE, ... )
X |
design matrix |
Y |
response vector |
betapilot |
initial estimate of the regression coefficients: can be "LAD", "OLS" or a vector of coefficients |
alt_iter |
number of iterations of the alternating procedure: when alt_iter == 1, this function is equivalent to asm_regression |
intercept.selection |
mean or median of the residuals if intercept.selection == "median", then the standard error of the intercept estimate is set to NA |
k |
the density quantile function is evaluated at (0, 1/ |
max_iter |
maximum number of iterations for the damped Newton–Raphson algorithm when minimizing the convex loss function |
kernel_pts |
number of points at which the kernel density estimate is evaluated, i.e. the parameter "n" in density() |
bw |
bandwidth for kernel density estimation i.e. the parameter "bw" in density() |
kernel |
kernel for kernel density estimation i.e. the parameter "kernel" in density() |
verbose |
logical; if TRUE, print optimization progress |
... |
additional arguments to ensure compatibility with generic functions |
asm
class object containing the following components:
betahat
:vector of estimated coefficients
std_errs
:vector of standard errors of the estimated coefficients
fitted.values
:fitted values
residuals
:residuals
zvals
:z-values
sig_vals
:p-values
info_asm
:antitonic information
I_mat
:estimated antitonic information matrix
Cov_mat
:asymptotic covariance matrix of the estimated coefficients
psi
:estimated antitonic score function
n <- 1000 ; d <- 2 X <- matrix(rnorm(n * d), n, d) Y <- X %*% c(2, 3) + rnorm(n) # no intercept! asm.fit(X,Y)
n <- 1000 ; d <- 2 X <- matrix(rnorm(n * d), n, d) Y <- X %*% c(2, 3) + rnorm(n) # no intercept! asm.fit(X,Y)
asm
regression modelOutputs the coefficients of a fitted asm
regression model
## S3 method for class 'asm' coef(object, ...)
## S3 method for class 'asm' coef(object, ...)
object |
asm object |
... |
additional arguments to ensure compatibility with the generic function coef() |
vector of coefficients of the asm
regression model
model = asm(mpg ~ cyl + hp + disp, data=mtcars) coef(model)
model = asm(mpg ~ cyl + hp + disp, data=mtcars) coef(model)
asm
regression modelComputes confidence intervals for individual regression coefficients based on a fitted asm
regression model
## S3 method for class 'asm' confint(object, parm, level = 0.95, ...)
## S3 method for class 'asm' confint(object, parm, level = 0.95, ...)
object |
asm object |
parm |
parameters to calculate confidence intervals |
level |
confidence level |
... |
additional arguments to ensure compatibility with the generic function confint() |
matrix of confidence intervals for the regression coefficients
model = asm(mpg ~ cyl + hp + disp, data=mtcars) confint(model)
model = asm(mpg ~ cyl + hp + disp, data=mtcars) confint(model)
asm
regression modelGenerates plots of residuals vs fitted values, and the estimated convex loss
and antitonic score functions based on a fitted asm
regression model
## S3 method for class 'asm' plot( x, which = c(1, 2, 3), caption = list("Residuals vs fitted", "Convex loss function", "Antitonic score function"), extend.ylim.f = 0.08, id.n = 3, labels.id = rownames(x$residuals), label.pos = c(4, 2), ext.xlim.f = 0.08, grid.length.f = 10, ask = prod(par("mfcol")) < length(which) && dev.interactive(), ... )
## S3 method for class 'asm' plot( x, which = c(1, 2, 3), caption = list("Residuals vs fitted", "Convex loss function", "Antitonic score function"), extend.ylim.f = 0.08, id.n = 3, labels.id = rownames(x$residuals), label.pos = c(4, 2), ext.xlim.f = 0.08, grid.length.f = 10, ask = prod(par("mfcol")) < length(which) && dev.interactive(), ... )
x |
asm object |
which |
a subset of the plots to be displayed |
caption |
a list of captions for the plots |
extend.ylim.f |
factor to extend the y-axis limits for the residuals vs fitted plot |
id.n |
number of residuals to label in the residuals vs fitted plot |
labels.id |
labels for the residuals in the residuals vs fitted plot |
label.pos |
position of the labels in the residuals vs fitted plot |
ext.xlim.f |
factor to extend the x-axis limits for the convex loss and antitonic score function plots |
grid.length.f |
the number of grid points for the convex loss plot is defined as grid.length.f * length(x$residuals) |
ask |
logical; if TRUE, the user is asked before each plot |
... |
additional arguments to ensure compatibility with the generic function plot() |
No return value
model = asm(mpg ~ cyl + hp + disp, data=mtcars) plot(model)
model = asm(mpg ~ cyl + hp + disp, data=mtcars) plot(model)
asm
regression model.Outputs predictions on new test data based on a fitted asm
regression model. Also returns a confidence interval around
the conditional mean (if interval = "confidence") or predicted response (if interval = "prediction").
## S3 method for class 'asm' predict(object, newdata = NULL, interval = "none", level = 0.95, ...)
## S3 method for class 'asm' predict(object, newdata = NULL, interval = "none", level = 0.95, ...)
object |
asm object |
newdata |
new data frame |
interval |
type of interval calculation, either "none", "confidence" or "prediction". Default is "none". |
level |
confidence level |
... |
additional arguments to ensure compatibility with the generic function predict() |
matrix of predicted values * if interval = "none", the matrix has one column of predicted values * if interval = "confidence" or "prediction", the matrix has three columns: predicted value, lower bound, and upper bound
model = asm(mpg ~ cyl + hp + disp, data=mtcars) predict(model, newdata = data.frame(cyl = 4, hp = 121, disp = 80), interval = "prediction") n <- 1000 X <- rnorm(n) beta <- 2 Y <- beta*X + rt(n,df=3) Mod <- asm(Y ~ X) predict(Mod, newdata = data.frame(X = 1), interval = "prediction")
model = asm(mpg ~ cyl + hp + disp, data=mtcars) predict(model, newdata = data.frame(cyl = 4, hp = 121, disp = 80), interval = "prediction") n <- 1000 X <- rnorm(n) beta <- 2 Y <- beta*X + rt(n,df=3) Mod <- asm(Y ~ X) predict(Mod, newdata = data.frame(X = 1), interval = "prediction")
asm
regression modelOutputs estimated coefficients and standard errors
## S3 method for class 'asm' print(x, ...)
## S3 method for class 'asm' print(x, ...)
x |
asm object |
... |
additional arguments to ensure compatibility with the generic function print() |
No return value, called for its side effect
model = asm(mpg ~ cyl + hp + disp, data=mtcars) print(model)
model = asm(mpg ~ cyl + hp + disp, data=mtcars) print(model)
asm
regression modelPrints the summary of a fitted asm
regression model
## S3 method for class 'summary.asm' print( x, digits = max(3L, getOption("digits") - 3L), signif.stars = getOption("show.signif.stars"), concise = FALSE, ... )
## S3 method for class 'summary.asm' print( x, digits = max(3L, getOption("digits") - 3L), signif.stars = getOption("show.signif.stars"), concise = FALSE, ... )
x |
summary.asm object |
digits |
number of digits to print |
signif.stars |
logical; if TRUE, 'significance stars' are printed |
concise |
logical; if TRUE, the output is concise |
... |
additional arguments to ensure compatibility with the generic function print() |
No return value
model = asm(mpg ~ cyl + hp + disp, data=mtcars) print(summary(model))
model = asm(mpg ~ cyl + hp + disp, data=mtcars) print(summary(model))
asm
regression modelOutputs the residuals (on the training data) from a fitted asm
regression
model
## S3 method for class 'asm' residuals(object, ...)
## S3 method for class 'asm' residuals(object, ...)
object |
asm object |
... |
additional arguments to ensure compatibility with the generic function residuals() |
vector of residuals from the asm
regression model
model = asm(mpg ~ cyl + hp + disp, data=mtcars) residuals(model)
model = asm(mpg ~ cyl + hp + disp, data=mtcars) residuals(model)
asm
regression modelOutputs estimated coefficients, standard errors and p-values based on a fitted asm
regression model
## S3 method for class 'asm' summary(object, ...)
## S3 method for class 'asm' summary(object, ...)
object |
asm object |
... |
additional arguments to ensure compatibility with the generic function summary() |
summary.asm
class object containing the following components:
coefficients
:estimated coefficients, standard errors, z-values and p-values
residuals
:residuals of the fitted model
call
:call to the asm
function
model = asm(mpg ~ cyl + hp + disp, data=mtcars) summary(model)
model = asm(mpg ~ cyl + hp + disp, data=mtcars) summary(model)