Skip to content

Commit

Permalink
Add outer weights bootstrap
Browse files Browse the repository at this point in the history
Outer weights bootstrap results added
  • Loading branch information
sergioventurini committed May 29, 2024
1 parent 72a2c28 commit ada9d34
Show file tree
Hide file tree
Showing 8 changed files with 152 additions and 32 deletions.
Binary file modified lplssem.mlib
Binary file not shown.
38 changes: 31 additions & 7 deletions plssem.ado
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
*!plssem version 0.6.0
*!Written 02May2024
*!plssem version 0.6.1
*!Written 29May2024
*!Written by Sergio Venturini and Mehmet Mehmetoglu
*!The following code is distributed under GNU General Public License version 3 (GPL-3)

Expand Down Expand Up @@ -775,8 +775,8 @@ program Estimate, eclass byable(recall) properties(mi)
/* End of labeling the LVs */

/* Compute the model parameter variances */
tempname xload_v path_v
local tempnamelist "`tempnamelist' `xload_v' `path_v'"
tempname xload_v path_v ow_v
local tempnamelist "`tempnamelist' `xload_v' `path_v' `ow_v'"

if ("`boot'" == "") {
mata: `xload_v' = ///
Expand Down Expand Up @@ -820,6 +820,7 @@ program Estimate, eclass byable(recall) properties(mi)
mata: `xload_v' = `res_bs'.xloadings_v
if ("`structural'" != "") {
mata: `path_v' = `res_bs'.path_v
mata: `ow_v' = `res_bs'.ow_v
}
}
/* End of computing the model parameter variances */
Expand Down Expand Up @@ -868,7 +869,7 @@ program Estimate, eclass byable(recall) properties(mi)
matrix colnames `xloadings' = `loadcolnames'

