0
votes

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). And in the x axis, I need to put the name of each variable.

Here what I tried, but it didn't work.

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"))

Thanks in advance for any help.

ps.: helping to set title, xlab and ylab font and size would be a plus to me.

1

1 Answers

2
votes

Sorry guys, but I found the errors on the code above. In this case, do I answer my own question?

Here the code that works...

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")

update: It was a silly mistake, so I don't know if I deserve an up vote for my answer after all. We don't wanna incentive people to ask silly question and answer them in order to get an up vote (I didn't this on purpose, of course). In any case, as requested, here what was wrong:

There was a missing parentesis after "labels". And I inserted this missing parentesis in the end of the code. So, I just put the parentesis in the proper place.