@@ -77,7 +77,7 @@ standardErrorOfMeasurement <- function(jaspResults, dataset, options) {
7777 exitAnalysisIfErrors = TRUE )
7878
7979 if (options [[" lord2" ]] && options [[" lord2NumberOfSplits" ]] == " " ) {
80- .quitAnalysis(gettext(" For the Lord's compound method, the test could not be split in equally sized parts with more than 1 item per part. Consider adding or removing items." ))
80+ .quitAnalysis(gettext(" For the Lord generalized method, the test could not be split in equally sized parts with more than 1 item per part. Consider adding or removing items." ))
8181 }
8282}
8383
@@ -128,7 +128,7 @@ standardErrorOfMeasurement <- function(jaspResults, dataset, options) {
128128 # at least one method is selected
129129 for (i in 1 : length(selected )) {
130130 if (is.na(selected [[i ]][[" name" ]])) {
131- .quitAnalysis(gettext(" The Lord, Keats, and Lord's compound method are only available for binary data." ))
131+ .quitAnalysis(gettext(" The Lord, Keats, and Lord generalized method are only available for binary data." ))
132132 }
133133 if (is.null(jaspResults [[" semMainContainer" ]][[paste0(method [i ], " State" )]])) {
134134 out <- eval(parse(text = selected [[i ]][[" funString" ]]))
@@ -485,15 +485,15 @@ standardErrorOfMeasurement <- function(jaspResults, dataset, options) {
485485 pl <- ggplot2 :: ggplot(dat ) +
486486 ggplot2 :: geom_point(ggplot2 :: aes(x = score , y = tscore ), size = 2.5 ) +
487487 ggplot2 :: geom_errorbar(ggplot2 :: aes(x = score , ymin = lower , ymax = upper ), width = 0.5 ) +
488- ggplot2 :: labs(x = gettext(" Sum Score" ), y = gettext(" True Score" ))
488+ ggplot2 :: labs(x = gettext(" Sum Score" ), y = gettext(" True Score Estimate " ))
489489 } else {
490490 dat <- as.data.frame(ciData )
491491 colnames(dat ) <- c(" score" , " lower" , " upper" )
492492 dat $ tscore <- dat $ score
493493 pl <- ggplot2 :: ggplot(dat ) +
494494 ggplot2 :: geom_ribbon(ggplot2 :: aes(x = score , ymin = lower , ymax = upper ), fill = " grey80" ) +
495495 ggplot2 :: geom_line(ggplot2 :: aes(x = score , y = tscore )) +
496- ggplot2 :: labs(x = gettext(" Sum Score" ), y = gettext(" True Score" ))
496+ ggplot2 :: labs(x = gettext(" Sum Score" ), y = gettext(" True Score Estimate " ))
497497 }
498498
499499 if (! is.na(cutoff )) {
@@ -539,8 +539,19 @@ standardErrorOfMeasurement <- function(jaspResults, dataset, options) {
539539 out <- .semPrepareOutMatrix(ncol(X ), nc , scoresObj )
540540 fun <- function (partSUMS , ind , cc ) {
541541 K <- ncol(partSUMS )
542- mean_diff <- partSUMS [ind , ] - rowMeans(partSUMS [ind , ]) - matrix (colMeans(partSUMS [ind , ]), length(ind ), K , TRUE ) + mean(partSUMS [ind , ])
543- ret <- sqrt(d * sum(rowSums(mean_diff ^ 2 ) / (K - 1 )) / length(ind ))
542+ # mean_diff <- partSUMS[ind, ] - rowMeans(partSUMS[ind, ]) - matrix(colMeans(partSUMS[ind, ]), length(ind), K, TRUE) + mean(partSUMS[ind, ])
543+ # ret <- sqrt(d * sum(rowSums(mean_diff^2) / (K - 1)) / length(ind))
544+
545+ col_means <- colMeans(partSUMS ) # Global marginal means (X_j)
546+ grand_mean <- mean(col_means ) # Global grand mean (M)
547+ row_means <- rowMeans(partSUMS [ind , ]) # Person means (X_i)
548+
549+ # Construct Feldt's deviation term
550+ mean_diff <- partSUMS [ind , ] -
551+ matrix (row_means , length(ind ), K , byrow = FALSE ) -
552+ matrix (col_means - grand_mean , length(ind ), K , byrow = TRUE )
553+
554+ ret <- sqrt( d * sum(mean_diff ^ 2 ) / ((K - 1 ) * length(ind )) )
544555 return (ret )
545556 }
546557 out <- .semComputeWithCaseMin(out , S , caseMin , partSUMS , fun )
@@ -557,9 +568,7 @@ standardErrorOfMeasurement <- function(jaspResults, dataset, options) {
557568 out <- .semPrepareOutMatrix(ncol(X ), nc , scoresObj )
558569 scores <- out [, 1 ]
559570
560- rawDiffK <- d *
561- rowSums((partSUMS - matrix (colMeans(partSUMS ), N , K , TRUE ) - rowMeans(partSUMS ) + mean(partSUMS ))^ 2 ) /
562- (K - 1 )
571+ rawDiffK <- d * rowSums((partSUMS - matrix (colMeans(partSUMS ), N , K , TRUE ) - rowMeans(partSUMS ) + mean(partSUMS ))^ 2 ) / (K - 1 )
563572 betaK <- coef(lm(rawDiffK ~ poly(S , n_poly , raw = TRUE )))
564573 scrs <- sqrt(betaK [1 ] + rowSums(matrix (betaK [- 1 ], length(scores ), n_poly , TRUE ) * poly(scores , n_poly , raw = TRUE )))
565574 out [, 2 ] <- scrs
@@ -882,7 +891,7 @@ standardErrorOfMeasurement <- function(jaspResults, dataset, options) {
882891 funString = NA ,
883892 dependencies = NA )),
884893 lord2 = switch (as.character(nc ),
885- " 2" = list (name = " Lord's compound " ,
894+ " 2" = list (name = " Lord generalized " ,
886895 funString = " .semLord2(dataset, as.numeric(options$lord2NumberOfSplits), scrs, options$minimumGroupSize)" ,
887896 dependencies = c(" lord2" , " lord2NumberOfSplits" , " minimumGroupSize" )),
888897 list (name = NA ,
0 commit comments