Workhorse function behind wals
and walsGLM
.
walsFit(
X1,
X2,
y,
sigma = NULL,
prior = weibull(),
method = "original",
svdTol = .Machine$double.eps,
svdRtol = 1e-06,
keepUn = FALSE,
eigenSVD = TRUE,
prescale = TRUE,
postmult = FALSE,
...
)
A list containing
Model averaged estimates of all coefficients.
Model averaged estimates of the coefficients of the focus regressors.
Model averaged estimates of the coefficients of the auxiliary regressors.
Model averaged estimates of the coefficients of the transformed focus regressors.
Model averaged estimates of the coefficients of the transformed auxiliary regressors.
Estimated covariance matrix of the regression coefficients.
Estimated covariance matrix of the coefficients of the transformed regressors.
Estimated or prespecified standard deviation of the error term.
familyPrior
. The prior
specified in the arguments.
Stores method
used from the arguments.
If keepUn = TRUE
, contains the unrestricted
estimators of the coefficients of the focus regressors.
If keepUn = TRUE
, contains the unrestricted
estimators of the coefficients of the auxiliary regressors.
If keepUn = TRUE
, contains the unrestricted
estimators of the coefficients of the transformed focus regressors.
If keepUn = TRUE
, contains the unrestricted
estimators of the coefficients of the transformed auxiliary regressors.
Estimated conditional means of the data.
Residuals, i.e. response - fitted mean.
Names of the focus regressors.
Names of the auxiliary regressors.
Number of focus regressors.
Number of auxiliary regressors.
Number of observations.
Condition number of the matrix \(\Xi = \Delta_{2} X_{2}^{\top} M_{1} X_{2} \Delta_{2}\).
Design matrix for focus regressors. Usually includes a constant
(column full of 1s) and can be generated using model.matrix
.
Design matrix for auxiliary regressors. Usually does not include
a constant column and can also be generated using model.matrix
.
Response as vector.
if NULL (default), then the variance of the error term is estimated, see p.136 of magnus2016wals;textualWALS. If sigma is specified, then the unrestricted estimator is divided by sigma before performing the Bayesian posterior mean estimation.
Object of class "familyPrior"
. For example
weibull
or laplace
.
Specifies method used. Available methods are
"original"
(default) or "svd"
.
Tolerance for rank of matrix \(\bar{Z}_{1}\)
Only used if method = "svd"
.
Checks if smallest eigenvalue in SVD of \(\bar{Z}_1\) and \(\bar{Z}\)
is larger than svdTol
, otherwise reports a rank deficiency.
Relative tolerance for rank of matrix \(\bar{Z}_{1}\).
Only used if method = "svd"
. Checks if ratio of largest to smallest
eigenvalue in SVD of \(\bar{Z}_1\) is larger than svdRtol
,
otherwise reports a rank deficiency.
If TRUE
, keeps the estimators of the unrestricted model,
i.e. \(\tilde{\gamma}_{u}\).
If TRUE
, then semiorthogonalize
uses svd
to compute the eigendecomposition of
\(\bar{\Xi}\) instead of eigen
. In this case, the
tolerances of svdTol
and svdRtol
are used to
determine whether \(\bar{\Xi}\) is of full rank (need it for \(\bar{\Xi}^{-1/2}\)).
If TRUE
(default), prescales the regressors X1 and X2 with
\(\Delta_1\) and \(\Delta_2\), respectively, to improve numerical stability
and make the coefficients of the auxiliary regressors scale equivariant.
See deluca2011stata;textualWALS for more details.
WARNING: It is not recommended to set prescale = FALSE
.
The option prescale = FALSE
only exists for historical reasons.
If TRUE
, then it computes
$$Z_{2} = X_{2} \Delta_{2} T \Lambda^{-1/2} T^{\top},$$
where \(T\) contains the eigenvectors and \(\Lambda\) the eigenvalues
from the eigenvalue decomposition
$$\Xi = \Delta_2 X_{2}^{\top} M_{1} X_{2} \Delta_2 = T \Lambda T^{\top},$$
instead of
$$Z_{2} = X_{2} \Delta_{2} T \Lambda^{-1/2}.$$
See huynhwals;textualWALS for more details. The latter is used
in the original MATLAB code for WALS in the linear regression model
magnus2010growth,deluca2011stata,kumar2013normallocation,magnus2016walsWALS,
see eq. (12) of magnus2016wals;textualWALS.
The first form is required in eq. (9) of deluca2018glm;textualWALS.
It is not recommended to set postmult = FALSE
when using walsGLM
and walsNB
.
Arguments for internal function computePosterior
.
wals, walsGLM.
X <- model.matrix(gdpgrowth ~ lgdp60 + equipinv + school60 + life60 + popgrowth
+ law + tropics + avelf + confucian, data = GrowthMPP)
X1 <- X[, c("(Intercept)", "lgdp60", "equipinv", "school60", "life60", "popgrowth")]
X2 <- X[, c("law", "tropics", "avelf", "confucian")]
y <- GrowthMPP$gdpgrowth
walsFit(X1, X2, y, prior = weibull(), method = "svd")
Run the code above in your browser using DataLab