R中add1()-command的作用域 [英] scope from add1()-command in R

查看:389
本文介绍了R中add1()-command的作用域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定如何使用add1命令.假设我有一个模型

I am not sure how to use the add1 command. Suppose I have a model

y=b0+b1*x1

,我想知道添加更多自变量是否更合适.现在,我将测试所有模型

and I would like to know if it would be a better fit to add more independent variables. Now I would test all models

y=b0+b1*x1+b2*x2

具有不同的x2(我不同的自变量). add1命令某种程度上需要一个作用域".我不确定那是什么. 我找不到如何使用add1命令.如果我这样做:

with different x2 (my different independent variables). The add1 command somehow needs a "scope". I am not sure of, what that is. I could not find out how to use the add1 command. If I do this:

add1(fittedmodel)

我得到一个错误,所以我想我需要指定要手动使用的变量. 很好,那实际上是我想要的,但是不确定是否是那样.如果我愿意

I get an error, so I suppose I need to specify which variable I want to use by hand. That is fine, that's actually what I wanted but wasn't sure if it is like that. If I do

add1(fittedmodel, scope=x1+x2, test="F")

为x2插入特定的变量, 我得到以下输出:

inserting a specific variable for x2, I get the following output:

单项添加

型号:

sl ~ le
       Df  Sum of Sq     RSS     AIC F value Pr(>F)
<none>               0.51211 -523.44               
ky      1 0.00097796 0.51113 -521.63  0.1856 0.6676

,我不确定这是否是我想要的.它描述的模型sl~le不是我想要的(sl~le+ky),但这可能仅仅是它开始的模型? 然后我不知道<none>是什么意思. 现在是否意味着将模型sl~le与模型sl~le进行比较的F检验值为0.1856?还是我将输出解释错误?

and I am not sure of if this is what I want. The Model it describes sl~le is not what I wanted (sl~le+ky), but that may just be the model it starts of with? Then I do not know what the <none> means. Would this now mean that the F-Test-value for comparing model sl~le to model sl~le is 0.1856? Or do I interpret the output wrong?

然后,即使这是正确的,我该如何对模型'sl〜le + ky + le:ky'进行操作,也就是说,是否确实存在交互作用? 我似乎不太了解add1()命令中的scope参数,但是我需要它,因为没有它,add1()不能正常工作!

Then, even if this is right, how do I do it for a model 'sl~le+ky+le:ky', that is if I do have an interaction? I don't seem to understand the scope parameter in the add1() command, but I need it, because without it, add1() does not work!

推荐答案

在这种情况下,您可以使用drop1()函数.当我们进行向后选择时,使用drop1(fittedmodel).它从完整模型开始,并在删除一个预测变量时针对每种情况返回p值.因此,如果只比较两个预测变量,则drop1()函数会做得更好.

In which case you could have used drop1() function. drop1(fittedmodel) is used when we do backward selection. It starts from full model, and returns p-value for each case when one predictor is dropped. So if you have only 2 predictors to compare, drop1() function would have done a better job.

这篇关于R中add1()-command的作用域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