empiricalBayesLM(
data,
removedCovariates,
retainedCovariates = NULL,
weights = NULL,
weightType = c("apriori", "empirical"),
stopOnSmallWeights = TRUE,
tol = 1e-4, maxIterations = 1000,
scaleMeanToSamples = NULL,
robustPriors = FALSE,
automaticWeights = c("none", "bicov"),
aw.maxPOutliers = 0.1)
NULL
if there are no such "retained" covariates.data
giving weights for each
entry in data
."apriori"
or "empirical"
. Determines whether a standard
("apriori"
) or a modified ("empirical"
) weighted regression is used. The "apriori"
choice is
suitable"apriori"
weights trigger an error? Because standard weighted regression
assumes that all weights are non-zero (otherwise estimates of standard errors will be biased), this function
will by default complain a"none"
or "bicov"
, instructing the function to calculate
weights from the given data
. Value "none"
will result in trivial weights; value "bicov"
will result automaticWeights
above is "bicov"
, this argument gets passed to the function
bicovWeights
and determines the maximum proportion of outliers in calculating the weights. See
data
, giving the adjusted data. If
input data
has non-NULL dimnames
, these are copied.data
, giving the residuals,
that is, adjusted data with zero means.data
.data
scaled
to mean 0 and variance 1.data
.data
scaled
to mean 0 and variance 1.data
, giving the data adjusted by
ordinary least squares. This component should only be used for diagnostic purposes, not as input for further
downstream analyses, as the OLS adjustment is inferior to EB adjustment.data
, giving the residuals obtained
from ordinary least squares regression, that is, OLS-adjusted data with zero means.data
.data
scaled to mean 0 and variance 1. These coefficients are used to calculate priors for the EB step.data
.data
scaled
to mean 0 and variance 1. These are used to calculate variance priors for the EB step.data
.data
, indicating whether the
column was adjusted. Columns with zero variance or too many missing data cannot be adjusted.data
, indicating
whether the
column had zero variance.data
), indicating whether the corresponding regression coefficient is valid. Invalid
regression coefficients may be returned as missing values or as zeroes.data
due to the
variables in removedCovariates
while retaining variation due to variables in retainedCovariates
,
if any are given. The EB step uses simple normal priors on the regression coefficients and inverse gamma
priors on the
variances. The procedure starts with multivariate ordinary linear regression of individual columns in
data
on retainedCovariates
and removedCovariates
. To make the coefficients comparable,
columns of data
are scaled to (weighted if weights are given) mean 0 and variance 1.
The resulting regression coefficients are used to
determine the parameters of the normal prior (mean, covariance, and inverse gamma or median and biweight
mid-covariance if robust priors are used), and the variances are used to determine the parameters of the
inverse gamma prior. The EB step then essentially shrinks the coefficients toward their means, with the amount
of shrinkage determined by the prior covariance.Using appropriate weights can make the data adjustment robust to outliers. This can be achieved automatically
by using the argument automaticWeights = "bicov"
. When bicov weights are used, we also recommend
setting the argument maxPOutliers
to a maximum proportion of samples that could be outliers. This is
especially important if some of the design variables are binary and can be expected to have a strong effect on
some of the columns in data
, since standard biweight midcorrelation (and its weights) do not work well
on bimodal data.
The automatic bicov weights are determined from data
only. It is implicitly assumed that there are no
outliers in the retained and removed covariates. Outliers in the covariates are more difficult to work with
since, even if the regression is made robust to them, they can influence the adjusted values for the sample in
which they appear. Unless the the covariate outliers can be attributed to a relevant vriation in experimental
conditions, samples with covariate outliers are best removed entirely before calling this function.
bicovWeights
for suitable weights that make the adjustment robust to outliers.