Generalized Linear Models

(subscript) logical subscript too long

Debug

Error in X[ii, ii, drop = FALSE]: (subscript) logical subscript too long

private$.run()
suppressWarnings({
    dep <- self$options$dep
    factors <- self$options$factors
    covs <- self$options$covs
    modelType <- self$options$modelSelection
    modelTerms <- private$.modelTerms()
    if (is.null(dep) || length(modelTerms) == 0) 
        return()
    base::options(contrasts = c("contr.sum", "contr.poly"))
    data <- private$.cleanData()
    data <- mf.checkData(dep, data, modelType)
    if (!is.data.frame(data)) 
        reject(data)
    for (factorName in factors) {
        lvls <- base::levels(data[[factorName]])
        if (length(lvls) == 1) 
            reject("Factor '{}' contains only a single level", factorName = factorName)
        else if (length(lvls) == 0) 
            reject("Factor '{}' contains no data", factorName = factorName)
    }
    anovaTable <- self$results$main
    estimatesTable <- self$results$estimates
    infoTable <- self$results$info
    formula <- jmvcore::constructFormula(dep, modelTerms)
    formula <- stats::as.formula(formula)
    model <- try(private$.estimate(formula, data))
    if (isError(model)) {
        message <- extractErrorMessage(model)
        reject(message)
    }
    private$.model <- model
    self$results$.setModel(model)
    infoTable$setRow(rowKey = "r2", list(value = mi.rsquared(model)))
    infoTable$setRow(rowKey = "aic", list(value = mf.getAIC(model)))
    infoTable$setRow(rowKey = "dev", list(value = model$deviance))
    infoTable$setRow(rowKey = "conv", mi.converged(model))
    anovaResults <- try(mf.anova(model))
    if (isError(anovaResults)) {
        message <- extractErrorMessage(anovaResults)
        anovaTable$setNote("anocrash", message)
        STOP <- TRUE
    }
    rowNames <- rownames(anovaResults)
    for (i in seq_along(rowNames)) {
        rowName <- rowNames[i]
        tableRow <- anovaResults[i, ]
        colnames(tableRow) <- TCONV[["glm.f"]]
        anovaTable$setRow(rowNo = i, tableRow)
    }
    if (mi.aliased(model)) {
        infoTable$setRow(rowKey = "conv", list(comm = "Results may be misleading because of aliased coefficients. See Tables notes"))
        anovaTable$setNote("aliased", WARNS["ano.aliased"])
        estimatesTable$setNote("aliased", WARNS["ano.aliased"])
    }
    parameters <- try(mf.summary(model))
    if (isError(parameters)) {
        message <- extractErrorMessage(parameters)
        estimatesTable$setNote("sumcrash", message)
        STOP <- T
    }
    ciWidth <- self$options$paramCIWidth/100
    if (self$options$showParamsCI) {
        citry <- try({
            ci <- mf.confint(model, level = ciWidth)
            colnames(ci) <- c("cilow", "cihig")
            parameters <- cbind(parameters, ci)
        })
        if (isError(citry)) {
            message <- extractErrorMessage(citry)
            infoTable$setRow(rowKey = "conv", list(value = "no"))
            estimatesTable$setNote("cicrash", paste(message, ". CI cannot be computed"))
        }
    }
    for (i in 1:nrow(parameters)) {
        estimatesTable$setRow(rowNo = i, parameters[i, ])
    }
    if (STOP) 
        return()
    private$.populateSimple(private$.model)
    private$.prepareDescPlots(private$.model)
    private$.populatePostHoc(model)
    private$.populateDescriptives(model)
})
withCallingHandlers(expr, warning = function(w) invokeRestart("muffleWarning"))
private$.populatePostHoc(model)
suppressWarnings({
    none <- mf.posthoc(model, ph, "none")
    bonferroni <- mf.posthoc(model, ph, "bonferroni")
    holm <- mf.posthoc(model, ph, "holm")
})
withCallingHandlers(expr, warning = function(w) invokeRestart("muffleWarning"))
mf.posthoc(model, ph, "none")
.posthoc.multinom(model, ph, "none")
emmeans::emmeans(model, tterm, transform = "response")
ref_grid(object, ...)
regrid(result, transform = transform)
.est.se.df(object, do.se = TRUE)
t(apply(object@linfct[use.elts, , drop = FALSE], 1, function(x) {
    if (!any(is.na(x)) && estimability::is.estble(x, object@nbasis, tol)) {
        x = x[active]
        est = sum(bhat * x)
        if (do.se) {
            se = sqrt(.qf.non0(object@V, x))
            df = object@dffun(x, object@dfargs)
        }
        else se = df = 0
        c(est, se, df)
    }
    else c(NA, NA, NA)
}))
apply(object@linfct[use.elts, , drop = FALSE], 1, function(x) {
    if (!any(is.na(x)) && estimability::is.estble(x, object@nbasis, tol)) {
        x = x[active]
        est = sum(bhat * x)
        if (do.se) {
            se = sqrt(.qf.non0(object@V, x))
            df = object@dffun(x, object@dfargs)
        }
        else se = df = 0
        c(est, se, df)
    }
    else c(NA, NA, NA)
})
FUN(newX[, i], ...)
.qf.non0(object@V, x)
Model Info
InfoValueComment
Model TypeMultinomialModel for categorical y
Link functionlogitLog of the odd of each category over y=0
DistributionMultinomialMulti-event distribution of y
R-squared0.0409Proportion of reduction of error
AIC1039.3274Less is better
Deviance1009.3274Less is better
ConvergedyesA solution was found

 

