R中的线性模型不合适

我知道标题没有确切说明我的意思,所以让我在这里解释一下。 我在一个数据集上工作,该数据集由给定某种小麦类型(A,B,C,D)的小麦产量组成。现在我在拟合线性模型时的问题是我要拟合:

lm1 = lm(yield ~ type), when doing so R commits the first wheat type(A) and marks it as a global intercept and then estimates influence of all other types on the yield. I know that I can fit a linear model like such: lm2 = lm(yield ~ 0 + type) which will give me estimates of the influence of each type on the yield however what I really want to see is a sort of combination of the two of them.

Is there an option to fit a linear model in R s.t lm3 = lm(yield ~ GlobalIntercept + type) where GlobalIntercept would represent the general intercept of my linear model and then I could see the influence of each type of wheat on that general intercept. So kind of like in the first model though this time we'd estimate the influence of all types of wheat (A,B,C,D) on the general yield.

评论
开始明了
开始明了

根据您提供的信息,我可以推断出您正在将收益率建模为具有四个类别的类型的线性函数。您的期望是截取每种类型的系数。这没有道理。

您正在根据名义变量预测产量。如果要通过截距进行回归,则需要使预测变量具有原点。标称变量的属性是它没有原点。原点表示预测变量的零值。标称变量不能有原点。换句话说,截距(带有连续的预测变量)是指预测变量值为零(在您的情况下,类型的类别为零,实际上是不可能的)时因变量y的值。这就是为什么您的模型将类别之一作为参考类别并为其计算截距的原因。当类别不同于参考类别时,y变量的变化由系数给出。

点赞
评论