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

查看:38
本文介绍了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),但这可能只是它开始的模型?然后我不知道 是什么意思.这是否意味着将模型 sl~le 与模型 sl~le 进行比较的 F-Test 值为 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 值.因此,如果您只有 2 个预测变量可供比较,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天全站免登陆