0

我想对 vglm 对象执行逐步回归。由于它们是 S4,因此类似的方法step()行不通。我发现step4()and step4vglm()in VGAM,它看起来像step(), 但对于S4对象的等价物。但是,我一直收到同样的错误Error in Deviance.categorical.data.vgam(mu = mu, y = y, w = w, residuals = residuals, : arguments 'y' and 'mu' must have at least 2 columns。我无法理解和解决这个问题。有谁知道出了什么问题?还是有一种方法可以转换S4S3并仅用于step()执行逐步回归?如果有帮助,我附上了一个代表。

##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

reprex 包于 2021-10-26 创建(v2.0.1)

4

0 回答 0