if ("`boot'" != "") {
tempname loadings_bs xloadings_bs
tempname loadings_bs xloadings_bs ow_bs

mata: st_matrix("`loadings_bs'", `res_bs'.loadings_bs)
matrix rownames `loadings_bs' = `loadrownames'
Expand All @@ -877,6 +878,12 @@ program Estimate, eclass byable(recall) properties(mi)
mata: st_matrix("`xloadings_bs'", `res_bs'.xloadings_bs)
matrix rownames `xloadings_bs' = `loadrownames'
matrix colnames `xloadings_bs' = `loadcolnames'

if ("`structural'" != "") {
mata: st_matrix("`ow_bs'", `res_bs'.ow_bs)
matrix rownames `ow_bs' = `loadrownames'
matrix colnames `ow_bs' = `loadcolnames'
}
}

mata: `annihilate_se' = editvalue(st_matrix("`adj_meas'"), 0, .)
Expand All @@ -887,6 +894,14 @@ program Estimate, eclass byable(recall) properties(mi)
mata: st_matrix("`xloadings_se'", sqrt(`xload_v'))
matrix rownames `xloadings_se' = `loadrownames'
matrix colnames `xloadings_se' = `loadcolnames'

if ("`boot'" != "" & "`structural'" != "") {
tempname ow_se

mata: st_matrix("`ow_se'", sqrt(`ow_v') :* `annihilate_se')
matrix rownames `ow_se' = `loadrownames'
matrix colnames `ow_se' = `loadcolnames'
}
/* End of computing the table of measurement loadings */

/* Compute the table of average variance extracted (AVE) */
Expand Down Expand Up @@ -1238,8 +1253,17 @@ program Estimate, eclass byable(recall) properties(mi)
ereturn matrix R = `R_Y'
if ("`rawsum'" == "") {
ereturn matrix reldiff = `matreldiff'
ereturn matrix outerweights = `outerW'
ereturn matrix ow_history = `Whistory'
ereturn matrix outerweights = `outerW'
ereturn matrix ow_history = `Whistory'
if ("`boot'" != "") {
tempname ow_reps
mata: st_matrix("`ow_reps'", `res_bs'.ow_reps)
matrix colnames `ow_reps' = `loadrownames'

ereturn matrix ow_se = `ow_se'
ereturn matrix ow_bs = `ow_bs'
ereturn matrix ow_breps = `ow_reps'
}
}
if (`num_lv_A' > 0) {
ereturn matrix assessment = `mod_assessment'
Expand Down
14 changes: 13 additions & 1 deletion plssem.sthlp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{smcl}
{* *! version 0.6.0 25Apr2024}{...}
{* *! version 0.6.1 29May2024}{...}
{vieweralsosee "plssem postestimation" "help plssem postestimation"}{...}
{vieweralsosee "plssemplot" "help plssemplot"}{...}
{vieweralsosee "plssemc" "help plssemc"}{...}
Expand Down Expand Up @@ -377,15 +377,25 @@ not{p_end}
{synopt:{cmd:e(b)}}coefficient vector{p_end}
{synopt:{cmd:e(V)}}variance-covariance matrix of the estimators{p_end}
{synopt:{cmd:e(loadings)}}outer loadings matrix{p_end}
{synopt:{cmd:e(loadings_breps)}}outer loadings bootstrap replications (available only
if the {cmd:boot()} option is chosen){p_end}
{synopt:{cmd:e(loadings_bs)}}bootstrap-based outer loadings matrix (available only
if the {cmd:boot()} option is chosen){p_end}
{synopt:{cmd:e(loadings_se)}}matrix of the outer loadings standard errors{p_end}
{synopt:{cmd:e(cross_loadings)}}cross loadings matrix{p_end}
{synopt:{cmd:e(cross_loadings_breps)}}cross loadings bootstrap replications (available only
if the {cmd:boot()} option is chosen){p_end}
{synopt:{cmd:e(cross_loadings_bs)}}bootstrap-based cross loadings matrix (available only
if the {cmd:boot()} option is chosen){p_end}
{synopt:{cmd:e(cross_loadings_se)}}matrix of the cross loadings standard errors{p_end}
{synopt:{cmd:e(adj_meas)}}adjacency matrix for the measurement (outer) model{p_end}
{synopt:{cmd:e(outerweights)}}matrix of outer weights{p_end}
{synopt:{cmd:e(ow_breps)}}outer weights bootstrap replications (available only
if the {cmd:boot()} option is chosen){p_end}
{synopt:{cmd:e(ow_bs)}}bootstrap-based outer weights matrix (available only
if the {cmd:boot()} option is chosen){p_end}
{synopt:{cmd:e(ow_se)}}matrix of the outer weights standard errors (available only
if the {cmd:boot()} option is chosen){p_end}
{synopt:{cmd:e(ow_history)}}matrix of outer weights evolution{p_end}
{synopt:{cmd:e(relcoef)}}matrix of reliability coefficients{p_end}
{synopt:{cmd:e(sqcorr)}}matrix of squared correlations among the latent variables{p_end}
Expand All @@ -394,6 +404,8 @@ if the {cmd:boot()} option is chosen){p_end}
{synopt:{cmd:e(struct_se)}}matrix of path coefficients' standard errors (short form){p_end}
{synopt:{cmd:e(struct_table)}}table combining estimation results for the structural (inner) model{p_end}
{synopt:{cmd:e(pathcoef)}}path coefficients matrix (extended form){p_end}
{synopt:{cmd:e(pathcoef_breps)}}path coefficients bootstrap replications (available only
if the {cmd:boot()} option is chosen){p_end}
{synopt:{cmd:e(pathcoef_bs)}}bootstrap-based path coefficients matrix (extended form; available only
if the {cmd:boot()} option is chosen){p_end}
{synopt:{cmd:e(adj_struct)}}adjacency matrix for the structural (inner) model{p_end}
Expand Down
4 changes: 2 additions & 2 deletions plssem_postestimation.sthlp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{smcl}
{* *! version 0.5.3 22Feb2024}{...}
{* *! version 0.5.3 28May2024}{...}
{vieweralsosee "plssem" "help plssem"}{...}
{vieweralsosee "plssemplot" "help plssemplot"}{...}
{viewerjumpto "Postestimation commands" "plssem postestimation##description"}{...}
Expand Down Expand Up @@ -98,7 +98,7 @@ Display the decomposition of the total effects in the corresponding direct and i
Display the mediation analysis using partial least squares structural equation modelling

{p 8 14 2}
{cmd:estat} {cmdab:me:diate}
{cmd:estat} {cmdab:me:diate}{cmd:,}
{cmdab:ind:ep(}{it:varname}{cmd:)} {cmdab:med:(}{it:varname}{cmd:)}
{cmdab:dep:(}{it:varname}{cmd:)} [{opt br:eps(#)} {opt s:eed(#)} {opt zlc:}
{opt rit:} {opt rid:} {opt bc:a} {opt l:evel(#)} {opt dig:its(#)}]
Expand Down
38 changes: 31 additions & 7 deletions plssemc.ado
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
*!plssemc version 0.6.0
*!Written 02May2024
*!plssemc version 0.6.1
*!Written 29May2024
*!Written by Sergio Venturini and Mehmet Mehmetoglu
*!The following code is distributed under GNU General Public License version 3 (GPL-3)

Expand Down Expand Up @@ -775,8 +775,8 @@ program Estimate_c, eclass byable(recall)
/* End of labeling the LVs */

/* Compute the model parameter variances */
tempname xload_v path_v
local tempnamelist "`tempnamelist' `xload_v' `path_v'"
tempname xload_v path_v ow_v
local tempnamelist "`tempnamelist' `xload_v' `path_v' `ow_v'"

if ("`boot'" == "") {
// note: in PLSc variances are available only using bootstrap
Expand Down Expand Up @@ -814,6 +814,7 @@ program Estimate_c, eclass byable(recall)
mata: `xload_v' = `res_bs'.xloadings_v
if ("`structural'" != "") {
mata: `path_v' = `res_bs'.path_v
mata: `ow_v' = `res_bs'.ow_v
}
}
/* End of computing the model parameter variances */
Expand Down Expand Up @@ -862,7 +863,7 @@ program Estimate_c, eclass byable(recall)
matrix colnames `xloadings' = `loadcolnames'

if ("`boot'" != "") {
tempname loadings_bs xloadings_bs
tempname loadings_bs xloadings_bs ow_bs

mata: st_matrix("`loadings_bs'", `res_bs'.loadings_bs)
matrix rownames `loadings_bs' = `loadrownames'
Expand All @@ -871,6 +872,12 @@ program Estimate_c, eclass byable(recall)
mata: st_matrix("`xloadings_bs'", `res_bs'.xloadings_bs)
matrix rownames `xloadings_bs' = `loadrownames'
matrix colnames `xloadings_bs' = `loadcolnames'

if ("`structural'" != "") {
mata: st_matrix("`ow_bs'", `res_bs'.ow_bs)
matrix rownames `ow_bs' = `loadrownames'
matrix colnames `ow_bs' = `loadcolnames'
}
}

mata: `annihilate_se' = editvalue(st_matrix("`adj_meas'"), 0, .)
Expand All @@ -881,6 +888,14 @@ program Estimate_c, eclass byable(recall)
mata: st_matrix("`xloadings_se'", sqrt(`xload_v'))
matrix rownames `xloadings_se' = `loadrownames'
matrix colnames `xloadings_se' = `loadcolnames'

if ("`boot'" != "" & "`structural'" != "") {
tempname ow_se

mata: st_matrix("`ow_se'", sqrt(`ow_v') :* `annihilate_se')
matrix rownames `ow_se' = `loadrownames'
matrix colnames `ow_se' = `loadcolnames'
}
/* End of computing the table of measurement loadings */

/* Compute the table of average variance extracted (AVE) */
Expand Down Expand Up @@ -1219,8 +1234,17 @@ program Estimate_c, eclass byable(recall)
ereturn matrix R = `R_Y'
if ("`rawsum'" == "") {
ereturn matrix reldiff = `matreldiff'
ereturn matrix outerweights = `outerW'
ereturn matrix ow_history = `Whistory'
ereturn matrix outerweights = `outerW'
ereturn matrix ow_history = `Whistory'
if ("`boot'" != "") {
tempname ow_reps
mata: st_matrix("`ow_reps'", `res_bs'.ow_reps)
matrix colnames `ow_reps' = `loadrownames'

ereturn matrix ow_se = `ow_se'
ereturn matrix ow_bs = `ow_bs'
ereturn matrix ow_breps = `ow_reps'
}
}
if (`num_lv_A' > 0) {
ereturn matrix assessment = `mod_assessment'
Expand Down
14 changes: 13 additions & 1 deletion plssemc.sthlp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{smcl}
{* *! version 0.6.0 25Apr2024}{...}
{* *! version 0.6.1 29May2024}{...}
{vieweralsosee "plssemc postestimation" "help plssemc postestimation"}{...}
{vieweralsosee "plssemplot" "help plssemplot"}{...}
{vieweralsosee "plssem" "help plssem"}{...}
Expand Down Expand Up @@ -380,17 +380,27 @@ not{p_end}
{synopt:{cmd:e(b)}}coefficient vector{p_end}
{synopt:{cmd:e(V)}}variance-covariance matrix of the estimators{p_end}
{synopt:{cmd:e(loadings)}}outer loadings matrix{p_end}
{synopt:{cmd:e(loadings_breps)}}outer loadings bootstrap replications (available only
if the {cmd:boot()} option is chosen){p_end}
{synopt:{cmd:e(loadings_bs)}}bootstrap-based outer loadings matrix (available only
if the {cmd:boot()} option is chosen){p_end}
{synopt:{cmd:e(loadings_se)}}matrix of the outer loadings standard errors; this is empty when
used without bootstrap{p_end}
{synopt:{cmd:e(cross_loadings)}}cross loadings matrix{p_end}
{synopt:{cmd:e(cross_loadings_breps)}}cross loadings bootstrap replications (available only
if the {cmd:boot()} option is chosen){p_end}
{synopt:{cmd:e(cross_loadings_bs)}}bootstrap-based cross loadings matrix (available only
if the {cmd:boot()} option is chosen){p_end}
{synopt:{cmd:e(cross_loadings_se)}}matrix of the cross loadings standard errors; this is empty when
used without bootstrap{p_end}
{synopt:{cmd:e(adj_meas)}}adjacency matrix for the measurement (outer) model{p_end}
{synopt:{cmd:e(outerweights)}}matrix of outer weights{p_end}
{synopt:{cmd:e(ow_breps)}}outer weights bootstrap replications (available only
if the {cmd:boot()} option is chosen){p_end}
{synopt:{cmd:e(ow_bs)}}bootstrap-based outer weights matrix (available only
if the {cmd:boot()} option is chosen){p_end}
{synopt:{cmd:e(ow_se)}}matrix of the outer weights standard errors (available only
if the {cmd:boot()} option is chosen){p_end}
{synopt:{cmd:e(ow_history)}}matrix of outer weights evolution{p_end}
{synopt:{cmd:e(relcoef)}}matrix of reliability coefficients{p_end}
{synopt:{cmd:e(sqcorr)}}matrix of squared correlations among the latent variables{p_end}
Expand All @@ -400,6 +410,8 @@ used without bootstrap{p_end}
used without bootstrap{p_end}
{synopt:{cmd:e(struct_table)}}table combining estimation results for the structural (inner) model{p_end}
{synopt:{cmd:e(pathcoef)}}path coefficients matrix (extended form){p_end}
{synopt:{cmd:e(pathcoef_breps)}}path coefficients bootstrap replications (available only
if the {cmd:boot()} option is chosen){p_end}
{synopt:{cmd:e(pathcoef_bs)}}bootstrap-based path coefficients matrix (extended form; available only
if the {cmd:boot()} option is chosen){p_end}
{synopt:{cmd:e(adj_struct)}}adjacency matrix for the structural (inner) model{p_end}
Expand Down
38 changes: 31 additions & 7 deletions plssemcmat.ado
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
*!plssemcmat version 0.6.0
*!Written 02May2024
*!plssemcmat version 0.6.1
*!Written 29May2024
*!Written by Sergio Venturini and Mehmet Mehmetoglu
*!The following code is distributed under GNU General Public License version 3 (GPL-3)

Expand Down Expand Up @@ -638,8 +638,8 @@ program Estimate_c_mat, eclass byable(recall)
/* End of labeling the LVs */

/* Compute the model parameter variances */
tempname xload_v path_v
local tempnamelist "`tempnamelist' `xload_v' `path_v'"
tempname xload_v path_v ow_v
local tempnamelist "`tempnamelist' `xload_v' `path_v' `ow_v'"

if ("`boot'" == "") {
// note: in PLSc variances are available only using bootstrap
Expand Down Expand Up @@ -677,6 +677,7 @@ program Estimate_c_mat, eclass byable(recall)
mata: `xload_v' = `res_bs'.xloadings_v
if ("`structural'" != "") {
mata: `path_v' = `res_bs'.path_v
mata: `ow_v' = `res_bs'.ow_v
}
}
/* End of computing the model parameter variances */
Expand Down Expand Up @@ -725,7 +726,7 @@ program Estimate_c_mat, eclass byable(recall)
matrix colnames `xloadings' = `loadcolnames'

if ("`boot'" != "") {
tempname loadings_bs xloadings_bs
tempname loadings_bs xloadings_bs ow_bs

mata: st_matrix("`loadings_bs'", `res_bs'.loadings_bs)
matrix rownames `loadings_bs' = `loadrownames'
Expand All @@ -734,6 +735,12 @@ program Estimate_c_mat, eclass byable(recall)
mata: st_matrix("`xloadings_bs'", `res_bs'.xloadings_bs)
matrix rownames `xloadings_bs' = `loadrownames'
matrix colnames `xloadings_bs' = `loadcolnames'

if ("`structural'" != "") {
mata: st_matrix("`ow_bs'", `res_bs'.ow_bs)
matrix rownames `ow_bs' = `loadrownames'
matrix colnames `ow_bs' = `loadcolnames'
}
}

mata: `annihilate_se' = editvalue(st_matrix("`adj_meas'"), 0, .)
Expand All @@ -744,6 +751,14 @@ program Estimate_c_mat, eclass byable(recall)
mata: st_matrix("`xloadings_se'", sqrt(`xload_v'))
matrix rownames `xloadings_se' = `loadrownames'
matrix colnames `xloadings_se' = `loadcolnames'

if ("`boot'" != "" & "`structural'" != "") {
tempname ow_se

mata: st_matrix("`ow_se'", sqrt(`ow_v') :* `annihilate_se')
matrix rownames `ow_se' = `loadrownames'
matrix colnames `ow_se' = `loadcolnames'
}
/* End of computing the table of measurement loadings */

/* Compute the table of average variance extracted (AVE) */
Expand Down Expand Up @@ -1081,8 +1096,17 @@ program Estimate_c_mat, eclass byable(recall)
ereturn matrix R = `R_Y'
if ("`rawsum'" == "") {
ereturn matrix reldiff = `matreldiff'
ereturn matrix outerweights = `outerW'
ereturn matrix ow_history = `Whistory'
ereturn matrix outerweights = `outerW'
ereturn matrix ow_history = `Whistory'
if ("`boot'" != "") {
tempname ow_reps
mata: st_matrix("`ow_reps'", `res_bs'.ow_reps)
matrix colnames `ow_reps' = `loadrownames'

ereturn matrix ow_se = `ow_se'
ereturn matrix ow_bs = `ow_bs'
ereturn matrix ow_breps = `ow_reps'
}
}
if (`num_lv_A' > 0) {
ereturn matrix assessment = `mod_assessment'
Expand Down
Loading

0 comments on commit ada9d34

Please sign in to comment.