From eeb4d564d11e8254fafa1765160c4d70f7b9ab0a Mon Sep 17 00:00:00 2001 From: Qixiang Fang Date: Tue, 1 Nov 2022 15:01:51 +0100 Subject: [PATCH] fixed unit test error --- R/glmClassical.R | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/R/glmClassical.R b/R/glmClassical.R index cc036ecc..1e757278 100644 --- a/R/glmClassical.R +++ b/R/glmClassical.R @@ -316,12 +316,16 @@ GeneralizedLinearModel <- function(jaspResults, dataset = NULL, options, ...) { if (options[["otherGlmModel"]] == "firthLogistic") { dev <- modelObj[["loglik"]]["full"]*-2 pearsonResid <- (modelObj[['y']] - modelObj[["predict"]])/sqrt(modelObj[["predict"]]*(1-modelObj[["predict"]])) - pearson <- sum(pearsonRes^2) + pearson <- sum(pearsonResid^2) dof <- modelObj[["n"]] - modelObj[["df"]] } else { + + if (options[["family"]] == "other") + pearson <- sum(VGAM::residuals(modelObj, type = "pearson")^2) + else + pearson <- sum(residuals(modelObj, type = "pearson")^2) dev <- deviance(modelObj) - pearson <- sum(resid(modelObj, type = "pearson")^2) dof <- df.residual(modelObj) } @@ -394,7 +398,7 @@ GeneralizedLinearModel <- function(jaspResults, dataset = NULL, options, ...) { fullModel <- glmModels[["fullModel"]] if ((options[["family"]] == "other") & (options[["otherGlmModel"]] %in% c("multinomialLogistic", "ordinalLogistic"))) - modelSummary <- coef(summaryvglm(fullModel)) + modelSummary <- VGAM::coef(VGAM::summaryvglm(fullModel)) if (options[["otherGlmModel"]] == "firthLogistic") modelSummary <- cbind(coef(fullModel), sqrt(diag(fullModel$var)), qchisq(1 - fullModel$prob, 1), fullModel$prob) @@ -437,7 +441,7 @@ GeneralizedLinearModel <- function(jaspResults, dataset = NULL, options, ...) { if (options[["otherGlmModel"]] == "ordinalLogistic") { dv <- options$dependent dvLevels <- paste(paste(seq(1, length(dv)), levels(dataset[[dv]]), sep = ":"), collapse = ", ") - linearPredictors <- paste(summaryvglm(fullModel)@misc$predictors.names, collapse = ", ") + linearPredictors <- paste(VGAM::summaryvglm(fullModel)@misc$predictors.names, collapse = ", ") jaspResults[["estimatesTable"]]$addFootnote(gettextf("%1$s levels: %2$s. Linear predictors: %3$s.", dv, dvLevels, linearPredictors)) }