-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
1ec6e7d
commit 3f8ef66
Showing
29 changed files
with
775 additions
and
685 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)) | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Oops, something went wrong.