Skip to content

Commit a5a5da5

Browse files
Updated changelog, vignette, tests for fSquared and minor changes to fSquared function. (#124)
1 parent fedb071 commit a5a5da5

File tree

9 files changed

+79
-11
lines changed

9 files changed

+79
-11
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818
- A test for the bootstrap summary return object
1919
- Descriptive statistics for item and construct data
2020
- S3 print method for class "table_output" for printing generic tables
21+
- A fSquare function to calculating fSquared
22+
- A test for fSquared function
2123

2224
### Changed
2325
- Fixtures for evaluating bootstrap HTMT for versions of R < 3.6.0
2426
- Changed the R/* file naming to R/estimate_ R/feature_ R/evaluate_ etc.
2527
- Summary S3 method to return data descriptives in summary object
28+
- Changed references to include Cohen (2013)
29+
- Updated vignette to reflect fSquare function
2630

2731
### Fixed
2832
- Modified calculation of HTMT to use absolute correlation matrices in order to make HTMT stable

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export(confidence_interval)
1313
export(constructs)
1414
export(correlation_weights)
1515
export(estimate_pls)
16+
export(fSquared)
1617
export(interaction_2stage)
1718
export(interaction_ortho)
1819
export(interaction_scaled)

R/evaluate_effects.R

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,18 @@
3737
#'
3838
#' fSquared(mobi_pls, "Image", "Satisfaction")
3939
#' @export
40-
# fSquared as per Cohen (2013)
41-
4240
fSquared <- function(seminr_model, iv, dv) {
4341
with_sm <- seminr_model$smMatrix
4442
without_sm <- subset(with_sm, !((with_sm[, "source"] == iv) & (with_sm[, "target"] == dv)))
4543
capture.output(
46-
without_pls <- estimate_pls(data = seminr_model$data,
44+
without_pls <- estimate_pls(data = seminr_model$rawdata,
4745
measurement_model = seminr_model$mmMatrix,
46+
interactions = seminr_model$interactions,
4847
structural_model = without_sm)
4948
)
50-
5149
with_r2 <- seminr_model$rSquared["Rsq", dv]
52-
without_r2 <- without_pls$rSquared["Rsq", dv]
53-
54-
(with_r2 - without_r2) / (1 - with_r2)
50+
ifelse(any(without_sm[,"target"] == dv),
51+
without_r2 <- without_pls$rSquared["Rsq", dv],
52+
without_r2 <- 0)
53+
return((with_r2 - without_r2) / (1 - with_r2))
5554
}

man/fSquared.Rd

Lines changed: 47 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

references.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,6 @@
5757
ref: Sarstedt, M., Hair, J. F., Ringle, C. M., Thiele, K. O., & Gudergan, S. P. (2016). Estimation issues with PLS and CBSEM: Where the bias lies! Journal of Business Research, 69(10), 3998–4010
5858
cite: Sarstedt et al. (2016)
5959
- code: [short code here]
60-
ref: [full academic reference here]
61-
cite: [preferred citation format]
60+
ref: Cohen, J. (2013). Statistical power analysis for the behavioral sciences. Routledge.
61+
cite: Cohen (2013)
6262

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
"","x"
2+
"1",0.303554364141901
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
"","x"
2+
"1",0.303554364141901

tests/testthat/test-metric.R

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,26 @@ mobi_sm <- relationships(
2222
mobi <- mobi
2323
seminr_model <- estimate_pls(mobi, mobi_mm, interactions = NULL ,mobi_sm)
2424

25-
2625
# Load outputs
2726
rsquared <- seminr_model$rSquared
27+
fsquared <- fSquared(seminr_model, "Image", "Satisfaction")
2828

2929
## Output originally created using following lines
3030
# write.csv(seminr_model$rSquared, file = "tests/fixtures/rsquared1.csv")
31+
# write.csv(fSquared(seminr_model, "Image", "Satisfaction"), file = "tests/fixtures/V_3_5_X/fsquared1.csv")
32+
# write.csv(fSquared(seminr_model, "Image", "Satisfaction"), file = "tests/fixtures/V_3_6_0/fsquared1.csv")
33+
3134

3235
# Load controls
3336
rsquared_control <- as.matrix(read.csv(file = paste(test_folder,"rsquared1.csv", sep = ""), row.names = 1))
37+
fsquared_control <- as.matrix(read.csv(file = paste(test_folder,"fsquared1.csv", sep = ""), row.names = 1))
3438

3539
# Testing
3640

3741
test_that("Seminr estimates the Rsquared correctly", {
38-
# Remove BIC for now
3942
expect_equal(rsquared[1:2,1], rsquared_control[1:2,1], tolerance = 0.00001)
4043
})
4144

45+
test_that("Seminr estimates the fSquared correctly", {
46+
expect_equal(fsquared, fsquared_control[1,1], tolerance = 0.00001)
47+
})

vignettes/SEMinR.Rmd

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,12 @@ summary(mobi_pls)
409409

410410
Please note that common-factor scores are indeterminable and therefore construct scores for common factors are not reported (Hair et al.,2011).
411411

412+
3. The fSquare of specific relationships can be determine using the `fSquared()` function as per Cohen (2013).
413+
414+
```{r}
415+
fSquared(mobi_pls, "Image", "Satisfaction")
416+
```
417+
412418
### Reporting the bootstrapped `boot_seminr_model`
413419

414420
As with the estimated model, there are multiple ways of reporting the bootstrapped model. The `bootstrap_model()` function returns an object of class `boot_seminr_model`. This can be passed directly to the base R function `summary()`. This can be used in two primary ways:
@@ -500,6 +506,7 @@ model_summary$descriptives$correlations$constructs
500506
## References
501507

502508
* Becker et al. (2018). Estimating Moderating Effects in PLS-SEM and PLSc-SEM: Interaction Term Generation*Data Treatment
509+
* Cohen, J. (2013). Statistical power analysis for the behavioral sciences. Routledge.
503510
* Dijkstra, T. K., & Henseler, J. (2015). Consistent Partial Least Squares Path Modeling, MIS Quarterly Vol. 39(X).
504511
* Dillon, W. R, and M. Goldstein. 1987. Multivariate Analysis: Methods, and Applications. Biometrical Journal 29 (6): 750–756.
505512
* 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)

0 commit comments

Comments
 (0)