|
2 | 2 | #' @export |
3 | 3 | unidimensionalReliabilityFrequentist <- function(jaspResults, dataset, options) { |
4 | 4 |
|
| 5 | + |
5 | 6 | # check for listwise deletion |
6 | 7 | datasetOld <- dataset |
7 | 8 | dataset <- .handleData(datasetOld, options) |
@@ -952,8 +953,8 @@ unidimensionalReliabilityFrequentist <- function(jaspResults, dataset, options) |
952 | 953 | out[["conf"]][["scaleSplithalf"]] <- quantile(samp, probs = c((1 - ciValue) / 2, 1 - (1 - ciValue) / 2), na.rm = TRUE) |
953 | 954 | out[["se"]][["scaleSplithalf"]] <- sd(samp, na.rm = TRUE) |
954 | 955 | } else { # interval analytic |
955 | | - partSums1 <- rowSums(dtUse[, splits[[1]]]) |
956 | | - partSums2 <- rowSums(dtUse[, splits[[2]]]) |
| 956 | + partSums1 <- rowSums(dtUse[, splits[[1]], drop = FALSE]) |
| 957 | + partSums2 <- rowSums(dtUse[, splits[[2]], drop = FALSE]) |
957 | 958 |
|
958 | 959 | out[["se"]][["scaleSplithalf"]] <- .seSplithalf(partSums1, partSums2, model[["use.cases"]]) |
959 | 960 | out[["conf"]][["scaleSplithalf"]] <- out[["est"]][["scaleSplithalf"]] + c(-1, 1) * out[["se"]][["scaleSplithalf"]] * qnorm(1 - (1 - ciValue) / 2) |
@@ -1168,31 +1169,33 @@ unidimensionalReliabilityFrequentist <- function(jaspResults, dataset, options) |
1168 | 1169 | out[["est"]][["itemDeletedSplithalf"]] <- c(NA, NA) |
1169 | 1170 | out[["lower"]][["itemDeletedSplithalf"]] <- c(NA, NA) |
1170 | 1171 | out[["upper"]][["itemDeletedSplithalf"]] <- c(NA, NA) |
1171 | | - } |
1172 | | - |
1173 | | - for (i in seq_len(ncol(dtUse))) { |
1174 | | - dtCut <- dtUse[, -i, drop = FALSE] |
1175 | | - nit <- ncol(dtCut) |
1176 | | - splits <- split(seq_len(nit), 1:2) |
1177 | | - est <- .splithalfData(dtCut, splits = splits, useCase = model[["use.cases"]]) |
1178 | | - out[["est"]][["itemDeletedSplithalf"]][i] <- est |
| 1172 | + } else { |
| 1173 | + for (i in seq_len(ncol(dtUse))) { |
| 1174 | + dtCut <- dtUse[, -i, drop = FALSE] |
| 1175 | + nit <- ncol(dtCut) |
| 1176 | + splits <- split(seq_len(nit), 1:2) |
| 1177 | + est <- .splithalfData(dtCut, splits = splits, useCase = model[["use.cases"]]) |
| 1178 | + out[["est"]][["itemDeletedSplithalf"]][i] <- est |
1179 | 1179 |
|
1180 | | - if (options[["intervalMethod"]] == "analytic") { |
| 1180 | + if (options[["intervalMethod"]] == "analytic") { |
1181 | 1181 |
|
1182 | | - partSums1 <- rowSums(dtCut[, splits[[1]]]) |
1183 | | - partSums2 <- rowSums(dtCut[, splits[[2]]]) |
| 1182 | + partSums1 <- rowSums(dtCut[, splits[[1]]]) |
| 1183 | + partSums2 <- rowSums(dtCut[, splits[[2]]]) |
1184 | 1184 |
|
1185 | | - se <- .seSplithalf(partSums1, partSums2, model[["use.cases"]]) |
1186 | | - conf <- est + c(-1, 1) * se * qnorm(1 - (1 - ciValue) / 2) |
1187 | | - out[["lower"]][["itemDeletedSplithalf"]][i] <- conf[1] |
1188 | | - out[["upper"]][["itemDeletedSplithalf"]][i] <- conf[2] |
1189 | | - } else { |
1190 | | - itemSamp <- model[["itemDeletedSplithalf"]][["itemSamp"]] |
1191 | | - conf <- quantile(itemSamp[, i], probs = c((1 - ciValue) / 2, 1 - (1 - ciValue) / 2), na.rm = TRUE) |
1192 | | - out[["lower"]][["itemDeletedSplithalf"]][i] <- conf[1] |
1193 | | - out[["upper"]][["itemDeletedSplithalf"]][i] <- conf[2] |
| 1185 | + se <- .seSplithalf(partSums1, partSums2, model[["use.cases"]]) |
| 1186 | + conf <- est + c(-1, 1) * se * qnorm(1 - (1 - ciValue) / 2) |
| 1187 | + out[["lower"]][["itemDeletedSplithalf"]][i] <- conf[1] |
| 1188 | + out[["upper"]][["itemDeletedSplithalf"]][i] <- conf[2] |
| 1189 | + } else { |
| 1190 | + itemSamp <- model[["itemDeletedSplithalf"]][["itemSamp"]] |
| 1191 | + conf <- quantile(itemSamp[, i], probs = c((1 - ciValue) / 2, 1 - (1 - ciValue) / 2), na.rm = TRUE) |
| 1192 | + out[["lower"]][["itemDeletedSplithalf"]][i] <- conf[1] |
| 1193 | + out[["upper"]][["itemDeletedSplithalf"]][i] <- conf[2] |
| 1194 | + } |
1194 | 1195 | } |
1195 | 1196 | } |
| 1197 | + |
| 1198 | + |
1196 | 1199 | } |
1197 | 1200 |
|
1198 | 1201 | # item-rest correlation |
|
0 commit comments