# Robust Standardized Beta Coefficients

Standardized beta coefficients are definded as

beta = b * sd_x/sd_y

where b are the coefficients from OLS linear regression, and sd_x and sd_y are standard deviations of each x variable and of y.

In the case where you performe a robust linear regression, sd_x and sd_y seems not be very meanigfull anymore, because variances and hence standard deviations are not robust. The R package “robust” provides the function covRob() to compute a robust covariance estimator.

I have written the following function to compute standardized beta coefficients for a robust linear regression. Setting the parameter classic=TRUE gives you the classic estimation of the beta coefficients. For very bad data, the covRob() function cannot compute the covariance due singularities. In this case the classical estimator is returned.

```my.lmr.beta <- function (object, classic = FALSE) {
if(class(object) != "lmRob")
stop("Object must be of class 'lmRob'")
model <- object\$model
num <- sapply(model, is.numeric)  # numeric vars only
b <- object\$coefficients[num][-1]  # final coefficients w/o intercept
## compute robust covariance
covr <- NULL
try(covr <- diag(covRob(model[num])\$cov), silent = TRUE)
if(is.null(covr) & classic == FALSE)
warning("covRob() coud not be computed, instead covClassic() was applied.")
## compute classic covariance if robust failed
if(is.null(covr) | classic == TRUE)
covr <- diag(covClassic(model[num])\$cov)
sx <- sqrt(covr[-1])  # standard deviation of x's
sy <- sqrt(covr[1])  # standard deviation of y
beta <- b * sx/sy
return(beta)
}```

UPDATE — 2014-07-23

Computing standard deviations for factors makes sense, because variance is definded for the binomial distribution.  So I have removed the num variable.

```my.lmr.beta <- function (object, classic = FALSE) {
if(class(object) != "lmRob")
stop("Object must be of class 'lmRob'")
model <- object\$model
#num <- sapply(model, is.numeric)  # numeric vars only
b <- object\$coefficients[-1]  # final coefficients w/o intercept
## compute robust covariance
covr <- NULL
try(covr <- diag(covRob(model)\$cov), silent = TRUE)
if(is.null(covr) & classic == FALSE)
warning("covRob() coud not be computed, instead covClassic() was applied.")
## compute classic covariance if robust failed
if(is.null(covr) | classic == TRUE)
covr <- diag(covClassic(sapply(model, as.numeric))\$cov)
sx <- sqrt(covr[-1])  # standard deviation of x's
sy <- sqrt(covr[1])  # standard deviation of y
beta <- b * sx/sy
return(beta)
}```