Analisys of Deviance: Omnibus Tests
 dfp
admit22.123< .001
gre5.0530.168
gpa8.6230.035
gre ✻ gpa7.4130.060

 

Model Coefficients (Parameter Estimates)
95% Confidence Interval
Response Groups ContrastEstimateSELowerUpperexp(B)zp
2 - 1(Intercept)Intercept0.971800.169140.640281.303312.6435.745< .001
 admit11 - ( 0, 1 )-0.359400.15929-0.67160-0.047200.698-2.2560.024
 gregre-2.67e−40.00149-0.003190.002651.000-0.1800.858
 gpagpa-0.394070.44879-1.273670.485540.674-0.8780.380
 gre ✻ gpagre ✻ gpa-0.005750.00354-0.012690.001190.994-1.6240.104
3 - 1(Intercept)Intercept0.489290.189150.118570.860011.6312.5870.010
 admit11 - ( 0, 1 )-0.673440.17292-1.01235-0.334530.510-3.895< .001
 gregre-0.002640.00157-0.005724.46e-40.997-1.6760.094
 gpagpa0.602260.48436-0.347081.551591.8261.2430.214
 gre ✻ gpagre ✻ gpa5.68e-40.00360-0.006480.007621.0010.1580.875
4 - 1(Intercept)Intercept-0.046480.21684-0.471480.378520.955-0.2140.830
 admit11 - ( 0, 1 )-0.799340.21011-1.21115-0.387530.450-3.804< .001
 gregre-0.001930.00177-0.005410.001550.998-1.0890.276
 gpagpa-0.424730.53138-1.466220.616760.654-0.7990.424
 gre ✻ gpagre ✻ gpa-0.006880.00435-0.015410.001640.993-1.5830.113

 

Simple Effects Analysis of Deviance

Simple effects of admit computed for gpa at -0.38
EffectModerator Levelsdfp
admitgre at -115.5222.13< .001
admitgre at 022.13< .001
admitgre at 115.5222.13< .001

 

Simple effects of admit computed for gpa at 0
EffectModerator Levelsdfp
admitgre at -115.5222.13< .001
admitgre at 022.13< .001
admitgre at 115.5222.13< .001

 

Simple effects of admit computed for gpa at 0.38
EffectModerator Levelsdfp
admitgre at -115.5222.13< .001
admitgre at 022.13< .001
admitgre at 115.5222.13< .001

 

Simple Effects Parameters

Simple effects of admit computed for gpa at -0.38
Response GroupsEffectModerator LevelsEstimateSEexp(B)zp
2 - 1admitgre at -115.52-0.3590.1590.698-2.260.024
 admitgre at 0-0.3590.1590.698-2.260.024
 admitgre at 115.52-0.3590.1590.698-2.260.024
3 - 1admitgre at -115.52-0.6730.1730.510-3.89< .001
 admitgre at 0-0.6730.1730.510-3.89< .001
 admitgre at 115.52-0.6730.1730.510-3.89< .001
4 - 1admitgre at -115.52-0.7990.2100.450-3.80< .001
 admitgre at 0-0.7990.2100.450-3.80< .001
 admitgre at 115.52-0.7990.2100.450-3.80< .001

 

Simple effects of admit computed for gpa at 0
Response GroupsEffectModerator LevelsEstimateSEexp(B)zp
2 - 1admitgre at -115.52-0.3590.1590.698-2.260.024
 admitgre at 0-0.3590.1590.698-2.260.024
 admitgre at 115.52-0.3590.1590.698-2.260.024
3 - 1admitgre at -115.52-0.6730.1730.510-3.89< .001
 admitgre at 0-0.6730.1730.510-3.89< .001
 admitgre at 115.52-0.6730.1730.510-3.89< .001
4 - 1admitgre at -115.52-0.7990.2100.450-3.80< .001
 admitgre at 0-0.7990.2100.450-3.80< .001
 admitgre at 115.52-0.7990.2100.450-3.80< .001

 

Simple effects of admit computed for gpa at 0.38
Response GroupsEffectModerator LevelsEstimateSEexp(B)zp
2 - 1admitgre at -115.52-0.3590.1590.698-2.260.024
 admitgre at 0-0.3590.1590.698-2.260.024
 admitgre at 115.52-0.3590.1590.698-2.260.024
3 - 1admitgre at -115.52-0.6730.1730.510-3.89< .001
 admitgre at 0-0.6730.1730.510-3.89< .001
 admitgre at 115.52-0.6730.1730.510-3.89< .001
4 - 1admitgre at -115.52-0.7990.2100.450-3.80< .001
 admitgre at 0-0.7990.2100.450-3.80< .001
 admitgre at 115.52-0.7990.2100.450-3.80< .001

 

Post Hoc Tests

Post Hoc Comparisons - admit
Response Groupsadmit - admitDifferenceSEtestpbonferroni
1.....
2.....
3.....
4.....

 

Estimated Marginal Means

admit
95% Confidence Interval
Response GroupsadmitProbSELowerUpper
.0....
 1....
 0....
 1....
 0....
 1....
 0....
 1....

 

Results Plots

gpa = -1 SD

gpa = Mean

gpa = +1 SD