@@ -271,7 +271,7 @@ calculateIndicatorCor <- function(
271271 cor_type <- S
272272
273273 # list for the thresholds
274- thres_est <- NULL
274+ thres_est <- list ()
275275
276276 # temp is used to only calculate the correlations between two
277277 # indicators once (upper triangular matrix)
@@ -284,28 +284,28 @@ calculateIndicatorCor <- function(
284284 if (is_numeric_indicator [[i ]] == FALSE & is_numeric_indicator [[j ]] == FALSE ){
285285 # The polycor package gives a list with the polychoric correlation and
286286 # the thresholds estimates
287- cor_temp <- polycor :: polychor(.X_cleaned [,i ], .X_cleaned [,j ], thresholds = TRUE )
288- S [i ,j ] <- cor_temp $ rho
289- cor_type [i ,j ] <- cor_temp $ type
290- thres_est [[i ]] <- cor_temp $ row.cuts
291- thres_est [[j ]] <- cor_temp $ col.cuts
287+ rho <- polychor(.X_cleaned [,i ], .X_cleaned [,j ], thresholds = TRUE )
288+ S [i ,j ] <- rho
289+ cor_type [i ,j ] <- " polychoric "
290+ thres_est [[i ]] <- attr( rho , " thr.x " )
291+ thres_est [[j ]] <- attr( rho , " thr.y " )
292292
293293 # If one indicator is continous, the polyserial correlation
294294 # is calculated.Note: polyserial needs the continous
295295 # indicator as the first argument.
296296 }else if (is_numeric_indicator [[i ]] == FALSE & is_numeric_indicator [[j ]] == TRUE ){
297297 # The polycor package gives the polyserial correlation and the thresholds
298- cor_temp <- polycor :: polyserial(.X_cleaned [,j ], .X_cleaned [,i ], thresholds = TRUE )
299- S [i ,j ] <- cor_temp $ rho
300- cor_type [i ,j ] <- cor_temp $ type
301- thres_est [[i ]] <- cor_temp $ cuts
298+ rho <- polyserial(.X_cleaned [,j ], .X_cleaned [,i ], thresholds = TRUE )
299+ S [i ,j ] <- rho
300+ cor_type [i ,j ] <- " polyserial "
301+ thres_est [[i ]] <- attr( rho , " thr.y " )
302302 thres_est [[j ]] <- NA
303303 }else if (is_numeric_indicator [[i ]] == TRUE & is_numeric_indicator [[j ]] == FALSE ){
304- cor_temp <- polycor :: polyserial(.X_cleaned [,i ], .X_cleaned [,j ], thresholds = TRUE )
305- S [i ,j ] <- cor_temp $ rho
306- cor_type [i ,j ] <- cor_temp $ type
307- thres_est [[j ]] <- cor_temp $ cuts
304+ rho <- polyserial(.X_cleaned [,i ], .X_cleaned [,j ], thresholds = TRUE )
305+ S [i ,j ] <- rho
306+ cor_type [i ,j ] <- " polyserial"
308307 thres_est [[i ]] <- NA
308+ thres_est [[j ]] <- attr(rho , " thr.y" )
309309
310310 # If both indicators are continous, the Pearson correlation
311311 # is calculated.
@@ -366,6 +366,7 @@ calculateIndicatorCor <- function(
366366 list (S = S , cor_type = cor_type , thres_est = thres_est )
367367}
368368
369+
369370# ' Internal: Calculate Reliabilities
370371# '
371372# ' @inheritParams csem_arguments
@@ -688,4 +689,4 @@ setDominantIndicator <- function(
688689 # .W[i, ] = .W[i, ] * sign(.W[i, .dominant_indicators[i]])
689690 }
690691 return (.W )
691- }
692+ }
0 commit comments