In the boxplot view created with the script below, I do not think the g2, g3
and g4
graphics are the same ones that appear in the g1
image, but I could not find anything wrong with the code! Notice that the median or maximum and minimum limits of the graphs are different! The% w of% for example in the% w% graph is above the% w value of% on the% w% of axis and the% w% of graph is below this value!
library(ggplot2)
set.seed(123)
n=100
#N=100
m=matrix(ncol=8,nrow=n)
for(i in 1:n){
m[i,] <- runif(8)
}
parametros = factor(rep(c("gamma0","gamma1","gamma2","beta0", "beta1","beta2","phi1", "rho"), each=n))
df <- data.frame(parametros, val_Sim = c(m[,1],m[,2],m[,3],m[,4],m[,5],m[,6],m[,7],m[,8]))
d <- df %>% group_by(parametros,val_Sim)
g1 <- ggplot(d, aes(y = val_Sim, x = parametros)) +
geom_boxplot(aes(fill = parametros),alpha = .6,size = .5)+
stat_boxplot(geom ='errorbar') +
guides(fill=FALSE)+geom_point()+
ggtitle("Boxplot com os valores estimados") +
xlab("Parâmetros")+
scale_x_discrete(name = "Valores Estimados",
labels=c("gamma0","gamma1","gamma2","beta0", "beta1","beta2","phi1", "rho")) +
scale_y_continuous(name = "Valores Estimados",
breaks = seq(-0.5, 2, 0.5),
limits=c(-0.5, 2))+
theme(plot.title = element_text(hjust = 0.5))
parametros = factor(rep(c("gamma0", "gamma1","gamma2"), each=n))
df <- data.frame(parametros, val_Sim = c(m[,1],m[,2],m[,3]))
d <- df %>% group_by(parametros,val_Sim)
g2 <- ggplot(d, aes(y = d$val_Sim, x = parametros)) +
geom_boxplot(aes(fill = parametros),alpha = .6,size = .5)+
stat_boxplot(geom ='errorbar') +
guides(fill=FALSE)+geom_point()+
ggtitle("Boxplot com os valores estimados") +
xlab("Parâmetros") +
scale_y_continuous(name = "Valores Estimados",
breaks = seq(-0.5, 2, 0.5),
limits=c(-0.5, 2))+
theme(plot.title = element_text(hjust = 0.5))
g1
g2
library(gridExtra)
grid.arrange(g1,g2)
parametros = factor(rep(c("beta0","beta1", "beta2"), each=n))
df <- data.frame(parametros, val_Sim = c(m[,4],m[,5],m[,6]))
d <- df %>% group_by(parametros,val_Sim)
g3 <- ggplot(d, aes(y = val_Sim, x = parametros)) +
geom_boxplot(aes(fill = parametros),alpha = .6,size = .5)+
stat_boxplot(geom ='errorbar') +
guides(fill=FALSE)+geom_point()+
ggtitle("Boxplot com os valores estimados") +
xlab("Parâmetros") +
scale_y_continuous(name = "Valores Estimados",
breaks = seq(-0.5, 2, 0.5),
limits=c(-0.5, 2))+
theme(plot.title = element_text(hjust = 0.5))
parametros = factor(rep(c("phi1", "rho"), each=n))
df <- data.frame(parametros, val_Sim = c(m[,7],m[,8]))
d <- df %>% group_by(parametros,val_Sim)
means <- aggregate(val_Sim ~ parametros, df, mean)
g4 <- ggplot(d, aes(y = val_Sim, x = parametros)) +
geom_boxplot(aes(fill = parametros),alpha = .6,size = .5)+
stat_boxplot(geom ='errorbar') +
guides(fill=FALSE)+geom_point()+
ggtitle("Boxplot com os valores estimados") +
xlab("Parâmetros") +
scale_y_continuous(name = "Valores Estimados",
breaks = seq(-1.25, 1.25, 0.25),
limits=c(-1.25, 1.25))+
theme(plot.title = element_text(hjust = 0.5))
grid.arrange(g1,g3)
grid.arrange(g1,g4)