Generalized Linear Models
(subscript) logical subscript too longDebug
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 |
|---|
|
| Info | Value | Comment |
|---|
| Model Type | | Multinomial | | Model for categorical y | |
| Link function | | logit | | Log of the odd of each category over y=0 | |
| Distribution | | Multinomial | | Multi-event distribution of y | |
| R-squared | | 0.0409 | | Proportion of reduction of error | |
| AIC | | 1039.3274 | | Less is better | |
| Deviance | | 1009.3274 | | Less is better | |
| Converged | | yes | | A solution was found | |
|
| Analisys of Deviance: Omnibus Tests |
|---|
|
| | X² | df | p |
|---|
| admit | | 22.12 | | 3 | | < .001 | |
| gre | | 5.05 | | 3 | | 0.168 | |
| gpa | | 8.62 | | 3 | | 0.035 | |
| gre ✻ gpa | | 7.41 | | 3 | | 0.060 | |
|
| Model Coefficients (Parameter Estimates) |
|---|
| 95% Confidence Interval | |
|---|
| Response Groups | | Contrast | Estimate | SE | Lower | Upper | exp(B) | z | p |
|---|
| 2 - 1 | | (Intercept) | | Intercept | | 0.97180 | | 0.16914 | | 0.64028 | | 1.30331 | | 2.643 | | 5.745 | | < .001 | |
| | | admit1 | | 1 - ( 0, 1 ) | | -0.35940 | | 0.15929 | | -0.67160 | | -0.04720 | | 0.698 | | -2.256 | | 0.024 | |
| | | gre | | gre | | -2.67e−4 | | 0.00149 | | -0.00319 | | 0.00265 | | 1.000 | | -0.180 | | 0.858 | |
| | | gpa | | gpa | | -0.39407 | | 0.44879 | | -1.27367 | | 0.48554 | | 0.674 | | -0.878 | | 0.380 | |
| | | gre ✻ gpa | | gre ✻ gpa | | -0.00575 | | 0.00354 | | -0.01269 | | 0.00119 | | 0.994 | | -1.624 | | 0.104 | |
| 3 - 1 | | (Intercept) | | Intercept | | 0.48929 | | 0.18915 | | 0.11857 | | 0.86001 | | 1.631 | | 2.587 | | 0.010 | |
| | | admit1 | | 1 - ( 0, 1 ) | | -0.67344 | | 0.17292 | | -1.01235 | | -0.33453 | | 0.510 | | -3.895 | | < .001 | |
| | | gre | | gre | | -0.00264 | | 0.00157 | | -0.00572 | | 4.46e-4 | | 0.997 | | -1.676 | | 0.094 | |
| | | gpa | | gpa | | 0.60226 | | 0.48436 | | -0.34708 | | 1.55159 | | 1.826 | | 1.243 | | 0.214 | |
| | | gre ✻ gpa | | gre ✻ gpa | | 5.68e-4 | | 0.00360 | | -0.00648 | | 0.00762 | | 1.001 | | 0.158 | | 0.875 | |
| 4 - 1 | | (Intercept) | | Intercept | | -0.04648 | | 0.21684 | | -0.47148 | | 0.37852 | | 0.955 | | -0.214 | | 0.830 | |
| | | admit1 | | 1 - ( 0, 1 ) | | -0.79934 | | 0.21011 | | -1.21115 | | -0.38753 | | 0.450 | | -3.804 | | < .001 | |
| | | gre | | gre | | -0.00193 | | 0.00177 | | -0.00541 | | 0.00155 | | 0.998 | | -1.089 | | 0.276 | |
| | | gpa | | gpa | | -0.42473 | | 0.53138 | | -1.46622 | | 0.61676 | | 0.654 | | -0.799 | | 0.424 | |
| | | gre ✻ gpa | | gre ✻ gpa | | -0.00688 | | 0.00435 | | -0.01541 | | 0.00164 | | 0.993 | | -1.583 | | 0.113 | |
|
Simple Effects Analysis of Deviance
| Simple effects of admit computed for gpa at -0.38 |
|---|
|
| Effect | Moderator Levels | X² | df | p |
|---|
| admit | | gre at -115.52 | | 22.1 | | 3 | | < .001 | |
| admit | | gre at 0 | | 22.1 | | 3 | | < .001 | |
| admit | | gre at 115.52 | | 22.1 | | 3 | | < .001 | |
|
| Simple effects of admit computed for gpa at 0 |
|---|
|
| Effect | Moderator Levels | X² | df | p |
|---|
| admit | | gre at -115.52 | | 22.1 | | 3 | | < .001 | |
| admit | | gre at 0 | | 22.1 | | 3 | | < .001 | |
| admit | | gre at 115.52 | | 22.1 | | 3 | | < .001 | |
|
| Simple effects of admit computed for gpa at 0.38 |
|---|
|
| Effect | Moderator Levels | X² | df | p |
|---|
| admit | | gre at -115.52 | | 22.1 | | 3 | | < .001 | |
| admit | | gre at 0 | | 22.1 | | 3 | | < .001 | |
| admit | | gre at 115.52 | | 22.1 | | 3 | | < .001 | |
|
Simple Effects Parameters
| Simple effects of admit computed for gpa at -0.38 |
|---|
|
| Response Groups | Effect | Moderator Levels | Estimate | SE | exp(B) | z | p |
|---|
| 2 - 1 | | admit | | gre at -115.52 | | -0.359 | | 0.159 | | 0.698 | | -2.26 | | 0.024 | |
| | | admit | | gre at 0 | | -0.359 | | 0.159 | | 0.698 | | -2.26 | | 0.024 | |
| | | admit | | gre at 115.52 | | -0.359 | | 0.159 | | 0.698 | | -2.26 | | 0.024 | |
| 3 - 1 | | admit | | gre at -115.52 | | -0.673 | | 0.173 | | 0.510 | | -3.89 | | < .001 | |
| | | admit | | gre at 0 | | -0.673 | | 0.173 | | 0.510 | | -3.89 | | < .001 | |
| | | admit | | gre at 115.52 | | -0.673 | | 0.173 | | 0.510 | | -3.89 | | < .001 | |
| 4 - 1 | | admit | | gre at -115.52 | | -0.799 | | 0.210 | | 0.450 | | -3.80 | | < .001 | |
| | | admit | | gre at 0 | | -0.799 | | 0.210 | | 0.450 | | -3.80 | | < .001 | |
| | | admit | | gre at 115.52 | | -0.799 | | 0.210 | | 0.450 | | -3.80 | | < .001 | |
|
| Simple effects of admit computed for gpa at 0 |
|---|
|
| Response Groups | Effect | Moderator Levels | Estimate | SE | exp(B) | z | p |
|---|
| 2 - 1 | | admit | | gre at -115.52 | | -0.359 | | 0.159 | | 0.698 | | -2.26 | | 0.024 | |
| | | admit | | gre at 0 | | -0.359 | | 0.159 | | 0.698 | | -2.26 | | 0.024 | |
| | | admit | | gre at 115.52 | | -0.359 | | 0.159 | | 0.698 | | -2.26 | | 0.024 | |
| 3 - 1 | | admit | | gre at -115.52 | | -0.673 | | 0.173 | | 0.510 | | -3.89 | | < .001 | |
| | | admit | | gre at 0 | | -0.673 | | 0.173 | | 0.510 | | -3.89 | | < .001 | |
| | | admit | | gre at 115.52 | | -0.673 | | 0.173 | | 0.510 | | -3.89 | | < .001 | |
| 4 - 1 | | admit | | gre at -115.52 | | -0.799 | | 0.210 | | 0.450 | | -3.80 | | < .001 | |
| | | admit | | gre at 0 | | -0.799 | | 0.210 | | 0.450 | | -3.80 | | < .001 | |
| | | admit | | gre at 115.52 | | -0.799 | | 0.210 | | 0.450 | | -3.80 | | < .001 | |
|
| Simple effects of admit computed for gpa at 0.38 |
|---|
|
| Response Groups | Effect | Moderator Levels | Estimate | SE | exp(B) | z | p |
|---|
| 2 - 1 | | admit | | gre at -115.52 | | -0.359 | | 0.159 | | 0.698 | | -2.26 | | 0.024 | |
| | | admit | | gre at 0 | | -0.359 | | 0.159 | | 0.698 | | -2.26 | | 0.024 | |
| | | admit | | gre at 115.52 | | -0.359 | | 0.159 | | 0.698 | | -2.26 | | 0.024 | |
| 3 - 1 | | admit | | gre at -115.52 | | -0.673 | | 0.173 | | 0.510 | | -3.89 | | < .001 | |
| | | admit | | gre at 0 | | -0.673 | | 0.173 | | 0.510 | | -3.89 | | < .001 | |
| | | admit | | gre at 115.52 | | -0.673 | | 0.173 | | 0.510 | | -3.89 | | < .001 | |
| 4 - 1 | | admit | | gre at -115.52 | | -0.799 | | 0.210 | | 0.450 | | -3.80 | | < .001 | |
| | | admit | | gre at 0 | | -0.799 | | 0.210 | | 0.450 | | -3.80 | | < .001 | |
| | | admit | | gre at 115.52 | | -0.799 | | 0.210 | | 0.450 | | -3.80 | | < .001 | |
|
Post Hoc Tests
| Post Hoc Comparisons - admit |
|---|
|
| Response Groups | admit - admit | Difference | SE | test | pbonferroni |
|---|
| 1 | | . | | . | | . | | . | | . | |
| 2 | | . | | . | | . | | . | | . | |
| 3 | | . | | . | | . | | . | | . | |
| 4 | | . | | . | | . | | . | | . | |
|
Estimated Marginal Means
| admit |
|---|
| 95% Confidence Interval |
|---|
| Response Groups | admit | Prob | SE | Lower | Upper |
|---|
| . | | 0 | | . | | . | | . | | . | |
| | | 1 | | . | | . | | . | | . | |
| | | 0 | | . | | . | | . | | . | |
| | | 1 | | . | | . | | . | | . | |
| | | 0 | | . | | . | | . | | . | |
| | | 1 | | . | | . | | . | | . | |
| | | 0 | | . | | . | | . | | . | |
| | | 1 | | . | | . | | . | | . | |
|
Results Plots
gpa = -1 SD

gpa = Mean

gpa = +1 SD
