我刚刚开始进行线性建模。我有以下回归者
regressor=lm(Profit~R.D.Spend+Administration+Marketing.Spend+State,data=dataset)
现在有三个州级别。
> levels(dataset$State)
[1] "1" "2" "3"
以下是我的模型的输出,我只需要从中删除state2。我该怎么做?
> summary(regressor)
Call:
lm(formula = Profit ~ R.D.Spend + Administration + Marketing.Spend +
State, data = dataset)
Residuals:
Min 1Q Median 3Q Max
-33504 -4736 90 6672 17338
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 5.013e+04 6.885e+03 7.281 4.44e-09 ***
R.D.Spend 8.060e-01 4.641e-02 17.369 < 2e-16 ***
Administration -2.700e-02 5.223e-02 -0.517 0.608
Marketing.Spend 2.698e-02 1.714e-02 1.574 0.123
State2 1.988e+02 3.371e+03 0.059 0.953
State3 -4.189e+01 3.256e+03 -0.013 0.990
答案 0 :(得分:-1)
这应该这样做:
regressor<-update(regressor,~.-State2)
summary(regressor)