From 3f8ef66054dcc07f6f41ef5b1729182cd328518a Mon Sep 17 00:00:00 2001 From: Nicholas Date: Sat, 5 Aug 2017 19:07:13 +0800 Subject: [PATCH] Removed semPLS dependancy Added a mobi dataset Added data.R to document dataset changed all files to call internal dataset Aadded mobi.md document for dataset Addresses Issue #21 --- DESCRIPTION | 2 +- R/bootstrap.R | 2 +- R/consistent.R | 2 +- R/consistent_interaction.R | 2 +- R/data.R | 38 ++++ R/interactions.R | 286 +++++++++++++++---------------- R/model.R | 2 +- R/reliability.R | 2 +- R/reporting.R | 2 +- R/simplePLS.R | 2 +- data/mobi.rda | Bin 0 -> 2684 bytes demo/seminr-contained.R | 80 ++++----- demo/seminr-ecsi.R | 2 +- demo/seminr-interaction.R | 162 ++++++++--------- man/PLSc.Rd | 100 +++++------ man/PLSc_interact.Rd | 2 +- man/bootstrap_model.Rd | 122 ++++++------- man/estimate_pls.Rd | 2 +- man/interaction_ortho.Rd | 66 +++---- man/interaction_scaled.Rd | 64 +++---- man/interactions.Rd | 82 ++++----- man/mobi.Rd | 52 ++++++ man/print_paths.Rd | 108 ++++++------ man/rhoA.Rd | 98 +++++------ man/simplePLS.Rd | 136 +++++++-------- tests/testthat/test-bootstrap.R | 4 +- tests/testthat/test-consistent.R | 6 +- tests/testthat/test-output.r | 4 +- vignettes/SEMinR.Rmd | 30 ++-- 29 files changed, 775 insertions(+), 685 deletions(-) create mode 100644 R/data.R create mode 100644 data/mobi.rda create mode 100644 man/mobi.Rd diff --git a/DESCRIPTION b/DESCRIPTION index 6ed3c479..6bcf72b9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -12,7 +12,7 @@ Description: SEMinR offers an easy to write and easy to change syntax for specifying `plsm` models that are compatible with `semPLS`, `sem`, and possibly other packages supporting structural equation models. Imports: - semPLS, parallel + parallel License: GPL-3 LazyData: TRUE RoxygenNote: 5.0.1 diff --git a/R/bootstrap.R b/R/bootstrap.R index ff4bb126..03a7c0f7 100644 --- a/R/bootstrap.R +++ b/R/bootstrap.R @@ -18,7 +18,7 @@ #' @seealso \code{\link{relationships}} \code{\link{constructs}} \code{\link{paths}} \code{\link{interactions}} #' #' @examples -#' data("mobi", package = "semPLS") +#' mobi <- mobi #' #' # seminr syntax for creating measurement model #' mobi_mm <- constructs( diff --git a/R/consistent.R b/R/consistent.R index 0d022077..850d4aa6 100644 --- a/R/consistent.R +++ b/R/consistent.R @@ -13,7 +13,7 @@ #' \code{\link{bootstrap_model}} #' #' @examples -#' data("mobi", package = "semPLS") +#' mobi <- mobi #' #' #seminr syntax for creating measurement model #' mobi_mm <- constructs( diff --git a/R/consistent_interaction.R b/R/consistent_interaction.R index 98debcc8..dbed611b 100644 --- a/R/consistent_interaction.R +++ b/R/consistent_interaction.R @@ -15,7 +15,7 @@ #' \code{\link{bootstrap_model}} #' #' @examples -#' data("mobi", package = "semPLS") +#' mobi <- mobi #' #' #seminr syntax for creating measurement model #' mobi_mm <- constructs( diff --git a/R/data.R b/R/data.R new file mode 100644 index 00000000..41d0cfe2 --- /dev/null +++ b/R/data.R @@ -0,0 +1,38 @@ +#' Measurement Instrument for the Mobile Phone Industry +#' +#' The data set is used as measurement instrument for the european customer satisfaction +#' index (ECSI) adapted to the mobile phone market, see Tenenhaus et al. (2005). +#' +#' @format A data frame with 250 rows and 24 variables: +#' \describe{ +#' \item{CUEX1}{Expectations for the overall quality of “your mobile phone provider” at the moment you became customer of this provider} +#' \item{CUEX2}{Expectations for “your mobile phone provider” to provide products and services to meet your personal need} +#' \item{CUEX3}{How often did you expect that things could go wrong at “your mobile phone provider} +#' \item{CUSA1}{Overall satisfaction} +#' \item{CUSA2}{Fulfillment of expectations} +#' \item{CUSA3}{How well do you think “your mobile phone provider” compares with your ideal mobile phone provider?} +#' \item{CUSCO}{You complained about “your mobile phone provider” last year. How well, or poorly, was your most recent complaint handled or You did not complain about “your mobile phone provider” last year. Imagine you have to complain to “your mobile phone rovider” because of a bad quality of service or product. To what extent do you think that “your mobile phone provider” will care about your complaint?} +#' \item{CUSL1}{If you would need to choose a new mobile phone provider how likely is it that you would choose “your provider” again?} +#' \item{CUSL2}{Let us now suppose that other mobile phone providers decide to lower their fees and prices, but “your mobile phone provider” stays at the same level as today. At which level of difference (in percentage) would you choose another mobile phone provider?} +#' \item{CUSL3}{If a friend or colleague asks you for advice, how likely is it that you would recommend “your mobile phone provider”?} +#' \item{IMAG1}{It can be trusted what it says and does} +#' \item{IMAG2}{It is stable and firmly established} +#' \item{IMAG3}{It has a social contribution to society} +#' \item{IMAG4}{It is concerned with customers} +#' \item{IMAG5}{It is innovative and forward looking} +#' \item{PERQ1}{Overall perceived quality} +#' \item{PERQ2}{Technical quality of the network} +#' \item{PERQ3}{Customer service and personal advice offered} +#' \item{PERQ4}{Quality of the services you use} +#' \item{PERQ5}{Range of services and products offered} +#' \item{PERQ6}{Reliability and accuracy of the products and services provided} +#' \item{PERQ7}{Clarity and transparency of information provided} +#' \item{PERV1}{Given the quality of the products and services offered by “your mobile phone provider” how would you rate the fees and prices that you pay for them?} +#' \item{PERV2}{Given the fees and prices that you pay for “your mobile phone provider” how would you rate the quality of the products and services offered by “your mobile phone provider”?} +#' } +#' +#' @details The data frame mobi contains the observed data for the model specified by ECSImobi. +#' @references Tenenhaus, M., V. E. Vinzi, Y.-M. Chatelin, and C. Lauro (2005) PLS path modeling. Computational Statistics & Data Analysis 48, 159-205. +#' @examples data("mobi") +#' +"mobi" diff --git a/R/interactions.R b/R/interactions.R index 9fa18a5f..6dbcd2e2 100644 --- a/R/interactions.R +++ b/R/interactions.R @@ -1,143 +1,143 @@ -#' Interaction Functions -#' -#' \code{interactions} creates interaction measurement items by multipying all combination of factor items. -#' -#' This function automatically generates interaction measurement items for a PLS SEM. -#' -#' @param ... Interaction Combinations as generated by the \code{interaction_scaled} or -#' \code{interaction_ortho} methods. -#' -#' @usage -#' # Create two new interactions (factor1.factor2 and factor1.factor3) using -#' -#' # (1) standardized product indicator approach as per Henseler & Chin (2010): -#' interactions( interaction_scaled("factor1", "factor2"), -#' interaction_scaled("factor1", "factor3")) -#' -#' # (2) orthogonalization approach as per Henseler & CHin (2010): -#' interactions( interaction_ortho("factor1", "factor2"), -#' interaction_ortho("factor1", "factor3")) -#' -#' @examples -#' data("mobi", package = "semPLS") -#' -#' mobi_xm <- interactions( -#' interaction_ortho("Image", "Expectation"), -#' interaction_ortho("Image", "Value") -#' ) -#' -#' mobi_pls <- estimate_pls(mobi, mobi_mm, mobi_xm, mobi_sm) -#' print_paths(mobi_pls) -#' -#' @aliases interaction_ortho, interaction_scaled -#' -#' @export -interactions <- function(...) { - function(data, mm, all_intxns=list(...)) { - create_interaction <- function(intxn_function) { intxn_function(data, mm) } - intxns_list <- lapply(all_intxns, create_interaction) - return(intxns_list) - } -} - -#' \code{interaction_ortho} creates interaction measurement items by multipying all combination of factor items. -#' -#' This function automatically generates interaction measurement items for a PLS SEM. -#' -#' @param ... Interaction Combinations as generated by the \code{interaction_ortho} method. -#' -#' @usage -#' # Create two new interactions (factor1.factor2 and factor1.factor3) using -#' -#' # orthogonalization approach as per Henseler & CHin (2010): -#' interactions( interaction_ortho("factor1", "factor2"), -#' interaction_ortho("factor1", "factor3")) -#' -#' @examples -#' data("mobi", package = "semPLS") -#' -#' mobi_xm <- interactions( -#' interaction_ortho("Image", "Expectation"), -#' interaction_ortho("Image", "Value") -#' ) -#' -#' mobi_pls <- estimate_pls(mobi, mobi_mm, mobi_xm, mobi_sm) -#' print_paths(mobi_pls) -#' -#' @aliases interaction_ortho, interaction_scaled -#' -#' @export -interaction_ortho <- function(factor1, factor2) { - function(data, mm) { - interaction_name <- paste(factor1, factor2, sep=".") - iv1_items <- mm[mm[, "latent"] == factor1, ][, "measurement"] - iv2_items <- mm[mm[, "latent"] == factor2, ][, "measurement"] - - iv1_data <- as.data.frame(scale(data[iv1_items])) - iv2_data <- as.data.frame(scale(data[iv2_items])) - - mult <- function(col) { - iv2_data*col - } - - multiples_list <- lapply(iv1_data, mult) - interaction_data <- do.call("cbind", multiples_list) - - # Create formula - frmla <- as.formula(paste("interaction_data[,i]",paste(as.vector(c(iv1_items,iv2_items)), collapse ="+"), sep = " ~ ")) - - # iterate and orthogonalize - for(i in 1:ncol(interaction_data)) { - interaction_data[,i] <- lm(formula = frmla, data = data)$residuals - } - return(list(name = interaction_name, data = interaction_data)) - } -} - -#' \code{interaction_scaled} creates interaction measurement items by multipying all combination of factor items. -#' -#' This function automatically generates interaction measurement items for a PLS SEM. -#' -#' @param ... Interaction Combinations as generated by the \code{interaction_scaled} method. -#' -#' @usage -#' # Create two new interactions (factor1.factor2 and factor1.factor3) using -#' -#' # standardized product indicator approach as per Henseler & Chin (2010): -#' interactions( interaction_scaled("factor1", "factor2"), -#' interaction_scaled("factor1", "factor3")) -#' -#' @examples -#' data("mobi", package = "semPLS") -#' -#' mobi_xm <- interactions( -#' interaction_scaled("Image", "Expectation"), -#' interaction_scaled("Image", "Value") -#' ) -#' -#' mobi_pls <- estimate_pls(mobi, mobi_mm, mobi_xm, mobi_sm) -#' print_paths(mobi_pls) -#' -#' @aliases interaction_ortho, interaction_scaled -#' -#' @export -interaction_scaled <- function(factor1, factor2) { - function(data, mm) { - interaction_name <- paste(factor1, factor2, sep=".") - iv1_items <- mm[mm[, "latent"] == factor1, ][, "measurement"] - iv2_items <- mm[mm[, "latent"] == factor2, ][, "measurement"] - - iv1_data <- as.data.frame(scale(data[iv1_items])) - iv2_data <- as.data.frame(scale(data[iv2_items])) - - mult <- function(col) { - iv2_data*col - } - - multiples_list <- lapply(iv1_data, mult) - interaction_data <- do.call("cbind", multiples_list) - - return(list(name = interaction_name, data = interaction_data)) - } -} - +#' Interaction Functions +#' +#' \code{interactions} creates interaction measurement items by multipying all combination of factor items. +#' +#' This function automatically generates interaction measurement items for a PLS SEM. +#' +#' @param ... Interaction Combinations as generated by the \code{interaction_scaled} or +#' \code{interaction_ortho} methods. +#' +#' @usage +#' # Create two new interactions (factor1.factor2 and factor1.factor3) using +#' +#' # (1) standardized product indicator approach as per Henseler & Chin (2010): +#' interactions( interaction_scaled("factor1", "factor2"), +#' interaction_scaled("factor1", "factor3")) +#' +#' # (2) orthogonalization approach as per Henseler & CHin (2010): +#' interactions( interaction_ortho("factor1", "factor2"), +#' interaction_ortho("factor1", "factor3")) +#' +#' @examples +#' mobi <- mobi +#' +#' mobi_xm <- interactions( +#' interaction_ortho("Image", "Expectation"), +#' interaction_ortho("Image", "Value") +#' ) +#' +#' mobi_pls <- estimate_pls(mobi, mobi_mm, mobi_xm, mobi_sm) +#' print_paths(mobi_pls) +#' +#' @aliases interaction_ortho, interaction_scaled +#' +#' @export +interactions <- function(...) { + function(data, mm, all_intxns=list(...)) { + create_interaction <- function(intxn_function) { intxn_function(data, mm) } + intxns_list <- lapply(all_intxns, create_interaction) + return(intxns_list) + } +} + +#' \code{interaction_ortho} creates interaction measurement items by multipying all combination of factor items. +#' +#' This function automatically generates interaction measurement items for a PLS SEM. +#' +#' @param ... Interaction Combinations as generated by the \code{interaction_ortho} method. +#' +#' @usage +#' # Create two new interactions (factor1.factor2 and factor1.factor3) using +#' +#' # orthogonalization approach as per Henseler & CHin (2010): +#' interactions( interaction_ortho("factor1", "factor2"), +#' interaction_ortho("factor1", "factor3")) +#' +#' @examples +#' mobi <- mobi +#' +#' mobi_xm <- interactions( +#' interaction_ortho("Image", "Expectation"), +#' interaction_ortho("Image", "Value") +#' ) +#' +#' mobi_pls <- estimate_pls(mobi, mobi_mm, mobi_xm, mobi_sm) +#' print_paths(mobi_pls) +#' +#' @aliases interaction_ortho, interaction_scaled +#' +#' @export +interaction_ortho <- function(factor1, factor2) { + function(data, mm) { + interaction_name <- paste(factor1, factor2, sep=".") + iv1_items <- mm[mm[, "latent"] == factor1, ][, "measurement"] + iv2_items <- mm[mm[, "latent"] == factor2, ][, "measurement"] + + iv1_data <- as.data.frame(scale(data[iv1_items])) + iv2_data <- as.data.frame(scale(data[iv2_items])) + + mult <- function(col) { + iv2_data*col + } + + multiples_list <- lapply(iv1_data, mult) + interaction_data <- do.call("cbind", multiples_list) + + # Create formula + frmla <- as.formula(paste("interaction_data[,i]",paste(as.vector(c(iv1_items,iv2_items)), collapse ="+"), sep = " ~ ")) + + # iterate and orthogonalize + for(i in 1:ncol(interaction_data)) { + interaction_data[,i] <- lm(formula = frmla, data = data)$residuals + } + return(list(name = interaction_name, data = interaction_data)) + } +} + +#' \code{interaction_scaled} creates interaction measurement items by multipying all combination of factor items. +#' +#' This function automatically generates interaction measurement items for a PLS SEM. +#' +#' @param ... Interaction Combinations as generated by the \code{interaction_scaled} method. +#' +#' @usage +#' # Create two new interactions (factor1.factor2 and factor1.factor3) using +#' +#' # standardized product indicator approach as per Henseler & Chin (2010): +#' interactions( interaction_scaled("factor1", "factor2"), +#' interaction_scaled("factor1", "factor3")) +#' +#' @examples +#' mobi <- mobi +#' +#' mobi_xm <- interactions( +#' interaction_scaled("Image", "Expectation"), +#' interaction_scaled("Image", "Value") +#' ) +#' +#' mobi_pls <- estimate_pls(mobi, mobi_mm, mobi_xm, mobi_sm) +#' print_paths(mobi_pls) +#' +#' @aliases interaction_ortho, interaction_scaled +#' +#' @export +interaction_scaled <- function(factor1, factor2) { + function(data, mm) { + interaction_name <- paste(factor1, factor2, sep=".") + iv1_items <- mm[mm[, "latent"] == factor1, ][, "measurement"] + iv2_items <- mm[mm[, "latent"] == factor2, ][, "measurement"] + + iv1_data <- as.data.frame(scale(data[iv1_items])) + iv2_data <- as.data.frame(scale(data[iv2_items])) + + mult <- function(col) { + iv2_data*col + } + + multiples_list <- lapply(iv1_data, mult) + interaction_data <- do.call("cbind", multiples_list) + + return(list(name = interaction_name, data = interaction_data)) + } +} + diff --git a/R/model.R b/R/model.R index 7f5a3972..1ba08c8a 100644 --- a/R/model.R +++ b/R/model.R @@ -22,7 +22,7 @@ #' \code{\link{bootstrap_model}} #' #' @examples -#' data("mobi", package = "semPLS") +#' mobi <- mobi #' #' #seminr syntax for creating measurement model #' mobi_mm <- constructs( diff --git a/R/reliability.R b/R/reliability.R index 8d9204ca..a8f71ed8 100644 --- a/R/reliability.R +++ b/R/reliability.R @@ -12,7 +12,7 @@ #' \code{\link{bootstrap_model}} #' #' @examples -#' data("mobi", package = "semPLS") +#' mobi <- mobi #' #' #seminr syntax for creating measurement model #' mobi_mm <- constructs( diff --git a/R/reporting.R b/R/reporting.R index 05944c7c..6769233e 100644 --- a/R/reporting.R +++ b/R/reporting.R @@ -27,7 +27,7 @@ #' plot_scores(fitted_model, factors=NULL) #' #' @examples -#' data("mobi", package = "semPLS") +#' mobi <- mobi #' mobi_pls <- estimate_pls(data = mobi, #' measurement_model = mobi_mm, #' structural_model = mobi_sm) diff --git a/R/simplePLS.R b/R/simplePLS.R index e2d77d4d..72afa271 100644 --- a/R/simplePLS.R +++ b/R/simplePLS.R @@ -23,7 +23,7 @@ #' \code{\link{estimate_pls}} \code{\link{bootstrap_model}} #' #' @examples -#' data("mobi", package = "semPLS") +#' mobi <- mobi #' #' #seminr syntax for creating measurement model #' mobi_mm <- constructs( diff --git a/data/mobi.rda b/data/mobi.rda new file mode 100644 index 0000000000000000000000000000000000000000..93fd06aa318ed78207ccc37f764533934dc1b5d7 GIT binary patch literal 2684 zcmV-?3WN1RT4*^jL0KkKS+7oSH2^RI|G@w9NI(DqKY%W#`#?V@oPa<801@C1msL_g zrBEu06i`W2pa1{`01^NI_yYg{001-^0MHEp)juXEDxd%W0000300000G#UWV4FJ^r z2#HdoOo5Y3fB*mhFaQ7m13{n-0MH1enMCz8^#Pz{&@|IP*+6DfU8?Ofn|zhvCbQHc zp}}uU43ZaMxY>~puR^s%!UTY#H(u{CYq{Opun$JP>K)1B-YR%H?Q?6oFIvpJlXq3( z9rsI>Rgu`=9Cyx$?`CIT{#67EI=%TmyYFu|b-|Qu8LEnYgEqshwn*Z5Hdb<6J~8&p z%mztihj#MjE!w@U9?rxxYx5j~&|HcQE@B6~?cQa(F=3aZS&n7agzusa7@*#rSo5b- zd48LmnH7phUkLKGP@_^x%Z$ zI4^FqvTHS}*BB>gZxGa4VnuRn-z|q?kSSxABCxQ%eA?~BD2~5Is$qzi*Vr7>u1@S^ zwYt}T4hmRI^$3AFAZ&`sCH3V;UgZxTVqTd&FKqhDTb_fKuRM@jkC>SA)t9Br#+d@o zRpRChdb;uXcf6|ODYLrNb0v4;Ywp+H#PLy1Wh5JDV)Rh2yH@8Kg90Un)RO58lSPnw zP_W!Y?R7Q=>iC6iedh{^u8#?bzg;TPk0>KQ4+=p(5qx{kC(}esPIa!q{tqE->a(04 z8?>Y6Ijw9Zz7fPA<`{8@cZxBmSX#<5QF(@Grp{`kBvUgWs9AfitoobGPs%r~(Bh58YS{9YiMQY{oQ9A~AA7BH=S=`RtTi`cRH zfv+vOm$7M4aYY6}iY#i^!sC$%f@#5s9==$kvDJZ8CN__qQLIr+D|0NPmwy&u*-?Dg zCFvGyKLrw>1lI3cc)c7wH@(ItV@$#D7I(2wO0N;ticr1ox+`;TnR2l*YKmHzHH$mh zCKY6>ckw!$^Q<^gI-q!1=MARVtaa3rmE|W#AY5E~*OqV`I2lslKrf5Yqr2Bj9~)vM zI-4U)3@dkXEZmaKiq!MBo;oY7%_oR?=DEpf^nKW6zdOs>$Zn_glOmfoblpOslb&oa zbV3ADipxB;%YztCBo!HhT-I2M=_gK0p0Q>}*}ZJQQKm*fd@_UDvWdP)aopxX@OoqLun6VTfHp5W~2f$qAf!YVIg8nhjvFTQGpOsG~tmp)3*F z77*P72{k6BEKzxb6pt#KRrH?UdyUoxi`}!F^P~x4i4n0CF*cCf(s%0h&bIq${97qe3rMG;hfW)@P_v9k>f_?6oN9CNNkJR@lXeDuxO%|jKo za4Ei!nK0JUBDvA&yUHPrEqr2_@UI-k$16>zN`Y-^)FqZ&*P?S_3{JLg(h(`Dz#okb zJ-h8tmFX4>Np>k~L~K_vOg-uD>{=d?*Ds?$>~xbc#TzSTT;P~MvK5#hOGmrj!}BWh zQO?TllkWEU10n0HI7A(I8c#Q(S(G81ykX7Z6s9eFey_@+Cetmxu)Sf-+%<&y9kq?shS1kc@ z##XgsoVerxDT1+~YRfre&8{eN$c7WFX0ef#ja(9DS&o@yma_^q2^QIS7cbV#H=>bz zJx+~3HiaW}y(L*OGnsv@mD$Od;Bq|2b|I+ak9O8VW;mGBYS%;!G34iC6xkbk+R?Co z3n1(qTSc5< z2%2f+lak1S;Y_*0)Y5gknYTrNGStQ z%7mOP%bNL_bxttK(1N$dPd&P)HAxLK0FK7)y;mY+%A~AE*yZB}$0j)lGRi)@na1zL zQ|`rV)~b(;i_KVYNN?ETvffzPk)a%H?Sw&OgBx+M7?nFV2Tqy{SK1wkJnD)HQS(g(|gpbld_Bi+>%|uSc z7PLz}aZ%hVsz)Vr=aH9G1PD9Uu^F*43urisO<|~UULg@1v?b?}{98HwmU>YjsUIGOeosR6n*G$Y-Vt`-| zC631Dn^55*gcVIma&l`~0jEwq6A&hoA(ld1n8eu$o@r2!h9H96IcT^N>7okfW_8b> z)nxL~j=L|3i_$GaBel9W!{^xZd)O>(Xv7<~=wsI7*;R5dO(^z`=D4uh*+4)hIw=8@ z2cxqwO2)7~y}P=t?d+dqo7mguV?YKr&!%nC)9UIgVq<-W&f~~1UFE9QwZs)`w9MC5 zHdvlVP*yoP*s zLYVbO%X^4+qsZEe9XABjk05>9bTvqQ+{H{o^iLg> zfDo-mYL}jZtybDI9=r&iO5&{;kQrt~Mr_ zkDDf4iR!s!s9Hpk8t@s6~b=>`G9*KX6Xbi7`GJqTdh2GuE0&{F>H+FTj`6UY155e%|d(Kz2UG~ zHMv2IUi$M^GM(>a39-xJ=0?>2lTTAnB^Rx zEF!L05fWToIQpe2YO1QGDQ3?(&U5V1im=~ML{~f@Fe3`6u?nLQpr{$4WDo+jKp@os zD4~Q301L7OL|Y&ha9f2ueKq^sQk118PIH_@Lu>Gns7q}^=Cqnoxi(aWHPdn%%Rwf4 qOu8__^LE@UuLo}H^g3sc7X}wywks^x ```{r, echo = FALSE, message = FALSE} knitr::opts_chunk$set(collapse = T, comment = "#>") library(seminr) -data("mobi", package = "semPLS") +mobi <- mobi ``` There are now many packages available for R to build, estimate and make predictions @@ -59,7 +59,7 @@ This document introduces you to SEMinR's basic set of tools, and shows you how t To explore the basic syntax of SEMinR, we'll start with the data bundled with the semPLS package - `mobi` data frame. The data set is used as measurement instrument for the european customer satisfaction index (ECSI) adapted to the mobile phone market, see Tenenhaus et al. (2005). ```{r} -data("mobi", package = "semPLS") +mobi <- mobi dim(mobi) head(mobi) ``` @@ -71,7 +71,7 @@ PLS SEM estimation and prediction packages generally take a source - target type SEMinR verbs for measurement model description: * `multi_items()` (or `single_items()`) -* `reflective()` (or `causal()`) +* `reflective()` (or `composite()`) * `constructs()` These verbs are highly intuitive and provide for human-readable code that allows a practitioner to understand a measurement model on first glance and easily make changes to compare different measurement models. @@ -95,9 +95,9 @@ c("IMAG1", "IMAG2", "IMAG3", "IMAG4", "IMAG5") `multi_items()` is used in conjunction with `reflective()` or `causal()` to describe a factor. -### Describe a factor with `causal()` or `reflective()` +### Describe a factor with `composite()` or `reflective()` -`causal()` and `reflective()` provide a verb to describe a factor in one simple line of human-readable code. +`composite()` and `reflective()` provide a verb to describe a factor in one simple line of human-readable code. For example, we can describe the reflective factor "Image" with manifest variables IMAG1, IMAG2, IMAG3, IMAG4 and IMAG5: @@ -108,7 +108,7 @@ reflective("Image", multi_items("IMAG", 1:5)) or ```{r, eval=FALSE} -causal("Image", multi_items("IMAG", 1:5)) +composite("Image", multi_items("IMAG", 1:5), weights = "B") ``` This is equivalent to the more verbose code in base R: @@ -125,7 +125,7 @@ c("IMAG1", "Image", "IMAG2", "Image", "IMAG3", "Image", "IMAG4", "Image", "IMAG5 for formative factors. -`multi_items()` is used in conjunction with `reflective()` or `causal()` to describe a factor. +`multi_items()` is used in conjunction with `reflective()` or `composite()` to describe a factor. `constructs()` is used in conjunction with multiple factor descriptions to describe the entire measurement model. ### Create measurement model matrix with `constructs()` @@ -140,9 +140,9 @@ mobi_mm <- constructs( reflective("Expectation", multi_items("CUEX", 1:3)), reflective("Quality", multi_items("PERQ", 1:7)), reflective("Value", multi_items("PERV", 1:2)), - causal("Satisfaction", multi_items("CUSA", 1:3)), - causal("Complaints", single_item("CUSCO")), - causal("Loyalty", multi_items("CUSL", 1:3)) + composite("Satisfaction", multi_items("CUSA", 1:3), weights = "B"), + composite("Complaints", single_item("CUSCO"), weights = "B"), + composite("Loyalty", multi_items("CUSL", 1:3), weights = "B") ) ``` @@ -325,13 +325,13 @@ The output of this code is: mobi_xm ``` -As previously mentioned, this method returns a function which is not resolved until passed to `estimate_model()` or `bootstrap_model()`. +As previously mentioned, this method returns a function which is not resolved until passed to `estimate_pls()` or `bootstrap_model()`. -## PLS SEM Model Estimation with `estimate_model()` +## PLS SEM Model Estimation with `estimate_pls()` SEMinR verbs for PLS SEM model estimation: -* `estimate_model()` +* `estimate_pls()` This verb is used to estimate the PLS model using the simplePLS function. It takes as parameters the structural model described by `relationships()`, the measurement model described by `constructs()` and an optional interactions function as described by `interactions()`. @@ -360,7 +360,7 @@ mobi_sm <- relationships( from = c("Image", "Expectation", "Value", "Image.Expectation", "Image.Value")) ) -mobi_pls <- estimate_model(data = mobi, +mobi_pls <- estimate_pls(data = mobi, measurement_model = mobi_mm, interactions = mobi_xm, structural_model = mobi_sm) @@ -407,7 +407,7 @@ mobi_sm <- relationships( from = c("Image", "Expectation", "Value", "Image.Expectation", "Image.Value")) ) -mobi_pls <- estimate_model(data = mobi, +mobi_pls <- estimate_pls(data = mobi, measurement_model = mobi_mm, interactions = mobi_xm, structural_model = mobi_sm)