
Estimates a weight matrix using Partial Least Squares or a related algorithm.
weightFun.factor
calculates weights by estimating a common factor analysis model with a single factor for each
indicator block and using the resulting estimates to calculate factor score weights
weightFun.principal
calculates weights by calculating a principal component analysis for each
indicator block and returning the weights for the first principal component.
weightFun.pls(
S,
model,
W.model,
outerEstim = NULL,
innerEstim = innerEstim.path,
...,
convCheck = convCheck.absolute,
variant = "lohmoller",
tol = 1e-05,
iter = 100,
validateInput = TRUE
)weightFun.optim(
S,
model,
W.model,
parameterEstim = parameterEstim.separate,
optimCrit = optimCrit.maximizeInnerR2,
method = "BFGS",
...,
validateInput = TRUE,
standardize = TRUE
)
weightFun.fixed(S, model, W.model = NULL, ..., standardize = TRUE)
weightFun.factor(
S,
model,
W.model = NULL,
...,
fm = "minres",
standardize = TRUE
)
weightFun.principal(S, model, W.model = NULL, ..., standardize = TRUE)
Covariance matrix of the data.
There are two options for this argument: 1. lavaan script or lavaan parameter
table, or 2. a list containing three matrices
inner
, reflective
, and formative
defining the free regression paths
in the model.
A matrix specifying the weight relationships and their starting values.
A function or a list of functions used for outer estimation. If
the value of this parameter is a function, the same function is applied to all
composites. If the value is a list, the composite n
is estimated
with the estimator in the n
th position in the list. If this argument is
NULL
the outerEstim.modeA
is used for all composites that are linked to at least
one indicator in the reflective
matrix.outerEstim.modeB
is used for all other
composites. See outerEstim
.
A function for calculating inner weights using the data covariance matrix
S
, a weight matrix W
, and an inner model matrix inner.mod
. Returns
an inner weight matrix E
. The default is innerEstim.path
.
All other arguments are passed through to other estimation functions.
A function that takes the old Wold
and new weight Wold
matrices and
returns a scalar that is compared against tol
to check for convergence. The default
is convCheck.absolute
.
Choose either Lohm<U+00F6>ller's ("lohmoller"
, default) or Wold's ("wold"
)
variant of PLS. In Wold's variant the inner and outer estimation steps are repeated for each
indicator block whereas in Lohm<U+00F6>ller's variant the weights for all composites are calculated
simultaneously.
Decimal value indicating the tolerance criterion for convergence.
An integer indicating the maximum number of iterations.
A boolean indicating whether the validity of the parameter values should be tested.
A function for estimating the model parameters using
the data covariance matrix S
, model specification model
,
and weight matrix W
. Returns a named vector of parameter estimates.
The default is parameterEstim.separate
A function for calculating value for an optimization criterion based on a
matrixpls
result object. Returns a scalar. The default is optimCrit.maximizeInnerR2
.
The minimization algorithm to be used. See optim
for details. Default is "BFGS"
.
A boolean indicating whether S
the weights should be scaled to produce
standardized composites.
factoring method for estimating the common factor model. Possible values are
minres
, wls
, gls
, pa
, and ml
. The parameter is passed through to
to fa
.
An object of class "matrixplsweights"
, which is a matrix containing the weights with the following attributes:
Number of iterations performed
A boolean indicating if the algorithm converged
A data.frame containing the weights for each iteration
weightFun.pls returns the following as attributes:
the sample covariance matrix.
inner weight matrix.
the number of iterations used by the weight algorithm.
TRUE
if the weight algorithm converged and FALSE
otherwise.
weight optimization history as a matrix.
weightFun.pls
: partial Least Squares and other iterative two-stage weight algorithms.
weightFun.optim
: calculates a set of weights to minimize an optimization criterion.
weightFun.fixed
: returns the starting weights.
weightFun.factor
: blockwise factor score weights.
weightFun.principal
: blockwise principal component weights.
Model can be specified in the lavaan format or the native matrixpls format.
The native model format is a list of three binary matrices, inner
, reflective
,
and formative
specifying the free parameters of a model: inner
(l x l
) specifies the
regressions between composites, reflective
(k x l
) specifies the regressions of observed
data on composites, and formative
(l x k
) specifies the regressions of composites on the
observed data. Here k
is the number of observed variables and l
is the number of composites.
If the model is specified in lavaan format, the native
format model is derived from this model by assigning all regressions between latent
variables to inner
, all factor loadings to reflective
, and all regressions
of latent variables on observed variables to formative
. Regressions between
observed variables and all free covariances are ignored. All parameters that are
specified in the model will be treated as free parameters.
The original papers about Partial Least Squares, as well as many of the current PLS
implementations, impose restrictions on the matrices inner
,
reflective
, and formative
: inner
must be a lower triangular matrix,
reflective
must have exactly one non-zero value on each row and must have at least
one non-zero value on each column, and formative
must only contain zeros.
Some PLS implementations allow formative
to contain non-zero values, but impose a
restriction that the sum of reflective
and t(formative)
must satisfy
the original restrictions of reflective
. The only restrictions that matrixpls
imposes on inner
, reflective
, and formative
is that these must be
binary matrices and that the diagonal of inner
must be zeros.
The argument W.model
is a (l x k
) matrix that indicates
how the indicators are combined to form the composites. The original papers about
Partial Least Squares as well as all current PLS implementations define this as
t(reflective) | formative
, which means that the weight patter must match the
model specified in reflective
and formative
. Matrixpls does not
require that W.model
needs to match reflective
and formative
, but
accepts any numeric matrix. If this argument is not specified, all elements of W.model
that
correspond to non-zero elements in the reflective
or formative
formative
matrices receive the value 1.
weightFun.pls
calculates indicator weights by calling the
innerEstim
and outerEstim
iteratively until either the convergence criterion or
maximum number of iterations is reached and provides the results in a matrix.
weightFun.optim
calculates indicator weights by optimizing the indicator
weights against the criterion function using optim
. The
algorithm works by first estimating the model with the starting weights. The
resulting matrixpls
object is passed to the optimCrit
function, which evaluates the optimization criterion for the weights. The
weights are adjusted and new estimates are calculated until the optimization
criterion converges.
Rosseel, Y. (2012). lavaan: An R Package for Structural Equation Modeling. Journal of Statistical Software, 48(2), 1<U+2013>36. Retrieved from http://www.jstatsoft.org/v48/i02
# NOT RUN {
# Run the customer satisfaction examle form plspm
# load dataset satisfaction
data(satisfaction)
# inner model matrix
IMAG = c(0,0,0,0,0,0)
EXPE = c(1,0,0,0,0,0)
QUAL = c(0,1,0,0,0,0)
VAL = c(0,1,1,0,0,0)
SAT = c(1,1,1,1,0,0)
LOY = c(1,0,0,0,1,0)
inner = rbind(IMAG, EXPE, QUAL, VAL, SAT, LOY)
colnames(inner) <- rownames(inner)
# Reflective model
list(1:5, 6:10, 11:15, 16:19, 20:23, 24:27)
reflective<- matrix(
c(1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1),
27,6, dimnames = list(colnames(satisfaction)[1:27],colnames(inner)))
# empty formative model
formative <- matrix(0, 6, 27, dimnames = list(colnames(inner), colnames(satisfaction)[1:27]))
# Estimation using covariance matrix
model <- list(inner = inner,
reflective = reflective,
formative = formative)
S <- cov(satisfaction[,1:27])
matrixpls.ModeA <- matrixpls(S, model)
matrixpls.ModeB <- matrixpls(S, model, outerEstim = outerEstim.modeB)
matrixpls.MaxR2 <- matrixpls(S, model, weightFun = weightFun.optim)
# Compare the R2s from the different estimations
R2s <- cbind(r2(matrixpls.ModeA), r2(matrixpls.ModeB), r2(matrixpls.MaxR2))
print(R2s)
apply(R2s,2,mean)
# Optimization against custom function
maximizeSumOfCorrelations <- function(matrixpls.res){
C <- attr(matrixpls.res,"C")
model <- attr(matrixpls.res,"model")
- sum(C[model$inner != 0])
}
matrixpls.MaxCor <- matrixpls(S, model, weightFun = weightFun.optim,
optimCrit = maximizeSumOfCorrelations)
# Compare the Mode B and optimized solutions
C <- attr(matrixpls.ModeB,"C")
print(C)
print(sum(C[inner != 0]))
C <- attr(matrixpls.MaxCor,"C")
print(C)
print(sum(C[inner != 0]))
# }
Run the code above in your browser using DataLab