SEMinR Lecture Series - Analyzing Categorical Predictors

SEMinR Lecture Series
This session is focused on how to perform moderation analysis using SEMinR in Cran R.
Categorical Predictor Variables using SEMinR in R
- The objective is to assess whether Country has an impact on Customer Loyalty.
- Country is a categorical variable in the study with three countries China, Pakistan, and Italy.
- Country is not added into the model directly. Since, it is a categorical variable, first the variable is dummy coded. Each Country will become a separate variable.
- In this case Two categories (Countries) will be added in the model estimation. Whereas the third country will serve as a reference category.
Create Dummy Variables in R
- Dummy variables are created when the exogenous variable is categorical in nature.
- Each category is transformed into a dummy variable.
- To create dummy variables in R, install fastDummies package
Video Tutorial
Complete Code
library(seminr)
library(fastDummies)
# Load the Data
datas <- read.csv(file = "Data.csv", header = TRUE, sep = ",")
# Create dummy variables
datas <- dummy_cols(datas, select_columns = "Country")
head(datas)
# Create measurement model
simple_mm <- constructs(
composite("Loyalty", multi_items("CL", 1:6)),
composite("Pakistan", single_item("Country_2")),
composite("Italy", single_item("Country_3")))
# Create structural model
simple_sm <- relationships(
paths(from = c("Pakistan", "Italy"), to = "Loyalty"))
# Estimate the model
simple_model <- estimate_pls(data = datas,
measurement_model = simple_mm,
structural_model = simple_sm,
missing = mean_replacement,
missing_value = "-99")
# Summarize the model results
summary_simple <- summary(simple_model)
summary_simple
# Bootstrap the model on the PLS Estimated Model
boot_model <- bootstrap_model(
seminr_model = simple_model,
nboot = 5000,
cores = parallel::detectCores(),
seed = 123)
# Store the summary of the bootstrapped model
# alpha sets the specified level for significance, i.e. 0.05
# Inspect the bootstrapped structural paths
summary_boot$bootstrapped_paths
Reference
Hair Jr, J. F., Hult, G. T. M., Ringle, C. M., Sarstedt, M., Danks, N. P., & Ray, S. (2021). Partial Least Squares Structural Equation Modeling (PLS-SEM) Using R: A Workbook.
The tutorials on SEMinR are based on the mentioned book. The book is open source and available for download under this link.
Â
Additional SEMinR Tutorials
- An Introduction to R and R Studio
- An Introduction to SEMinR Package
- Create Project, Load, and Inspect the Data
- SEMinR Package: An Introduction to Evaluating Formative Measurement Model
- SEMinR Package: Analyzing Categorical Predictor Variables
- SEMinR Package: Bootstrapping PLS Model
- SEMinR Package: Evaluating Formative Measurement Model – Convergent Validity and Collinearity
- SEMinR Package: Evaluating Formative Measurement Model – Step 3- Indicator Weights
- SEMinR Package: Evaluating Formative Measurement Model – When to Delete Formative Indicators
- SEMinR Package: Evaluating Reflective Measurement Model
- SEMinR Package: Evaluating Structural Model
- SEMinR Package: Evaluating Structural Model – Step 4: Predictive Power (PLSPredict)
- SEMinR Package: Higher Order Analysis – REF-FOR
- SEMinR Package: Higher Order Analysis – REF-REF
- SEMinR Package: How to Solve Convergent and Discriminant Validity Problems
- SEMinR Package: Mediation Analysis
- SEMinR Package: PLS Estimation
- SEMinR Package: Print, Export and Plot Results
- SEMinR Package: Reflective Measurement Model Step 2: Consistency and Step 3: Convergent Validity
- SEMinR Package: Reflective Measurement Model Step 4: Discriminant Validity
- SEMinR Package: Single Item, SmartPLS Comparison and Summary of SEMinR
- SEMinR Package: Specifying Measurement Model
- SEMinR Package: Specifying the Structural Model