首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >强迫步骤()保持一定的价值

强迫步骤()保持一定的价值
EN

Stack Overflow用户
提问于 2014-03-22 16:28:16
回答 1查看 4.8K关注 0票数 2

我用step()来找一个模型来根据其他变量来调整分数。因此,我的完整模型是:

代码语言:javascript
复制
mod<-lm(Adjusted.score ~ original.score + X1 + X2 + X3 + ... + X10)

我需要将变量original.score保留在最后的模型中,这是合乎逻辑的,但是step()总是忽略它。有没有办法强迫step()保留变量original.score,并找到其他变量的最佳组合来陪伴它?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-03-22 16:35:12

您是否正在寻找这个(来自?step):

代码语言:javascript
复制
The set of models searched is determined by the ‘scope’ argument.
The right-hand-side of its ‘lower’ component is always included in
the model, and right-hand-side of the model is included in the
‘upper’ component.  If ‘scope’ is a single formula, it specifies
the ‘upper’ component, and the ‘lower’ model is empty.  If ‘scope’
is missing, the initial model is used as the ‘upper’ model.

Models specified by ‘scope’ can be templates to update ‘object’ as
used by ‘update.formula’.  So using ‘.’ in a ‘scope’ formula means
‘what is already there’, with ‘.^2’ indicating all interactions of
existing terms.

回应你的评论:我以前没有做过这类事情,但下面的一个小例子似乎能满足你的要求:

代码语言:javascript
复制
x = setNames(lapply(1:5, function (x) runif(100)), letters[1:5])
step(lmObj, scope=list(lower=as.formula(a ~ b), upper=as.formula(a ~ .)))
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22580293

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档