diff --git a/R/glmClassical.R b/R/glmClassical.R index 1e757278..3e569508 100644 --- a/R/glmClassical.R +++ b/R/glmClassical.R @@ -189,10 +189,15 @@ GeneralizedLinearModel <- function(jaspResults, dataset = NULL, options, ...) { glmModels <- .glmComputeModel(jaspResults, dataset, options) hasNuisance <- .hasNuisance(options) if (hasNuisance) { - terms <- rownames(coef(summary(glmModels[["nullModel"]]))) - terms <- jaspBase::gsubInteractionSymbol(terms[terms!="(Intercept)"]) - message <- gettextf("Null model contains nuisance parameters: %s", - paste(terms, collapse = ", ")) + if ((options[["family"]] == "other") & (options[["otherGlmModel"]] %in% c("multinomialLogistic", "ordinalLogistic"))) + termsNullModel <- rownames(VGAM::coef(VGAM::summaryvglm(glmModels[["nullModel"]]))) + else if (options[["otherGlmModel"]] == "firthLogistic") + termsNullModel <- names(coef((glmModels[["nullModel"]]))) + else + termsNullModel <- rownames(coef(summary(glmModels[["nullModel"]]))) + nuisanceTerms <- jaspBase::gsubInteractionSymbol(termsNullModel[!grepl("(Intercept)", termsNullModel, fixed = TRUE)]) + message <- gettextf("Null model contains nuisance parameters: %s.", + paste(nuisanceTerms, collapse = ", ")) jaspResults[["modelSummary"]]$addFootnote(message) } @@ -223,17 +228,17 @@ GeneralizedLinearModel <- function(jaspResults, dataset = NULL, options, ...) { pValue <- 1 - pchisq(chiValue, glmModels[["fullModel"]][["df"]]) } else { - devNullModel <- deviance(glmModels[["nullModel"]]) - aicNullModel <- AIC(glmModels[["nullModel"]]) - bicNullModel <- BIC(glmModels[["nullModel"]]) - dofNullModel <- df.residual(glmModels[["nullModel"]]) + devNullModel <- VGAM::deviance(glmModels[["nullModel"]]) + aicNullModel <- VGAM::AIC(glmModels[["nullModel"]]) + bicNullModel <- VGAM::BIC(glmModels[["nullModel"]]) + dofNullModel <- VGAM::df.residual(glmModels[["nullModel"]]) - devFullModel <- deviance(glmModels[["fullModel"]]) - aicFullModel <- AIC(glmModels[["fullModel"]]) - bicFullModel <- BIC(glmModels[["fullModel"]]) - dofFullModel <- df.residual(glmModels[["fullModel"]]) + devFullModel <- VGAM::deviance(glmModels[["fullModel"]]) + aicFullModel <- VGAM::AIC(glmModels[["fullModel"]]) + bicFullModel <- VGAM::BIC(glmModels[["fullModel"]]) + dofFullModel <- VGAM::df.residual(glmModels[["fullModel"]]) - anovaRes <- anova(glmModels[["nullModel"]], glmModels[["fullModel"]], type = 1) + anovaRes <- VGAM::anova.vglm(glmModels[["nullModel"]], glmModels[["fullModel"]], type = 1) chiValue <- devNullModel - devFullModel pValue <- anovaRes[["Pr(>Chi)"]][[2]] } diff --git a/R/glmCommonFunctions.R b/R/glmCommonFunctions.R index be799579..afe2104e 100644 --- a/R/glmCommonFunctions.R +++ b/R/glmCommonFunctions.R @@ -89,22 +89,22 @@ fullModel <- VGAM::vglm(ff, family = VGAM::multinomial(), data = dataset, - weights = .getWeightVariable(options$weights)) + weights = eval(.getWeightVariable(options$weights))) nullModel <- VGAM::vglm(nf, family = VGAM::multinomial(), data = dataset, - weights = .getWeightVariable(options$weights)) + weights = eval(.getWeightVariable(options$weights))) } if (options$otherGlmModel == "ordinalLogistic") { fullModel <- VGAM::vglm(ff, family = VGAM::cumulative(link = "logitlink", parallel = TRUE), data = dataset, - weights = .getWeightVariable(options$weights)) + weights = eval(.getWeightVariable(options$weights))) nullModel <- VGAM::vglm(nf, family = VGAM::cumulative(link = "logitlink", parallel = TRUE), data = dataset, - weights = .getWeightVariable(options$weights)) + weights = eval(.getWeightVariable(options$weights))) } if (options$otherGlmModel == "firthLogistic") { @@ -112,12 +112,12 @@ data = dataset, pl = TRUE, firth = TRUE, - weights = .getWeightVariable(options$weights)) + weights = eval(.getWeightVariable(options$weights))) nullModel <- logistf::logistf(nf, data = dataset, pl = TRUE, firth = TRUE, - weights = .getWeightVariable(options$weights)) + weights = eval(.getWeightVariable(options$weights))) } } diff --git a/inst/qml/common/GlmInputComponent.qml b/inst/qml/common/GlmInputComponent.qml index e2fb6718..4295706e 100644 --- a/inst/qml/common/GlmInputComponent.qml +++ b/inst/qml/common/GlmInputComponent.qml @@ -24,7 +24,7 @@ import JASP 1.0 // All Analysis forms must be built with the From QML item Group { - property bool otherFamilyNotSelected: family.currentValue !== "other" + property bool otherFamilyNotSelected: family.currentValue !== "other"; VariablesForm { @@ -39,7 +39,7 @@ Group { { name: "dependent" title: qsTr("Dependent variable") - allowedColumns: ["scale","ordinal", "nominal", "nominalText"] + allowedColumns: ["scale", "ordinal", "nominal", "nominalText"] singleVariable: true }