Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
.Rproj.user/
.Rhistory
.RData
delete this working file.R
engage_2.csv
.Rproj.user
_*
.*
.DS*
.R*
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
language: r

os:
- linux
- osx

cache: packages

# safelist
branches:
only:
- develop
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Package: seminr
Type: Package
Title: Natural, Friendly, Domain-Specific Language for Building PLS Structural Equation Models
Version: 0.3.0
Date: 2017-10-12
Version: 0.3.1
Date: 2018-01-03
Authors@R: c(person("Soumya", "Ray",
email = "soumya.ray@gmail.com", role = c("aut")),
email = "soumya.ray@gmail.com", role = c("aut", "ths")),
person("Nicholas", "Danks",
email = "nicholasdanks@hotmail.com", role = c("aut","cre")))
Description: A powerful, easy to write and easy to modify syntax for
Expand Down
6 changes: 3 additions & 3 deletions R/evaluation.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ evaluate_model <- function(seminr_model) {

## Reliability -------------------------
# RhoC and AVE
# Dillon-Goldstein's Rho as per: Dillon, W. R, and M. Goldstein. 1987. Multivariate Analysis: Methods
# and Applications. Biometrical Journal 29 (6): 750–756.
# Dillon-Goldstein's Rho as per: Dillon, W. R, and M. Goldstein. 1987. Multivariate Analysis: Methods
# and Applications. Biometrical Journal 29 (6).
# Average Variance Extracted as per: Fornell, C. and D. F. Larcker (February 1981). Evaluating
# structural equation models with unobservable variables and measurement error, Journal of Marketing Research, 18, pp. 39-5
rhoC_AVE <- function(seminr_model){
Expand Down Expand Up @@ -102,7 +102,7 @@ cross_loadings <- function(seminr_model) {
}

# HTMT as per Henseler, J., Ringle, C. M., & Sarstedt, M. (2014). A new criterion for assessing discriminant validity in
# variance-based structural equation modeling. Journal of the Academy of Marketing Science, 43(1), 115135.
# variance-based structural equation modeling. Journal of the Academy of Marketing Science, 43(1), 115-135.
# https://doi.org/10.1007/s11747-014-0403-8
HTMT <- function(seminr_model) {
HTMT <- matrix(, nrow=length(seminr_model$ltVariables), ncol=length(seminr_model$ltVariables),
Expand Down
2 changes: 1 addition & 1 deletion R/library.R
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ calculate_loadings <- function(weights_matrix,fscores, normData) {
# Function to adjust for the interaction
# Adjustment of the SD of the interaction term as per Henseler, J., & Chin, W. W. (2010),
# A comparison of approaches for the analysis of interaction effects between latent variables
# using partial least squares path modeling. Structural Equation Modeling, 17(1), 82109. https://doi.org/10.1080/10705510903439003
# using partial least squares path modeling. Structural Equation Modeling, 17(1), 82-109. https://doi.org/10.1080/10705510903439003
adjust_interaction <- function(ltVariables, mmMatrix, outer_loadings, fscores, obsData){
for(latent in ltVariables) {
adjustment <- 0
Expand Down
1 change: 0 additions & 1 deletion R/summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ summary.seminr_model <- function(object, na.print=".", digits=3, ...) {

model_summary <- list(iterations=iterations,
paths=path_reports,
metrics=metrics,
loadings=object$outer_loadings,
cross_loadings=metrics$Validity$`Cross-Loadings`,
weights=object$outer_weights,
Expand Down
94 changes: 48 additions & 46 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,18 @@ knitr::opts_chunk$set(

# SEMinR

The `seminr` package provides a natural syntax for researchers to describe PLS structural equation models.
SEMinR brings many advancements to creating and estimating structural equation models (SEM) using Partial Least Squares Path Modeling (PLS-PM):

* A _natural_ feeling, _domain-specific_ language to build and estimate structural equation models in R
* Uses _variance-based PLS estimation_ to model both _composite_ and _common-factor_ constructs
* _High-level functions_ to quickly specify interactions and complicated structural models

SEMinR follows the latest best-practices in methodological literature:

* Automatically _adjusts PLS estimates to ensure consistency (PLSc)_ wherever common factors are involved
* Ajusts for known biases in interaction terms in PLS models
* Continuously tested against leading PLSPM software to ensure parity of outcomes: SmartPLS (Ringle et al., 2015) and ADANCO (Henseler and Dijkstra, 2015), as well as other R packages such as semPLS (Monecke and Leisch, 2012) and matrixpls (Rönkkö, 2016)
* _High performance, multi-core_ bootstrapping function

## Documentation

Expand All @@ -26,64 +37,55 @@ Demo code for use of Seminr can be found in the [seminr/demo/](https://github.co

## Installation

You can install seminr from github with:
You can install SEMinR with:

```{r gh-installation, eval = FALSE}
# install.packages("devtools")
devtools::install_github("ISS-Analytics/seminr")
```{r, eval=FALSE}
install.packages("seminr")
```

## Usage

Seminr can be used to create a plsm model, to estimate the model and to perform bootstrapping.
Briefly, there are four steps to specifying and estimating a structural equation model using SEMinR:

```{r example}
# seminr syntax for creating measurement model
mobi_mm <- constructs(
reflective("Image", multi_items("IMAG", 1:5)),
reflective("Expectation", multi_items("CUEX", 1:3)),
reflective("Value", multi_items("PERV", 1:2)),
reflective("Satisfaction", multi_items("CUSA", 1:3))
1 Describe measurement model for each construct and its items:
```{r, eval=FALSE}
# Distinguish and mix composite or reflective (common-factor) measurement models
measurements <- constructs(
composite("Image", multi_items("IMAG", 1:5), weights = mode_B),
composite("Expectation", multi_items("CUEX", 1:3), weights = mode_A),
reflective("Loyalty", multi_items("CUSL", 1:3))
)
```

# interaction factors must be created after the measurement model is defined
mobi_xm <- interactions(
interaction_combo("Image", "Expectation"),
interaction_combo("Image", "Value")
2 Specify any interactions between constructs:
```{r, eval=FALSE}
# Easily create orthogonalized or scaled interactions between constructs
intxns <- interactions(
interaction_ortho("Image", "Expectation")
)
```

# structural model: note that name of the interactions factor should be
# the names of its two main factors joined by a '.' in between.
mobi_sm <- relationships(
paths(to = "Satisfaction",
from = c("Image", "Expectation", "Value",
"Image.Expectation", "Image.Value"))
3 Describe the structural model of causal relationships between constructs (and interactions):
```{r, eval=FALSE}
# Quickly create multiple paths "from" and "to" sets of constructs
structure <- relationships(
paths(from = c("Image", "Expectation", "Image.Expectation"),
to = "Loyalty")
)

# Load data, assemble model, and estimate using semPLS
data("mobi", package = "semPLS")
seminr_model <- estimate_model(data = mobi,
measurement_model = mobi_mm,
interactions = mobi_xm,
structural_model = mobi_sm)

summary(seminr_model)

seminr_model_boot <- bootstrap_model(data = mobi,
measurement_model = mobi_mm,
interactions = mobi_xm,
structural_model = mobi_sm,
nboot = 200)

summary(seminr_model_boot)
```

## Testing
4 Put the above elements together to estimate and bootstrap the model:
```{r, eval=FALSE}
# Dynamically compose SEM models from individual parts
pls_model <- estimate_pls(data = mobi, measurements, intxns, structure)
summary(pls_model)

To test:

```{r devtools-test, eval = FALSE}
require(devtools)
devtools::test()
# Use multi-core parallel processing to speed up bootstraps
boot_estimates <- bootstrap_model(pls_model, nboot = 1000, cores = 2)
summary(boot_estimates)
```

## Authors

* Soumya Ray
* Nicholas Danks
179 changes: 86 additions & 93 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,93 +1,86 @@

<!-- README.md is generated from README.Rmd. Please edit that file -->
SEMinR
======

The `seminr` package provides a natural syntax for researchers to describe PLS structural equation models.

Documentation
-------------

The vignette for Seminr can be found in the [seminr/inst/doc/](https://github.com/ISS-Analytics/seminr/blob/master/inst/doc/SEMinR.html) folder or by running the `vignette("SEMinR")` command after installation.

Demo code for use of Seminr can be found in the [seminr/demo/](https://github.com/ISS-Analytics/seminr/tree/master/demo) folder or by running the `demo("seminr-contained")`, `demo("seminr-ecsi")` or `demo("seminr-interaction")` commands after installation.

Installation
------------

You can install seminr from github with:

``` r
# install.packages("devtools")
devtools::install_github("ISS-Analytics/seminr")
```

Usage
-----

Seminr can be used to create a plsm model, to estimate the model and to perform bootstrapping.

``` r
# seminr syntax for creating measurement model
mobi_mm <- measure(
reflective("Image", multi_items("IMAG", 1:5)),
reflective("Expectation", multi_items("CUEX", 1:3)),
reflective("Value", multi_items("PERV", 1:2)),
reflective("Satisfaction", multi_items("CUSA", 1:3))
)

# interaction factors must be created after the measurement model is defined
mobi_xm <- interact(
interaction_combo("Image", "Expectation"),
interaction_combo("Image", "Value")
)

# structural model: note that name of the interactions factor should be
# the names of its two main factors joined by a '.' in between.
mobi_sm <- structure(
paths(to = "Satisfaction",
from = c("Image", "Expectation", "Value",
"Image.Expectation", "Image.Value"))
)

# Load data, assemble model, and estimate using semPLS
data("mobi", package = "semPLS")
seminr_model <- create_model(data = mobi,
measurement_model = mobi_mm,
interaction = mobi_xm,
structural_model = mobi_sm)
#> Generating the plsm model

mobi_pls <- estimate_model(seminr_model, nboot = 200)
#> Estimating model using semPLS::sempls...
print_paths(mobi_pls)
#> Satisfaction
#> R^2 0.60
#> Expectation 0.47
#> Image 0.80
#> Image.Expectation -0.52
#> Image.Value -0.16
#> Value 0.43
#> Estimate Bootstrapped Estimate
#> Expectation -> Satisfaction 0.47 0.40
#> Image -> Satisfaction 0.80 0.77
#> Image.Expectation -> Satisfaction -0.52 -0.40
#> Image.Value -> Satisfaction -0.16 -0.25
#> Value -> Satisfaction 0.43 0.51
#> Standard Error
#> Expectation -> Satisfaction 0.31
#> Image -> Satisfaction 0.19
#> Image.Expectation -> Satisfaction 0.51
#> Image.Value -> Satisfaction 0.47
#> Value -> Satisfaction 0.33
```

Testing
-------

To test:

``` r
require(devtools)
devtools::test()
```

<!-- README.md is generated from README.Rmd. Please edit that file -->
SEMinR
======

SEMinR brings many advancements to creating and estimating structural equation models (SEM) using Partial Least Squares Path Modeling (PLS-PM):

- A *natural* feeling, *domain-specific* language to build and estimate structural equation models in R
- Uses *variance-based PLS estimation* to model both *composite* and *common-factor* constructs
- *High-level functions* to quickly specify interactions and complicated structural models

SEMinR follows the latest best-practices in methodological literature:

- Automatically *adjusts PLS estimates to ensure consistency (PLSc)* wherever common factors are involved
- Ajusts for known biases in interaction terms in PLS models
- Continuously tested against leading PLSPM software to ensure parity of outcomes: SmartPLS (Ringle et al., 2015) and ADANCO (Henseler and Dijkstra, 2015), as well as other R packages such as semPLS (Monecke and Leisch, 2012) and matrixpls (Rönkkö, 2016)
- *High performance, multi-core* bootstrapping function

Documentation
-------------

The vignette for Seminr can be found in the [seminr/inst/doc/](https://github.com/ISS-Analytics/seminr/blob/master/inst/doc/SEMinR.html) folder or by running the `vignette("SEMinR")` command after installation.

Demo code for use of Seminr can be found in the [seminr/demo/](https://github.com/ISS-Analytics/seminr/tree/master/demo) folder or by running the `demo("seminr-contained")`, `demo("seminr-ecsi")` or `demo("seminr-interaction")` commands after installation.

Installation
------------

You can install SEMinR with:

``` r
install.packages("seminr")
```

Usage
-----

Briefly, there are four steps to specifying and estimating a structural equation model using SEMinR:

1 Describe measurement model for each construct and its items:

``` r
# Distinguish and mix composite or reflective (common-factor) measurement models
measurements <- constructs(
composite("Image", multi_items("IMAG", 1:5), weights = mode_B),
composite("Expectation", multi_items("CUEX", 1:3), weights = mode_A),
reflective("Loyalty", multi_items("CUSL", 1:3))
)
```

2 Specify any interactions between constructs:

``` r
# Easily create orthogonalized or scaled interactions between constructs
intxns <- interactions(
interaction_ortho("Image", "Expectation")
)
```

3 Describe the structural model of causal relationships between constructs (and interactions):

``` r
# Quickly create multiple paths "from" and "to" sets of constructs
structure <- relationships(
paths(from = c("Image", "Expectation", "Image.Expectation"),
to = "Loyalty")
)
```

4 Put the above elements together to estimate and bootstrap the model:

``` r
# Dynamically compose SEM models from individual parts
pls_model <- estimate_pls(data = mobi, measurements, intxns, structure)
summary(pls_model)

# Use multi-core parallel processing to speed up bootstraps
boot_estimates <- bootstrap_model(pls_model, nboot = 1000, cores = 2)
summary(boot_estimates)
```

Authors
-------

- Soumya Ray
- Nicholas Danks
1 change: 1 addition & 0 deletions SEMinR.Rproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageCheckArgs: --as-cran
PackageRoxygenize: rd,collate,namespace
4 changes: 2 additions & 2 deletions inst/doc/SEMinR.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ library(seminr)
# summary(pls_model)
#
# # Use multi-core parallel processing to speed up bootstraps
# boot_estimates <- bootstrap_model(pls_model, nboot = 200, cores = 4)
# boot_estimates <- bootstrap_model(pls_model, nboot = 2000, cores = 4)
# summary(boot_estimates)

## ---- eval=FALSE---------------------------------------------------------
Expand Down Expand Up @@ -155,7 +155,7 @@ mobi_pls <- estimate_pls(data = mobi,
## ------------------------------------------------------------------------
# use 2000 bootstraps and utilize 4 parallel cores
boot_mobi_pls <- bootstrap_model(seminr_model = mobi_pls,
nboot = 200,
nboot = 2000,
cores = 2)

## ------------------------------------------------------------------------
Expand Down
Loading