Skip to content

Commit

Permalink
implemented suggested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
fqixiang committed Dec 1, 2022
1 parent e9b4ac2 commit 5b78934
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 21 deletions.
31 changes: 18 additions & 13 deletions R/glmClassical.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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]]
}
Expand Down
12 changes: 6 additions & 6 deletions R/glmCommonFunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,35 +89,35 @@
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") {
fullModel <- logistf::logistf(ff,
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)))
}
}

Expand Down
4 changes: 2 additions & 2 deletions inst/qml/common/GlmInputComponent.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -39,7 +39,7 @@ Group {
{
name: "dependent"
title: qsTr("Dependent variable")
allowedColumns: ["scale","ordinal", "nominal", "nominalText"]
allowedColumns: ["scale", "ordinal", "nominal", "nominalText"]
singleVariable: true
}

Expand Down

0 comments on commit 5b78934

Please sign in to comment.