Skip to content

Commit

Permalink
fix: S3 generic method and implementations use same function signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
soumyaray committed Nov 19, 2024
1 parent 6bf5eab commit e473175
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 25 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: seminr
Type: Package
Title: Building and Estimating Structural Equation Models
Version: 2.3.4
Version: 2.3.5
Date: 2024-10-12
Authors@R: c(person("Soumya", "Ray", email = "[email protected]", role = c("aut", "ths")),
person("Nicholas Patrick", "Danks", email = "[email protected]", role = c("aut","cre")),
Expand Down Expand Up @@ -33,7 +33,7 @@ Depends: R (>= 3.5.0)
LazyData: TRUE
URL: https://github.com/sem-in-r/seminr
BugReports: https://github.com/sem-in-r/seminr/issues
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
Enhances: rsvg (>= 2.1),
semPlot,
vdiffr
Expand Down
2 changes: 1 addition & 1 deletion R/evaluate_measurement_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ reliability <- function(seminr_model) {
#get HOC
model_constructs <- constructs_in_model(seminr_model)
alpha <- cronbachs_alpha(seminr_model, model_constructs$construct_names)
mat1 <- rhoC_AVE(pls_model = seminr_model, constructs = model_constructs$construct_names)
mat1 <- rhoC_AVE(seminr_model, constructs = model_constructs$construct_names)
mat2 <- rho_A(seminr_model, model_constructs$construct_names)
table <- cbind(alpha, mat1, mat2)
colnames(table) <- c("alpha", "rhoC", "AVE", "rhoA")
Expand Down
27 changes: 6 additions & 21 deletions R/evaluate_reliability.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,34 +80,19 @@ rho_A <- function(seminr_model, constructs) {
# 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(x, ...) {
rhoC_AVE <- function(x, constructs = NULL) {
UseMethod("rhoC_AVE")
}

# rhoC_AVE.pls_model <- rhoC_AVE.boot_seminr_model <- function(pls_model, constructs) {
#' @export
rhoC_AVE.pls_model <- rhoC_AVE.boot_seminr_model <- function(pls_model, constructs) {
dgr <- matrix(NA, nrow=length(constructs), ncol=2)
rownames(dgr) <- constructs
colnames(dgr) <- c("rhoC", "AVE")
for(i in constructs){
loadings <- pls_model$outer_loadings[, i]
ind <- which(loadings != 0)
if(measure_mode(i, pls_model$mmMatrix) %in% c("A", "B", "HOCA", "HOCB", "C", "UNIT")) {
if(length(ind) == 1) {
dgr[i, 1:2] <- 1
} else {
lambdas <- loadings[ind]
dgr[i, 1] <- compute_rhoC(lambdas)
dgr[i, 2] <- compute_AVE(lambdas)
}
}
rhoC_AVE.pls_model <- rhoC_AVE.boot_seminr_model <- function(x, constructs = NULL) {
pls_model <- x
if (is.null(constructs)) {
constructs <- pls_model$constructs
}
return(dgr)
}

rhoC_AVE_boot_seminr_model <- function(pls_model, constructs){
dgr <- matrix(NA, nrow=length(constructs), ncol=2)

rownames(dgr) <- constructs
colnames(dgr) <- c("rhoC", "AVE")
for(i in constructs){
Expand Down
2 changes: 1 addition & 1 deletion R/evaluate_validity.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ fl_criteria_table <- function(seminr_model, model_constructs) {
# }
table <- stats::cor(model_constructs$construct_scores)
table[upper.tri(table)] <- NA
diag(table) <- sqrt(rhoC_AVE(seminr_model, model_constructs$construct_names)[,"AVE"])
diag(table) <- sqrt(rhoC_AVE(seminr_model, constructs = model_constructs$construct_names)[,"AVE"])
comment(table) <- "FL Criteria table reports square root of AVE on the diagonal and construct correlations on the lower triangle."
convert_to_table_output(table)
}

0 comments on commit e473175

Please sign in to comment.