我正在尝试使用R中的Firth回归拟合模型。我正在使用logistf库。具体地说,问题围绕着Backward和Forward函数中关联的Scope语句。我无法让R识别我希望关联的变量列表。
范围要求什么格式?我尝试了以下方法:
variables <- c(CogComplex, Depression, Pres, Hon, Fem, Age)
fit6 <- logistf (data = DiffScores, TurnoutMedStan ~ CogComplex + Depression + Pres + Hon + Fem + Age, dataout = TRUE)
前进(fit6,变量)
OR
variables <- c('CogComplex', 'Depression', 'Pres', 'Hon', 'Fem', 'Age')
fit6 <- logistf (data = DiffScores, TurnoutMedStan ~ CogComplex + Depression + Pres + Hon + Fem + Age, dataout = TRUE)
前进(fit6,变量)
我最终遇到以下错误
> forward(fit6, scope=variables)
Step 0 : starting model
Error in terms.formula(tmp, simplify = TRUE) :
invalid model formula in ExtractVars
> variables <- c(CogComplex, Depression, Pres, Hon, Fem, Age)
> forward(fit6, scope=variables)
Error in colnames(object$data)[scope] :
only 0's may be mixed with negative subscripts