diff --git a/NAMESPACE b/NAMESPACE index 0267682..00dcd61 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -27,6 +27,7 @@ S3method(print,summary.seminr_model) S3method(print,table_output) S3method(rerun,pls_model) S3method(rhoC_AVE,cbsem_model) +S3method(rhoC_AVE,cfa_model) S3method(rhoC_AVE,pls_model) S3method(summary,boot_seminr_model) S3method(summary,cbsem_model) @@ -84,6 +85,7 @@ export(regression_weights) export(relationships) export(report_paths) export(rerun) +export(rhoC_AVE) export(rho_A) export(save_plot) export(seminr_theme_create) diff --git a/R/evaluate_reliability.R b/R/evaluate_reliability.R index be78a03..d6aeec4 100644 --- a/R/evaluate_reliability.R +++ b/R/evaluate_reliability.R @@ -75,20 +75,25 @@ rho_A <- function(seminr_model, constructs) { } # End rho_A function -# 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). -# 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 +#' seminr rhoC_AVE() function +#' +#' Get rhoC and AVE for a CFA model estimated with \code{estimate_pls}, \code{estimate_cbsem} or \code{estimate_cfa}. +#' 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 +#' +#' @param x Estimated \code{seminr_model} object. +#' +#' @param constructs Vector containing the names of the constructs to calculate rhoC and AVE for; if NULL, all constructs are used. +#' +#' @return A matrix containing the rhoC and AVE metrics for each construct. +#' +#' @export rhoC_AVE <- function(x, constructs = NULL) { UseMethod("rhoC_AVE") } -#' Get rhoC and AVE for a PLS model estimated with \code{estimate_pls} -#' @param x Estimated \code{pls_model} object. -#' @param constructs Vector containing the names of the constructs to calculate rhoC and AVE for; if NULL, all constructs are used. -#' @return A matrix containing the rhoC and AVE metrics for each construct. -#' #' @export rhoC_AVE.pls_model <- rhoC_AVE.boot_seminr_model <- function(x, constructs = NULL) { pls_model <- x @@ -115,20 +120,9 @@ rhoC_AVE.pls_model <- rhoC_AVE.boot_seminr_model <- function(x, constructs = NUL return(dgr) } -#' seminr rhoC_AVE() function -#' -#' Get rhoC and AVE for a CBSEM model estimated with \code{estimate_cbsem} -#' -#' @param x Estimated \code{cbsem_model} object. -#' -#' @param constructs Vector containing the names of the constructs to calculate rhoC and AVE for; if NULL, all constructs are used. -#' -#' @return A matrix containing the rhoC and AVE metrics for each construct. -#' #' @export rhoC_AVE.cbsem_model <- function(x, constructs = NULL) { - # Assumes factor loadings are in model: - # lavaan::inspect(fit,what="std")$lambda + # Assumes factor loadings are in model: lavaan::inspect(fit,what="std")$lambda cbsem_model <- x if (is.null(constructs)) { constructs <- cbsem_model$constructs @@ -151,12 +145,18 @@ rhoC_AVE.cbsem_model <- function(x, constructs = NULL) { return(dgr) } -rhoC_AVE_cfa_model <- function(seminr_model) { - dgr <- matrix(NA, nrow=length(seminr_model$constructs), ncol=2) - rownames(dgr) <- seminr_model$constructs +#' @export +rhoC_AVE.cfa_model <- function(x, constructs = NULL) { + cfa_model <- x + if (is.null(constructs)) { + constructs <- cfa_model$constructs + } + + dgr <- matrix(NA, nrow=length(constructs), ncol=2) + rownames(dgr) <- constructs colnames(dgr) <- c("rhoC", "AVE") - for(i in seminr_model$constructs) { - loadings <- seminr_model$factor_loadings[, i] + for(i in constructs) { + loadings <- cfa_model$factor_loadings[, i] ind <- which(loadings != 0) if(length(ind) == 1) { dgr[i, 1:2] <- 1 diff --git a/R/report_cfa.R b/R/report_cfa.R index 13a6f54..87ccdfa 100644 --- a/R/report_cfa.R +++ b/R/report_cfa.R @@ -7,7 +7,7 @@ summary.cfa_model <- function(object, na.print=".", digits=3, alpha=0.05,...) { model_summary <- summarize_cb_measurement(object, alpha=alpha) model_summary$quality <- list( fit = summarize_fit(object$lavaan_output), - reliability = rhoC_AVE_cfa_model(object) + reliability = rhoC_AVE(object) ) class(model_summary) <- c("summary.cfa_model", class(model_summary)) diff --git a/man/rhoC_AVE.Rd b/man/rhoC_AVE.Rd new file mode 100644 index 0000000..1754d9e --- /dev/null +++ b/man/rhoC_AVE.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/evaluate_reliability.R +\name{rhoC_AVE} +\alias{rhoC_AVE} +\title{seminr rhoC_AVE() function} +\usage{ +rhoC_AVE(x, constructs = NULL) +} +\arguments{ +\item{x}{Estimated \code{seminr_model} object.} + +\item{constructs}{Vector containing the names of the constructs to calculate rhoC and AVE for; if NULL, all constructs are used.} +} +\value{ +A matrix containing the rhoC and AVE metrics for each construct. +} +\description{ +Get rhoC and AVE for a CFA model estimated with \code{estimate_pls}, \code{estimate_cbsem} or \code{estimate_cfa}. +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 +} diff --git a/man/rhoC_AVE.cbsem_model.Rd b/man/rhoC_AVE.cbsem_model.Rd deleted file mode 100644 index 6a67ba7..0000000 --- a/man/rhoC_AVE.cbsem_model.Rd +++ /dev/null @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/evaluate_reliability.R -\name{rhoC_AVE.cbsem_model} -\alias{rhoC_AVE.cbsem_model} -\title{seminr rhoC_AVE() function} -\usage{ -\method{rhoC_AVE}{cbsem_model}(x, constructs = NULL) -} -\arguments{ -\item{x}{Estimated \code{cbsem_model} object.} - -\item{constructs}{Vector containing the names of the constructs to calculate rhoC and AVE for; if NULL, all constructs are used.} -} -\value{ -A matrix containing the rhoC and AVE metrics for each construct. -} -\description{ -Get rhoC and AVE for a CBSEM model estimated with \code{estimate_cbsem} -} diff --git a/man/rhoC_AVE.pls_model.Rd b/man/rhoC_AVE.pls_model.Rd deleted file mode 100644 index 7250d9a..0000000 --- a/man/rhoC_AVE.pls_model.Rd +++ /dev/null @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/evaluate_reliability.R -\name{rhoC_AVE.pls_model} -\alias{rhoC_AVE.pls_model} -\title{Get rhoC and AVE for a PLS model estimated with \code{estimate_pls}} -\usage{ -\method{rhoC_AVE}{pls_model}(x, constructs = NULL) -} -\arguments{ -\item{x}{Estimated \code{pls_model} object.} - -\item{constructs}{Vector containing the names of the constructs to calculate rhoC and AVE for; if NULL, all constructs are used.} -} -\value{ -A matrix containing the rhoC and AVE metrics for each construct. -} -\description{ -Get rhoC and AVE for a PLS model estimated with \code{estimate_pls} -}