2017-10-05 71 views
0

说我适合的模型如下fit = lm(Y ~ X + Dummy1 + Dummy2)提取物型号

我怎样才能提取回归为特定的虚拟变量?

我希望能做到像下面来绘制所有的回归:

plot(...) 
abline(extracted.lm.dummy1) 
abline(extracted.lm.dummy2) 
+0

还有库(效果);图(allEffects(FIT))。 – 5ayat

回答

2

我将调查sjPlot包。 Here is the documentationsjp.lm,可用于以各种方式可视化线性模型。该软件包还有一些用于模型表格摘要的好工具。

一个例子:

library(sjPlot) 
library(dplyr) 

# add a second categorical variable to the iris dataset 
# then generate a linear model 
set.seed(123) 
fit <- iris %>% 
    mutate(Category = factor(sample(c("A", "B"), 150, replace = TRUE))) %>% 
    lm(Sepal.Length ~ Sepal.Width + Species + Category, data = .) 

不同种类的情节包括:

边际效应的情节,可能最接近你想要什么

sjp.lm(fit, type = "eff", vars = c("Category", "Species")) 

enter image description here

“森林图” (贝塔系数+置信区间)

sjp.lm(fit) 

enter image description here