首页 > 解决方案 > 使用 par(mfrow()) 方法在一个图中拟合两个 coefplot

问题描述

我试图coefplot通过该方法将两个对象排列成一个图形par(mfrow(,)),但没有成功。我做错了什么?或者这coefplot只是行不通?什么是替代方法?我已经引用了这个较早的线程,但我倾向于认为我的问题是一个完全不同的问题。

# load the data
dat <- readRDS(url("https://www.dropbox.com/s/88h7hmiroalx3de/act.rds?dl=1"))


#fit two models
library(lmer4)

act1.fit <- glmer(act1 ~ os + education + marital + nat6 + nat5 + nat4 + nat3 + nat2 + nat1 + 
    (1 | region_id), data = action, family = binomial, control = glmerControl(optimizer = "bobyqa"),
    nAGQ = 10)
    
action2.fit <- glmer(act2 ~ os + education + marital + nat6 + nat5 + nat4 + nat3 + nat2 + nat1 + 
    (1 | region_id), data = action, family = binomial, control = glmerControl(optimizer = "bobyqa"),
    nAGQ = 10)
    

# plot the two model individually
library(coefplot)

# construct coefplot objects

coefplot:::buildModelCI(action1.fit)
         
coefplot:::buildModelCI(action2.fit)
coefplot(action2.fit, coefficients=c("nat1", "nat2", "nat3", "nat4", "nat5", "nat6"), 
         intercept = FALSE, color = "brown3")
         
# arrange two plots in one graph
par(mfrow=c(1,2))
coefplot(action1.fit, coefficients=c("nat1", "nat2", "nat3", "nat4", "nat5", "nat6"), 
         intercept = FALSE, color = "brown3")
         
coefplot(action2.fit, coefficients=c("nat1", "nat2", "nat3", "nat4", "nat5", "nat6"), 
         intercept = FALSE, color = "brown3")         

# didn't work ???

标签: rmultirowcoefplot

解决方案


推荐阅读