Partial residual plots for linear model including an interaction term

后端 未结 2 1495
天涯浪人
天涯浪人 2021-01-14 10:48

My model includes one response variable, five predictors and one interaction term for predictor_1 and predictor_2. I would like to plot partial residual plots for every pred

2条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-14 11:12

    Another way to do this is to put the interaction term in as a separate variable (which avoids hacking the code for crPlot(...)).

    df <- data.frame(R,P1,P2,P1.P2=P1*P2)
    lm.fit1 <- lm(R ~ ., df)
    summary(lm.fit1)
    crPlots(lm.fit1)
    

    Note that summary(lm.fit1) yeilds exactly the same result as summary(lm(R~P1*P2,df)).

提交回复
热议问题