BYlogreg.RdComputation of the estimator of Bianco and Yohai (1996) in logistic regression. Now provides both the weighted and regular (unweighted) BY-estimator.
By default, an intercept term is included and p parameters are estimated. For more details, see the reference.
Note: This function is for “back-compatibility” with the
BYlogreg() code web-published at KU Leuven, Belgium,
and also available as file FunctionsRob/BYlogreg.ssc from
https://www.wiley.com/legacy/wileychi/robust_statistics/robust.html.
However instead of using this function, the recommended interface is
glmrob(*, method = "BY") or ... method = "WBY" ..,
see glmrob.
BYlogreg(x0, y, initwml = TRUE, addIntercept = TRUE,
const = 0.5, kmax = 1000, maxhalf = 10, sigma.min = 1e-4,
trace.lev = 0)a numeric \(n \times (p-1)\) matrix containing the explanatory variables.
numeric \(n\)-vector of binomial (0 - 1) responses.
logical for selecting one of the two possible methods for computing the initial value of the optimization process.
If initwml is true (default), a weighted ML estimator is
computed with weights derived from the MCD estimator
computed on the explanatory variables.
If initwml is false, a classical ML fit is perfomed. When
the explanatory variables contain binary observations, it is
recommended to set initwml to FALSE or to modify the code of the
algorithm to compute the weights only on the continuous variables.
logical indicating that a column of 1 must be
added the \(x\) matrix.
tuning constant used in the computation of the estimator (default=0.5).
maximum number of iterations before convergence (default=1000).
max number of step-halving (default=10).
smallest value of the scale parameter before implosion (and hence non-convergence) is assumed.
logical (or integer) indicating if intermediate results
should be printed; defaults to 0 (the same as FALSE).
a list with components
logical indicating if convergence was achieved
the value of the objective function at the minimum
vector of parameter estimates
variance-covariance matrix of the coefficients (if convergence is TRUE).
standard errors, i.e., simply sqrt(diag(.$vcov)), if convergence.
Croux, C., and Haesbroeck, G. (2003) Implementing the Bianco and Yohai estimator for Logistic Regression, Computational Statistics and Data Analysis 44, 273–295.
Ana M. Bianco and Víctor J. Yohai (1996) Robust estimation in the logistic regression model. In Helmut Rieder, Robust Statistics, Data Analysis, and Computer Intensive Methods, Lecture Notes in Statistics 109, pages 17–34.
set.seed(17)
x0 <- matrix(rnorm(100,1))
y <- rbinom(100, size=1, prob= 0.5) # ~= as.numeric(runif(100) > 0.5)
BY <- BYlogreg(x0,y)
#> Convergence Achieved
BY <- BYlogreg(x0,y, trace.lev=TRUE)
#> k= 1, s1= 2.2297175: => new s1= 2.04225
#> k= 2, s1= 2.04225: => new s1= 2.1166645
#> k= 3, s1= 2.1166645: => new s1= 2.1166605
#> Convergence Achieved
## The "Vaso Constriction" aka "skin" data:
data(vaso)
vX <- model.matrix( ~ log(Volume) + log(Rate), data=vaso)
vY <- vaso[,"Y"]
head(cbind(vX, vY))# 'X' does include the intercept
#> (Intercept) log(Volume) log(Rate) vY
#> 1 1 1.3083328 -0.1923719 1
#> 2 1 1.2527630 0.0861777 1
#> 3 1 0.2231436 0.9162907 1
#> 4 1 -0.2876821 0.4054651 1
#> 5 1 -0.2231436 1.1631508 1
#> 6 1 -0.3566749 1.2527630 1
vWBY <- BYlogreg(x0 = vX, y = vY, addIntercept=FALSE) # as 'vX' has it already
#> Convergence Achieved
v.BY <- BYlogreg(x0 = vX, y = vY, addIntercept=FALSE, initwml=FALSE)
#> Convergence Achieved
## they are relatively close, well used to be closer than now,
## with the (2023-05, VT) change of covMcd() scale-correction
stopifnot( all.equal(vWBY, v.BY, tolerance = 0.008) ) # was ~ 1e-4 till 2023-05