Stepwise regression on vglm objects: step4() error

I would like to perform stepwise regression on vglm objects. Since they are S4, method like step() wouldn't work. I have found step4() and step4vglm() in VGAM , which look like the equivalents of step() , but for S4 objects. However, I kept getting the same error Error in Deviance.categorical.data.vgam(mu = mu, y = y, w = w, residuals = residuals, : arguments 'y' and 'mu' must have at least 2 columns . I have trouble understanding and fixing this issue. Does anyone know what is wrong? Or is there a way to convert S4 to S3 and just use step() to perform stepwise regression? I have attached a reprex if it helps.

##libraries
library(VGAM)
#> Loading required package: stats4
#> Loading required package: splines

# import data
dff<-list()
dff[[1]] <- data.table::data.table(
                   sbq_1 = c(1L,2L,1L,2L,2L,
                             1L,2L,2L,4L,2L,1L,4L,2L,3L,1L,4L,2L,1L,
                             3L,1L,4L,1L,3L,4L,2L,1L,2L,2L,2L,2L,
                             1L,4L,3L,4L,1L,2L,3L,4L,1L,1L,3L,3L,1L,
                             1L,2L,1L,1L,1L,1L),
                     age = c(53L,32L,47L,58L,
                             34L,29L,57L,25L,38L,29L,51L,50L,37L,33L,
                             41L,36L,49L,38L,32L,51L,37L,36L,37L,39L,
                             55L,55L,45L,25L,24L,27L,26L,57L,47L,30L,
                             37L,39L,38L,34L,38L,56L,39L,43L,49L,39L,48L,
                             44L,63L,61L,46L),
                  gender = c(1L,1L,2L,1L,1L,
                             1L,1L,2L,2L,1L,1L,1L,1L,1L,1L,2L,1L,1L,
                             2L,1L,1L,1L,1L,1L,2L,1L,1L,2L,1L,1L,
                             1L,1L,2L,1L,2L,1L,1L,2L,1L,1L,1L,2L,1L,
                             1L,2L,1L,1L,2L,1L),
               ethnicity = c(2L,2L,2L,2L,2L,
                             2L,2L,2L,2L,2L,2L,1L,1L,2L,2L,2L,2L,2L,
                             2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,
                             2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,2L,
                             2L,2L,2L,2L,2L,2L)
            )

ppom.1 <- vglm(sbq_1 ~ ., family=cumulative(parallel=F~ age), maxit=50, data=dff[[1]])
ppom.2 <- step4(ppom.1)
#> Start:  AIC=135.61
#> sbq_1 ~ age + gender + ethnicity
#> Error in Deviance.categorical.data.vgam(mu = mu, y = y, w = w, residuals = residuals, : arguments 'y' and 'mu' must have at least 2 columns
summary(ppom.2)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'object' in selecting a method for function 'summary': object 'ppom.2' not found

Created on 2021-10-26 by the reprex package (v2.0.1)

Cross-posted here: r - Stepwise regression on vglm objects: step4() error - Stack Overflow. A quick note about cross posting, FAQ: Is it OK if I cross-post?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.