我正在尝试进行多元多元回归分析。幸运的是,我找到了一个很好的页面,演示了如何在 Stata 中执行此操作:
http://www.ats.ucla.edu/stat/stata/dae/mvreg.htm
问题是我正在使用 R,虽然我已经弄清楚如何在 R 中运行多元多元回归模型的基础知识,但我仍然不确定如何查看每个因变量的系数是否不同(如如链接所示)。有谁知道如何在 R 中计算这个分析?似乎查看相同的自变量是否对每个因变量产生不同的影响是一个非常有用的工具,我很想能够做到这一点!
更新:这是迄今为止我用自己的数据所做的可重现的示例:
# data
data(mtcars)
# fitting a multivariate multiple regression where mpg and cyl are predicted by wt and hp
car.mod <- lm(cbind(mpg,cyl) ~ wt + hp,data=mtcars)
# see if there is a multivariate effect of wt and hp
summary(manova(car.mod),test="W")
# Get coefficients for each dependent variable
summary(car.mod)
Run Code Online (Sandbox Code Playgroud)
在这个例子中我想知道的是如何测试“wt”在“mpg”和“cyl”上的等效性。显然,在 Stata 中使用该命令可以实现这一点test。
我想以某种方式表明多面板图中的某些行应该进行比较.例如,我想制作这个情节:
看起来像这个图(用PowerPoint制作的面板周围的框):
这是我使用第一个图表的代码.我使用了ggplot和cowplot:
require(cowplot)
theme_set(theme_cowplot(font_size=12)) # reduce default font size
plot.mpg <- ggplot(mpg, aes(x = cty, y = hwy, colour = factor(cyl))) +
geom_point(size=2.5)
plot.diamonds <- ggplot(diamonds, aes(clarity, fill = cut)) + geom_bar() +
theme(axis.text.x = element_text(angle=70, vjust=0.5))
plot.mpg2 <- ggplot(mpg, aes(x = cty, y = hwy, colour = factor(cyl))) +
geom_point(size=2.5)
plot.diamonds2 <- ggplot(diamonds, aes(clarity, fill = cut)) + geom_bar() +
theme(axis.text.x = element_text(angle=70, vjust=0.5))
plot_grid(plot.mpg, plot.diamonds,plot.mpg2, plot.diamonds2, nrow=2,labels = c('A', 'B','C','D'))
Run Code Online (Sandbox Code Playgroud)
我可以对此代码进行更改以获取我想要的边框吗?或者我甚至可以让面板A和B的颜色与面板C和D的背景略有不同?那可能会更好.