Skip to content

predictions for glm with se.fit = TRUE throws an error #95

@vandenman

Description

@vandenman

Describe the bug
Calling predict with se.fit = TRUE on an object of class basglm (logistic regression) throws the error:

Error in array(STATS, dims[perm]) : 
  'data' must be of a vector type, was 'NULL'
In addition: Warning message:
In max(cumDim[cumDim <= lstats]) :
  no non-missing arguments to max; returning -Inf

To Reproduce

library(BAS)
library(MASS)
data(Pima.tr)


# enumeration  with default method="BAS"
pima.cch = bas.glm(type ~ ., data=Pima.tr, n.models= 2^7,
                   method="BAS",
                   betaprior=CCH(a=1, b=532/2, s=0), family=binomial(),
                   modelprior=beta.binomial(1,1))

try(predict(pima.cch, newdata=Pima.tr[1:10,], type="response", se.fit = TRUE))
#> Warning in max(cumDim[cumDim <= lstats]): no non-missing arguments to max;
#> returning -Inf
#> Error in array(STATS, dims[perm]) : 
#>   'data' must be of a vector type, was 'NULL'

glm_fit <- glm(type ~ ., data = Pima.tr, family = binomial())
predict(glm_fit, newdata = Pima.tr[1:10,], type = "response", se.fit = TRUE)
#> $fit
#>          1          2          3          4          5          6          7 
#> 0.06318139 0.81393846 0.07347296 0.65233283 0.03649077 0.32099021 0.06759699 
#>          8          9         10 
#> 0.64708680 0.58782564 0.77333901 
#> 
#> $se.fit
#>          1          2          3          4          5          6          7 
#> 0.02570134 0.10513608 0.03782698 0.13935359 0.01818461 0.11389870 0.02771771 
#>          8          9         10 
#> 0.16317946 0.19040925 0.10630820 
#> 
#> $residual.scale
#> [1] 1

Created on 2025-06-10 with reprex v2.1.1

Expected behavior
Either:

  • An intended error, if se.fit = TRUE is not supported.
  • Actual results. The reprex above shows that stats::glm does produce a result, but I'm not sure how straightforward this is for the Bayesian version.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions