r - R - 使用 stepAIC() 函数时提取最终模型中的变量列表
问题描述
我想在使用该
stepAIC()
函数时提取最终模型中的变量名称列表。
我试过了:
attr(terms(backward.aic), "predvars")
但这并没有给我一个清单。
解决方案
上市怎么样term.labels
?
list(attr(terms(quine.stp), "term.labels"))
# [[1]]
# [1] "Eth" "Sex" "Age" "Lrn" "Eth:Sex"
# [6] "Eth:Age" "Eth:Lrn" "Sex:Age" "Sex:Lrn" "Age:Lrn"
# [11] "Eth:Sex:Lrn" "Eth:Age:Lrn"
数据
library(MASS)
quine.hi <- aov(log(Days + 2.5) ~ .^4, quine)
quine.nxt <- update(quine.hi, . ~ . - Eth:Sex:Age:Lrn)
quine.stp <- stepAIC(quine.nxt,
scope = list(upper = ~Eth*Sex*Age*Lrn, lower = ~1),
trace = FALSE)
推荐阅读
- r - 使用 lapply (s) 的参数命名由 lapply(s,fun) 创建的列表 (L) 的元素
- html - Beautifulsoup Webscraping:如何使用 javascript 获取信息?
- python - 在 Python 中解析 JSON 中的所有字节数组值
- javascript - 基于用户 id 的复选框,它只保存所有复选框中的一个 id
- python - 如何处理数据框中列内的 json 数据集
- android - 如何在 saveInstanceState 中保存可选的 GridLayoutManaer RecyclerView 的 UI 状态
- angular - Angular 6 Route URL String Parameter in AppComponent
- laravel - Laravel Eloquent - 如何查询 NOT LIKE?
- c# - 如何在 JsonConverter 的自定义 WriteJson 中保留默认的 Json.Net 字段,如 $id 和 $type?
- webpack - Typescript,Webpack:未捕获的 TypeError:Object(...) 不是函数