Skip to contents

Auxiliary function that control fitting of unit quantile regression models using unitquantreg.

Usage

unitquantreg.control(
  method = "BFGS",
  hessian = FALSE,
  gradient = TRUE,
  maxit = 5000,
  factr = 1e+07,
  reltol = sqrt(.Machine$double.eps),
  trace = 0L,
  starttests = FALSE,
  dowarn = FALSE,
  ...
)

Arguments

method

string. Specify the method argument passed to optimx.

hessian

logical. Should use the numerically Hessian matrix to compute variance-covariance? Default is FALSE, i.e., use the analytic Hessian.

gradient

logical. Should use the analytic gradient? Default is TRUE.

maxit

integer. Specify the maximal number of iterations passed to optimx.

factr

numeric.Controls the convergence of the "L-BFGS-B" method.

reltol

numeric. Relative convergence tolerance passed to optimx.

trace

non-negative integer. If positive, tracing information on the progress of the optimization is produced.

starttests

logical. Should optimx run tests of the functions and parameters? Default is FALSE.

dowarn

logical. Show warnings generated by optimx? Default is FALSE.

...

arguments passed to optimx.

Value

A list with components named as the arguments.

Details

The control argument of unitquantreg uses the arguments of unitquantreg.control. In particular, the parameters in unitquantreg are estimated by maximum likelihood using the optimx, which is a general-purpose optimization wrapper function that calls other R tools for optimization, including the existing optim function. The main advantage of optimx is to unify the tools allowing a number of different optimization methods and provide sanity checks.

References

Nash, J. C. and Varadhan, R. (2011). Unifying Optimization Algorithms to Aid Software System Users: optimx for R., Journal of Statistical Software, 43(9), 1--14.

See also

optimx for more details about control parameters and unitquantreg.fit the fitting procedure used by unitquantreg.

Author

André F. B. Menezes

Examples

data(sim_bounded, package = "unitquantreg")
sim_bounded_curr <- sim_bounded[sim_bounded$family == "uweibull", ]

# Fitting using the analytical gradient
fit_gradient <- unitquantreg(formula = y1 ~ x,
                             data = sim_bounded_curr, tau = 0.5,
                             family = "uweibull",
                             control = unitquantreg.control(gradient = TRUE,
                                                            trace = 1))
#> fn is  fn1 
#> Looking for method =  BFGS 
#> Method:  BFGS 
#> initial  value -113.361578 
#> final  value -140.614828 
#> converged
#> Post processing for method  BFGS 
#> Successful convergence! 
#> Compute Hessian approximation at finish of  BFGS 
#> Compute gradient approximation at finish of  BFGS 
#> Save results from method  BFGS 
#> $par
#> (Intercept)           x (Intercept) 
#>   0.9971136   1.9125274   2.0537425 
#> 
#> $value
#> [1] -140.6148
#> 
#> $message
#> NULL
#> 
#> $convcode
#> [1] 0
#> 
#> $fevals
#> function 
#>       29 
#> 
#> $gevals
#> gradient 
#>        9 
#> 
#> $nitns
#> [1] NA
#> 
#> $kkt1
#> [1] TRUE
#> 
#> $kkt2
#> [1] TRUE
#> 
#> $xtimes
#> user.self 
#>     0.003 
#> 
#> Assemble the answers

# Fitting without using the analytical gradient
fit_nogradient <- unitquantreg(formula = y1 ~ x,
                             data = sim_bounded_curr, tau = 0.5,
                             family = "uweibull",
                             control = unitquantreg.control(gradient = FALSE,
                                                            trace = 1))
#> fn is  fn1 
#> Looking for method =  BFGS 
#> Method:  BFGS 
#> initial  value -113.361578 
#> final  value -140.614828 
#> converged
#> Post processing for method  BFGS 
#> Successful convergence! 
#> Compute Hessian approximation at finish of  BFGS 
#> Compute gradient approximation at finish of  BFGS 
#> Save results from method  BFGS 
#> $par
#> (Intercept)           x (Intercept) 
#>   0.9971127   1.9125284   2.0537431 
#> 
#> $value
#> [1] -140.6148
#> 
#> $message
#> NULL
#> 
#> $convcode
#> [1] 0
#> 
#> $fevals
#> function 
#>       29 
#> 
#> $gevals
#> gradient 
#>        9 
#> 
#> $nitns
#> [1] NA
#> 
#> $kkt1
#> [1] TRUE
#> 
#> $kkt2
#> [1] TRUE
#> 
#> $xtimes
#> user.self 
#>     0.004 
#> 
#> Assemble the answers
# Compare estimated coefficients
cbind(gradient = coef(fit_gradient), no_gradient = coef(fit_nogradient))
#>              gradient no_gradient
#> (Intercept) 0.9971136   0.9971127
#> x           1.9125274   1.9125284
#> theta       2.0537425   2.0537431