Learn R Programming

simest (version 0.4)

sim.est:

Description

This function provides an estimate of the non-parametric function and the index vector by minimizing an objective function specified by the method argument.

Usage

sim.est(x, y, w = NULL, beta.init = NULL, nmulti = NULL, L = NULL,
                    lambda = NULL, maxit = 100, bin.tol = 1e-05, beta.tol = 1e-05,
                    method = c("cvx.pen","cvx.lip","cvx.lse","smooth.pen"), 
                    progress = TRUE, force = FALSE)
# S3 method for default
sim.est(x, y, w = NULL, beta.init = NULL, nmulti = NULL, L = NULL,
                    lambda = NULL, maxit = 100, bin.tol = 1e-05, beta.tol = 1e-05,
                    method = c("cvx.pen","cvx.lip","cvx.lse","smooth.pen"), 
                    progress = TRUE, force = FALSE)
# S3 method for sim.est
plot(x,...)
# S3 method for sim.est
print(x,...)
# S3 method for sim.est
predict(object, newdata = NULL, deriv = 0, ...)

Arguments

x
a numeric matrix giving the values of the predictor variables or covariates. For functions plot and print, `x' is an object of class `sim.est'.
y
a numeric vector giving the values of the response variable.
method
a string indicating which method to use for regression.
lambda
a numeric value giving the penalty value for cvx.pen and cvx.lip.
L
a numeric value giving the Lipschitz bound for cvx.lip.
w
an optional numeric vector of the same length as \(x\); Defaults to all 1.
beta.init
An numeric vector giving the initial value for the index vector.
nmulti
An integer giving the number of multiple starts to be used for iterative algorithm. If beta.init is provided then the nmulti is set to 1.
bin.tol
A tolerance level upto which the x values used in regression are recognized as distinct values.
beta.tol
A tolerance level for stopping iterative algorithm for the index vector.
maxit
An integer specifying the maximum number of iterations for each initial \(\beta\) vector.
progress
A logical denoting if progress of the algorithm is to be printed. Defaults to TRUE.
force
A logical indicating the use of cvx.lse.reg or cvx.lse.con.reg. Defaults to FALSE and uses cvx.lse.con.reg
object
An object of class `sim.est'.
...
Any additional arguments to be passed.
newdata
a matrix of new data points in the predict function.
deriv
a numeric either 0 or 1 representing which derivative to evaluate.

Value

An object of class `sim.est', basically a list including the elements
beta
A numeric vector storing the estimate of the index vector.
nmulti
Number of multistarts used.
x.mat
the input `x' matrix with possibly aggregated rows.
BetaInit
a matrix storing the initial vectors taken or given for the index parameter.
lambda
Given input lambda.
L
Given input L.
K
an integer storing the row index of BetaInit which lead to the estimator beta.
BetaPath
a list containing the paths taken by each initial index vector for nmulti times.
ObjValPath
a matrix with nmulti rows storing the path of objective function value for multiple starts.
convergence
a numeric storing convergence status for the index parameter.
itervec
a vector of length nmulti storing the number of iterations taken by each of the multiple starts.
iter
a numeric giving the total number of iterations taken.
method
method given as input.
regress
An output of the regression function used needed for predict.
x.values
sorted `x.betahat' values obtained by the algorithm.
y.values
corresponding `y' values in input.
fit.values
corresponding fit values of same length as that of \(x\beta\).
deriv
corresponding values of the derivative of same length as that of \(x\beta\).
residuals
residuals obtained from the fit.
minvalue
minimum value of the objective function attained.

Details

The function minimizes $$\sum_{i=1}^n w_i(y_i - f(x_i^{\top}\beta))^2 + \lambda\int\{f''(x)\}^2dx$$ with constraints on \(f\) dictated by method = `cvx.pen' or `smooth.pen'. For method = `cvx.lip' or `cvx.lse', the function minimizes $$\sum_{i=1}^n w_i(y_i - f(x_i^{\top}\beta))^2$$ with constraints on \(f\) disctated by method = `cvx.lip' or `cvx.lse'. The penalty parameter \(\lambda\) is not choosen by any criteria. It has to be specified for using method \(=\) `cvx.pen', `cvx.lip' or `smooth.pen' and \(\lambda\) denotes the Lipschitz constant for using the method \(=\) `cvx.lip.reg'. plot function provides the scatterplot along with fitted curve; it also includes some diagnostic plots for residuals and progression of the algorithm. Predict function now allows calculation of the first derivative. In applications, it might be advantageous to scale of the covariate matrix x before passing into the function which brings more stability to the algorithm.

Examples

Run this code
args(sim.est)
x <- matrix(runif(50*3,-1,1),ncol = 3)
b0 <- rep_len(1,3)/sqrt(3)
y <- (x%*%b0)^2 + rnorm(50,0,0.3)
tmp1 <- sim.est(x, y, lambda = 0.01, method = "cvx.pen", nmulti = 5)
<!-- %tmp2 <- sim.est(x, y, L = 10, method = "cvx.lip", nmulti = 5) -->
tmp3 <- sim.est(x, y, lambda = 0.01, method = "smooth.pen", nmulti = 5)
<!-- %tmp4 <- sim.est(x, y, method = "cvx.lse", nmulti = 5) -->
print(tmp1)
<!-- %print(tmp2) -->
print(tmp3)
<!-- %print(tmp4) -->
plot(tmp1)
<!-- %plot(tmp2) -->
plot(tmp3)
<!-- %plot(tmp4) -->
predict(tmp1, newdata = c(0,0,0))
<!-- %predict(tmp2, newdata = c(0,0,0)) -->
predict(tmp3, newdata = c(0,0,0))
<!-- %predict(tmp4, newdata = c(0,0,0)) -->

Run the code above in your browser using DataLab