[英]Plotting mean and 95% confidence interval with Hmisc::xYplot and adjusting x axis
I'm trying to plot the results of a regression and I need to plot the coefficients estimated plus 95% confidence interval (actually I have 95% credibility interval, since I'm fitting a Bayesian model, but the idea is the same). 在 x 轴上,我需要输入每个变量的名称。
这是我尝试过的,但没有奏效。
library(lattice)
library(Hmisc)
betas1=c(0.4271611, -0.4730473, 0.8428530, -0.4356814, 0.2699920, -0.2308315)
quantiles.beta = matrix(c(-0.09015,-1.30900, 0.43290, -0.85280, 0.02675, -0.56850, 0.93940, 0.37390, 1.28900, -0.03920, 0.52410, 0.07017), ncol=2)
xYplot(Cbind(betas1,quantiles.beta) ~ seq(0, 125, 25), varwidth = TRUE, ylab="Betas",
xlab="Ano", ylim=c(-1.5, 1.5), scales=list(cex=1.2, x = list(at=seq(0,125, by=25),
labels = c("PIB per cap.", "democracia", "ginete_park", "educ","patentes", "FDI" ) ),
abline=c(list(h=0), lty="dotted",
col= "grey69"), main="Betas estimados no modelo 1",
sub="Inclinação das Covariáveis com respectivos 95% intervalo de credibilidade estimados no modelo1"))
提前感谢您的帮助。
ps.:帮助设置标题、xlab 和 ylab 字体和大小对我来说是一个加分项。
对不起,我在上面的代码中发现了错误。 在这种情况下,我应该回答我自己的问题吗?
这是有效的代码......
xYplot(Cbind(betas1,quantiles.beta) ~ seq(0, 125, 25)
, varwidth = TRUE, ylab="Betas",xlab="Ano", ylim=c(-1.5, 1.5),
scales=list(cex=1.2, x = list(at=seq(0,125, by=25),
labels = c("PIB per cap.", "democracia", "ginete_park", "educ","patentes", "FDI" ))) ,
abline=c(list(h=0), lty="dotted", col= "grey69"), main="Betas estimados no modelo 1",
sub="Inclinação das Covariáveis com respectivos 95% intervalo de credibilidade estimados no modelo1")
更新:这是一个愚蠢的错误,所以我不知道我是否应该为我的答案投赞成票。 我们不想激励人们提出愚蠢的问题并回答他们以获得赞成票(当然,我不是故意的)。 无论如何,根据要求,这里出了什么问题:
“标签”之后缺少双亲。 我在代码末尾插入了这个缺失的括号。 所以,我只是把双亲放在适当的地方。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.