|
923 | 923 | tb$addColumnInfo(name = "hq", title = gettext("HQ"), type = "number") |
924 | 924 | tb$addColumnInfo(name = "bic", title = gettext("BIC"), type = "number") |
925 | 925 | tb$addColumnInfo(name = "x2", title = gettext("X2"), type = "number") |
926 | | - tb$addColumnInfo(name = "df", title = gettext("df"), type = "number") |
| 926 | + tb$addColumnInfo(name = "df", title = gettext("df"), type = "integer") |
927 | 927 | tb$addColumnInfo(name = "p", title = gettext("p"), type = "pvalue") |
928 | 928 | tb$dependOn(options = c(.irtCommonDeps(type = "irt"), "tableDifAnalysis", "groupingVariable", "tableDifAnalysisDifficulty", "tableDifAnalysisDiscrimination", "tableDifAnalysisGuess", "tableDifAnalysisSlip")) |
929 | 929 | tb$addFootnote(gettext("For each item, the null hypothesis specifies that there is no DIF between the groups.")) |
|
935 | 935 | if (!ready || options[["groupingVariable"]] == "") { |
936 | 936 | return() |
937 | 937 | } |
| 938 | + state <- .irtIRTStateBayesian(dataset, options, jaspResults) |
938 | 939 | parameters <- character() |
939 | | - if (options[["tableDifAnalysisDifficulty"]]) { |
940 | | - parameters <- c(parameters, "d") |
941 | | - } |
942 | | - if (options[["tableDifAnalysisDiscrimination"]] && options[["model"]] %in% c("2PL", "3PL", "4PL")) { |
943 | | - parameters <- c(parameters, "a1") |
944 | | - } |
945 | | - if (options[["tableDifAnalysisGuess"]] && options[["model"]] %in% c("3PL", "4PL")) { |
946 | | - parameters <- c(parameters, "d") |
947 | | - } |
948 | | - if (options[["tableDifAnalysisSlip"]] && options[["model"]] == "4PL") { |
949 | | - parameters <- c(parameters, "u") |
| 940 | + if (options[["dichotomous"]]) { |
| 941 | + if (options[["tableDifAnalysisDifficulty"]]) { |
| 942 | + parameters <- c(parameters, "d") |
| 943 | + } |
| 944 | + if (options[["tableDifAnalysisDiscrimination"]] && options[["model"]] %in% c("2PL", "3PL", "4PL")) { |
| 945 | + parameters <- c(parameters, "a1") |
| 946 | + } |
| 947 | + if (options[["tableDifAnalysisGuess"]] && options[["model"]] %in% c("3PL", "4PL")) { |
| 948 | + parameters <- c(parameters, "g") |
| 949 | + } |
| 950 | + if (options[["tableDifAnalysisSlip"]] && options[["model"]] == "4PL") { |
| 951 | + parameters <- c(parameters, "u") |
| 952 | + } |
| 953 | + } else { |
| 954 | + all_parameters <- colnames(state[["coefficients"]]) |
| 955 | + if (options[["tableDifAnalysisDifficulty"]]) { |
| 956 | + if (options[["model"]] %in% c("rsm", "grsm")) { |
| 957 | + parameters <- c(parameters, "c") |
| 958 | + } else if (options[["model"]] == "nominal") { |
| 959 | + colnames_diff <- colnames(state[["coefficients"]])[grep("c", colnames(state[["coefficients"]]))] |
| 960 | + colnames_diff <- gsub("c", "", colnames_diff) |
| 961 | + colnames_diff <- paste0("d", as.numeric(colnames_diff) - 1) |
| 962 | + parameters <- c(parameters, colnames_diff) |
| 963 | + } else { |
| 964 | + colnames_diff <- colnames(state[["coefficients"]])[grep("b", colnames(state[["coefficients"]]))] |
| 965 | + colnames_diff <- gsub("b", "d", colnames_diff) |
| 966 | + parameters <- c(parameters, colnames_diff) |
| 967 | + } |
| 968 | + } |
| 969 | + if (options[["tableDifAnalysisDiscrimination"]] && options[["model"]] %in% c("gpcm", "grsm", "graded", "nominal")) { |
| 970 | + if (options[["model"]] == "nominal") { |
| 971 | + colnames_disc <- colnames(state[["coefficients"]])[grep("a", colnames(state[["coefficients"]]))] |
| 972 | + colnames_disc <- gsub("a", "", colnames_disc) |
| 973 | + colnames_disc <- paste0("ak", as.numeric(colnames_disc) - 1) |
| 974 | + parameters <- c(parameters, colnames_disc) |
| 975 | + } else { |
| 976 | + parameters <- c(parameters, "a1") |
| 977 | + } |
| 978 | + } |
| 979 | + if (options[["tableDifAnalysisThreshold"]] && options[["model"]] %in% c("rsm", "grsm")) { |
| 980 | + colnames_tresh <- colnames(state[["coefficients"]])[grep("b", colnames(state[["coefficients"]]))] |
| 981 | + parameters <- c(parameters, colnames_tresh) |
| 982 | + } |
950 | 983 | } |
951 | 984 | if (length(parameters) == 0) { |
952 | 985 | tb$setError(gettext("DIf-analysis not possible: Select at least one parameter to test.")) |
953 | 986 | return() |
954 | 987 | } |
955 | | - state <- .irtIRTStateBayesian(dataset, options, jaspResults) |
956 | 988 | fit <- mirt::multipleGroup(data = state[["items"]], model = 1, itemtype = options[["model"]], group = dataset[[options[["groupingVariable"]]]], SE = FALSE, verbose = FALSE, TOL = options[["emTolerance"]], technical = list(NCYCLES = options[["emIterations"]], set.seed = options[["seed"]])) |
| 989 | + print(unique(unlist(lapply(mirt::coef(fit)[[1]][seq_len(length(options[["items"]]))], colnames)))) |
| 990 | + print(parameters) |
957 | 991 | dif <- mirt::DIF(fit, which.par = parameters) |
958 | 992 | tb[["item"]] <- options[["items"]] |
959 | 993 | tb[["aic"]] <- dif[["AIC"]] |
|
0 commit comments