### Install plspm package Source: https://github.com/gastonstat/plspm/blob/master/README.md Installs the plspm package from GitHub using the devtools library. ```R install.packages("devtools") library(devtools) install_github("gastonstat/plspm") ``` -------------------------------- ### Lightweight PLS-PM Estimation with plspm.fit (R) Source: https://context7.com/gastonstat/plspm/llms.txt The `plspm.fit()` function offers a streamlined PLS-PM estimation, returning only core results without bootstrap validation. This is useful for performance-intensive tasks or when only basic model outputs are required. The setup involves defining the data, path matrix, blocks, and measurement modes, similar to the main `plspm()` function. ```r library(plspm) data(satisfaction) # Define path 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) sat_path = rbind(IMAG, EXPE, QUAL, VAL, SAT, LOY) # Define blocks and modes sat_blocks = list(1:5, 6:10, 11:15, 16:19, 20:23, 24:27) sat_modes = rep("A", 6) # Run lightweight PLS-PM satpls_fit = plspm.fit(satisfaction, sat_path, sat_blocks, modes = sat_modes, scaled = FALSE) # Access basic results satpls_fit$outer_model satpls_fit$inner_model satpls_fit$path_coefs satpls_fit$scores ``` -------------------------------- ### Estimate PLS Path Model with plspm (R) Source: https://context7.com/gastonstat/plspm/llms.txt The main function `plspm()` estimates a PLS path model. It requires data, a path matrix for the inner model, blocks for the outer model, and measurement modes. This example demonstrates setting up these components and running the analysis with bootstrap validation, then accessing various results like path coefficients, inner model summaries, outer model details, and goodness-of-fit indices. ```r library(plspm) data(satisfaction) # Define the inner model (path 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) sat_path = rbind(IMAG, EXPE, QUAL, VAL, SAT, LOY) # Define the outer model blocks sat_blocks = list(1:5, 6:10, 11:15, 16:19, 20:23, 24:27) # Define measurement modes sat_modes = rep("A", 6) # Run PLS-PM analysis with bootstrap validation satpls = plspm(satisfaction, sat_path, sat_blocks, modes = sat_modes, scaled = FALSE, boot.val = TRUE, br = 100) # View model summary satpls # Detailed summary with all results summary(satpls) # Access specific results satpls$path_coefs satpls$inner_model satpls$outer_model satpls$gof satpls$scores ``` -------------------------------- ### Run Global PLS-PM and Group Comparison in R Source: https://context7.com/gastonstat/plspm/llms.txt Demonstrates how to set up and run a global Partial Least Squares Path Model (PLS-PM) using the plspm function. It also shows how to compare groups (e.g., by gender) using permutation tests or bootstrapping with plspm.groups, and how to access the detailed comparison results. ```R sat_path = rbind( 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) ) sat_blocks = list(1:5, 6:10, 11:15, 16:19, 20:23, 24:27) sat_modes = rep("A", 6) satpls = plspm(satisfaction, sat_path, sat_blocks, modes = sat_modes, scaled = FALSE) group_comparison = plspm.groups(satpls, group = satisfaction$gender, method = "permutation", reps = 100) group_comparison group_comparison$test group_comparison$global group_comparison$group1 group_comparison$group2 group_boot = plspm.groups(satpls, group = satisfaction$gender, method = "bootstrap", reps = 100) ``` -------------------------------- ### Perform PLS-PM with metric data Source: https://github.com/gastonstat/plspm/blob/master/README.md Demonstrates a standard PLS-PM workflow using the satisfaction dataset, including path matrix definition, block specification, model execution with bootstrapping, and result visualization. ```R library(plspm) data(satisfaction) 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) sat_path <- rbind(IMAG, EXPE, QUAL, VAL, SAT, LOY) sat_blocks <- list(1:5, 6:10, 11:15, 16:19, 20:23, 24:27) sat_modes <- rep("A", 6) satpls <- plspm(satisfaction, sat_path, sat_blocks, modes = sat_modes, scaled = FALSE, boot.val = TRUE) summary(satpls) plot(satpls, what = "inner") ``` -------------------------------- ### Execute PLS-PM with Missing Data Handling Source: https://github.com/gastonstat/plspm/blob/master/README.md Demonstrates how to introduce missing values into a dataset and perform a PLS-PM analysis. The snippet includes steps to inspect the outer model, inner model, scores, and visualize the inner path model. ```R russNA <- russa russNA[1,1] <- NA russNA[4,4] <- NA russNA[6,6] <- NA rus_pls6 <- plspm(russNA, rus_path, rus_blocks, scaling = rus_scaling, modes = rus_modes, scheme = "centroid", plscomp = c(1,1,1), tol = 0.0000001) rus_pls6 rus_pls6$outer_model rus_pls6$inner_model head(rus_pls6$scores) plot(rus_pls6) ``` -------------------------------- ### Perform PLS-PM Analysis on russb Dataset Source: https://github.com/gastonstat/plspm/blob/master/README.md Executes a PLS-PM model using the 'russb' dataset with specified paths, blocks, scaling, and modes. It outputs the outer model results for structural analysis. ```R rus_pls5 <- plspm(russb, rus_path, rus_blocchi, scaling = rus_scaling3, modes = rus_modes3, scheme = "CENTROID", plscomp = c(1,1,1), tol = 0.0000001) rus_pls5$outer_model ``` -------------------------------- ### Perform PLS-PM with non-metric data Source: https://github.com/gastonstat/plspm/blob/master/README.md Shows how to handle non-metric data using the Russett dataset, including defining custom scaling types (NUM, ORD, NOM) and configuring modes for the PLS-PM algorithm. ```R data(russa) rus_path <- rbind(c(0, 0, 0), c(0, 0, 0), c(1, 1, 0)) rownames(rus_path) <- c("AGRI", "IND", "POLINS") colnames(rus_path) <- c("AGRI", "IND", "POLINS") rus_blocks <- list(1:3, 4:5, 6:9) rus_scaling <- list(c("NUM", "NUM", "NUM"), c("ORD", "ORD"), c("NUM", "NUM", "NUM", "NOM")) rus_modes <- c("A", "A", "A") rus_pls <- plspm(russa, rus_path, rus_blocks, scaling = rus_scaling, modes = rus_modes, scheme = "centroid") rus_pls$outer_model ``` -------------------------------- ### Visualize Non-Metric Variable Quantification with quantiplot Source: https://context7.com/gastonstat/plspm/llms.txt This snippet demonstrates how to run a non-metric PLS-PM using the plspm package and visualize the quantification of specific latent or manifest variables using quantiplot. It covers both name-based and index-based selection for plotting. ```r library(plspm) data(russa) # Define path matrix rus_path = rbind(c(0, 0, 0), c(0, 0, 0), c(1, 1, 0)) rownames(rus_path) = c("AGRI", "IND", "POLINS") colnames(rus_path) = c("AGRI", "IND", "POLINS") # Define blocks and scaling rus_blocks = list(1:3, 4:5, 6:9) rus_scaling = list(c("NUM", "NUM", "NUM"), c("ORD", "ORD"), c("NUM", "NUM", "NUM", "NOM")) rus_modes = c("A", "A", "A") # Run non-metric PLS-PM rus_pls = plspm(russa, rus_path, rus_blocks, scaling = rus_scaling, modes = rus_modes, scheme = "centroid", plscomp = c(1,1,1)) # Plot quantification by latent variable quantiplot(rus_pls, lv = "IND") quantiplot(rus_pls, lv = 2) # Plot quantification by manifest variable quantiplot(rus_pls, mv = "gnpr") quantiplot(rus_pls, mv = 4) ``` -------------------------------- ### PLS-PM with Non-Metric Data in R Source: https://context7.com/gastonstat/plspm/llms.txt Demonstrates how to perform PLS-PM analysis on datasets with ordinal or nominal variables using the non-metric approach in R. It requires specifying scaling types for manifest variables (numeric, ordinal, or nominal) and defines the path matrix, blocks, scaling, and modes for the analysis. ```r library(plspm) data(russa) # Russett dataset with numeric variables # Define path matrix for three latent variables us_path = rbind( c(0, 0, 0), # AGRI c(0, 0, 0), # IND c(1, 1, 0) # POLINS <- AGRI + IND ) rownames(rus_path) = c("AGRI", "IND", "POLINS") colnames(rus_path) = c("AGRI", "IND", "POLINS") # Define blocks (using column indices) us_blocks = list(1:3, 4:5, 6:9) # Define scaling for each manifest variable # AGRI block: 3 numeric variables # IND block: 1 ordinal, 1 ordinal # POLINS block: 1 numeric, 1 numeric, 1 numeric, 1 nominal us_scaling = list( c("NUM", "NUM", "NUM"), # AGRI variables c("ORD", "ORD"), # IND variables c("NUM", "NUM", "NUM", "NOM") # POLINS variables ) # Define modes rus_modes = c("A", "A", "A") # Run non-metric PLS-PM us_pls = plspm(russa, rus_path, rus_blocks, scaling = rus_scaling, modes = rus_modes, scheme = "centroid", plscomp = c(1, 1, 1), # Number of PLS components per block tol = 0.0000001) # View results rus_pls$outer_model rus_pls$inner_model summary(rus_pls) # You can also use variable names instead of indices for blocks us_blocks_named = list( c("gini", "farm", "rent"), c("gnpr", "labo"), c("inst", "ecks", "death", "demo") ) ``` -------------------------------- ### Perform Permutation Test for REBUS Classes Source: https://context7.com/gastonstat/plspm/llms.txt Compares pairs of classes derived from REBUS analysis using permutation tests. It evaluates significant differences in path coefficients, loadings, and GoF indices. ```R perm_test = rebus.test(sim_global, rebus_sim) perm_test$test_1_2$gof perm_test$test_1_2$paths perm_test$test_1_2$loadings ``` -------------------------------- ### Generic Plot Method for plspm Objects in R Source: https://context7.com/gastonstat/plspm/llms.txt The generic plot method for plspm objects provides a unified interface to visualize PLS-PM results by wrapping the innerplot and outerplot functions. It allows plotting the inner model by default, or specifically loadings and weights of the outer model. ```r library(plspm) data(satisfaction) # Run PLS-PM analysis sat_path = rbind( 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) ) sat_blocks = list(1:5, 6:10, 11:15, 16:19, 20:23, 24:27) satpls = plspm(satisfaction, sat_path, sat_blocks, modes = rep("A", 6)) # Plot inner model (default) plot(satpls) plot(satpls, what = "inner") # Plot loadings plot(satpls, what = "loadings") # Plot weights plot(satpls, what = "weights") ``` -------------------------------- ### Iterative REBUS Algorithm Steps in R Source: https://context7.com/gastonstat/plspm/llms.txt Executes the iterative refinement steps of the REBUS algorithm. This function takes a global PLS-PM model and the results of an initial cluster analysis (from res.clus) to iteratively adjust class assignments until convergence is achieved, based on specified criteria. ```R library(plspm) data(simdata) sim_path = matrix(c(0,0,0,0,0,0,1,1,0), 3, 3, byrow = TRUE) dimnames(sim_path) = list( c("Price", "Quality", "Satisfaction"), c("Price", "Quality", "Satisfaction") ) sim_blocks = list(c(1,2,3,4,5), c(6,7,8,9,10), c(11,12,13)) sim_modes = c("A", "A", "A") sim_global = plspm(simdata, sim_path, sim_blocks, modes = sim_modes) sim_clus = res.clus(sim_global) rebus_sim = it.reb(sim_global, sim_clus, nk = 2, stop.crit = 0.005, iter.max = 100) rebus_sim$loadings rebus_sim$path.coefs rebus_sim$quality rebus_sim$segments ``` -------------------------------- ### Assess Unidimensionality of Measurement Models Source: https://context7.com/gastonstat/plspm/llms.txt Provides a comprehensive unidimensionality report for blocks, including Cronbach's alpha, Dillon-Goldstein's rho, and eigenvalue analysis to validate reflective models. ```R library(plspm) data(satisfaction) sat_blocks = list(Image = 1:5, Expectations = 6:10, Quality = 11:15, Value = 16:19, Satisfaction = 20:23, Loyalty = 24:27) unidim_results = unidim(satisfaction, sat_blocks) print(unidim_results) ``` -------------------------------- ### REBUS Algorithm for Latent Class Detection in R Source: https://context7.com/gastonstat/plspm/llms.txt Implements the Response Based Unit Segmentation (REBUS) algorithm to detect latent classes with different local models. This function automatically identifies segments of observations that follow distinct path model patterns. It requires a pre-calculated global PLS-PM model and outputs results including loadings, path coefficients, and quality indices for each class. ```R library(plspm) data(simdata) sim_path = matrix(c(0,0,0,0,0,0,1,1,0), 3, 3, byrow = TRUE) dimnames(sim_path) = list( c("Price", "Quality", "Satisfaction"), c("Price", "Quality", "Satisfaction") ) sim_blocks = list(c(1,2,3,4,5), c(6,7,8,9,10), c(11,12,13)) sim_modes = c("A", "A", "A") sim_global = plspm(simdata, sim_path, sim_blocks, modes = sim_modes) rebus_result = rebus.pls(sim_global, stop.crit = 0.005, iter.max = 100) rebus_result rebus_result$loadings rebus_result$path.coefs rebus_result$quality rebus_result$segments local_models = local.models(sim_global, rebus_result) summary(local_models$loc.model.1) summary(local_models$loc.model.2) ``` -------------------------------- ### Two Groups Comparison in R using plspm.groups Source: https://context7.com/gastonstat/plspm/llms.txt Performs statistical tests to compare path coefficients between two groups in PLS-PM analysis. It utilizes bootstrap or permutation methods to assess the significance of differences in path coefficients across groups. ```r library(plspm) data(satisfaction) # Example usage for comparing two groups would follow here, # assuming a dataset with a grouping variable and appropriate setup. # The function plspm.groups is designed for this purpose. # For instance: # group1_data <- subset(satisfaction, group == 1) # group2_data <- subset(satisfaction, group == 2) # plspm.groups(group1_data, group2_data, ...) ``` -------------------------------- ### Compute Local PLS-PM Models Source: https://context7.com/gastonstat/plspm/llms.txt Calculates full PLS-PM results for global and local segments. It accepts REBUS results or custom grouping variables to generate model summaries for specific classes. ```R library(plspm) data(simdata) sim_path = matrix(c(0,0,0,0,0,0,1,1,0), 3, 3, byrow = TRUE) dimnames(sim_path) = list(c("Price", "Quality", "Satisfaction"), c("Price", "Quality", "Satisfaction")) sim_blocks = list(c(1,2,3,4,5), c(6,7,8,9,10), c(11,12,13)) sim_modes = c("A", "A", "A") sim_global = plspm(simdata, sim_path, sim_blocks, modes = sim_modes) rebus_sim = rebus.pls(sim_global, stop.crit = 0.005, iter.max = 100) local_rebus = local.models(sim_global, rebus_sim) summary(local_rebus$loc.model.1) summary(local_rebus$loc.model.2) ``` -------------------------------- ### Residual Clustering for REBUS in R Source: https://context7.com/gastonstat/plspm/llms.txt Performs hierarchical cluster analysis on communality and structural residuals derived from a global PLS-PM model. This function is a key step in the manual REBUS procedure, aiding in the determination of the appropriate number of latent classes by visualizing a dendrogram. ```R library(plspm) data(simdata) sim_path = matrix(c(0,0,0,0,0,0,1,1,0), 3, 3, byrow = TRUE) dimnames(sim_path) = list( c("Price", "Quality", "Satisfaction"), c("Price", "Quality", "Satisfaction") ) sim_blocks = list(c(1,2,3,4,5), c(6,7,8,9,10), c(11,12,13)) sim_modes = c("A", "A", "A") sim_global = plspm(simdata, sim_path, sim_blocks, modes = sim_modes) sim_clus = res.clus(sim_global) # Examine the dendrogram to choose number of classes (nk) # Based on the dendrogram, choose nk = 2 for this example ``` -------------------------------- ### Plot Inner Model in R using innerplot Source: https://context7.com/gastonstat/plspm/llms.txt Visualizes the structural (inner) model of a PLS-PM analysis, displaying path relationships between latent variables with path coefficients on arrows. The function can accept either a path matrix or a plspm object and allows customization of colors, sizes, and text. ```r library(plspm) data(satisfaction) # Define and plot path matrix before estimation 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) sat_path = rbind(IMAG, EXPE, QUAL, VAL, SAT, LOY) # Plot the theoretical path model (shows structure without coefficients) innerplot(sat_path) # After estimation, plot with path coefficients sat_blocks = list(1:5, 6:10, 11:15, 16:19, 20:23, 24:27) sat_modes = rep("A", 6) satpls = plspm(satisfaction, sat_path, sat_blocks, modes = sat_modes) # Plot inner model with estimated path coefficients # Positive paths shown in blue, negative in red innerplot(satpls) # Customize appearance innerplot(satpls, colpos = "#2E86AB", # Color for positive coefficients colneg = "#E94F37", # Color for negative coefficients box.size = 0.1, # Size of ellipses box.col = "white", # Fill color of boxes txt.col = "black", # Text color arr.width = 0.25, # Arrow width cex.txt = 1.0) # Text size on arrows ``` -------------------------------- ### Plot Outer Model in R using outerplot Source: https://context7.com/gastonstat/plspm/llms.txt Visualizes the measurement (outer) model of a PLS-PM analysis, showing relationships between latent variables and their manifest indicators. It can display either loadings (correlations between manifest variables and latent variables) or weights (used to calculate latent variable scores), with customizable appearance options. ```r library(plspm) data(satisfaction) # Run PLS-PM sat_path = rbind( 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) ) sat_blocks = list(1:5, 6:10, 11:15, 16:19, 20:23, 24:27) sat_modes = rep("A", 6) satpls = plspm(satisfaction, sat_path, sat_blocks, modes = sat_modes) # Plot outer model loadings (correlations between MVs and LVs) outerplot(satpls, what = "loadings") # Plot outer model weights (used to calculate LV scores) outerplot(satpls, what = "weights") # Customize appearance outerplot(satpls, what = "loadings", colpos = "#28a745", colneg = "#dc3545", box.size = 0.06, cex.txt = 0.8) ``` -------------------------------- ### Calculate Cronbach's Alpha Reliability Source: https://context7.com/gastonstat/plspm/llms.txt Computes the Cronbach's alpha coefficient for manifest variable blocks to assess internal consistency. Values above 0.7 are generally considered acceptable. ```R library(plspm) data(satisfaction) Image_block = satisfaction[, 1:5] alpha(Image_block) ``` -------------------------------- ### Calculate Dillon-Goldstein's Rho Source: https://context7.com/gastonstat/plspm/llms.txt Computes composite reliability for manifest variable blocks. This metric is often preferred over Cronbach's alpha in PLS-PM as it incorporates factor loadings. ```R library(plspm) data(satisfaction) Image_block = satisfaction[, 1:5] rho(Image_block) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.