scripts_1/step_5-code-analysis_estimation_boot.R

rm(list=ls())
require(tidyverse)
path_monte_carlo <- "estimations_predicts/estimation_mc.txt"
estimation_mc <- read.table(path_monte_carlo,
                         col.names = c("id","estimate","par"))

estimation_mc %>% filter(par=="(Intercept)_delta")
TT <- nrow(estimation_mc)/11

estimation_mc %>% mutate(t=rep(seq(1,TT),each=11) ) %>% group_by(par) %>% summarise(max(estimate))

fig <- estimation_mc %>% mutate(t=rep(seq(1,TT),each=11) ) %>%
  dplyr::group_split(par) %>%
  purrr::map(
  ~ggplot(.,aes(x=t,y=estimate)) +
  geom_line()+
    theme_bw()+
    facet_wrap(~par,scales = "free")+
    #geom_hline(data = d,aes(yintercept = kp))+
    #geom_hline(yintercept = q)+
    theme(legend.position = "none",axis.text.x=element_text(angle=90,size=8)))%>%
  cowplot::plot_grid(plotlist = .,nrow=3)
x11()
fig

fig <- estimation_mc %>% mutate(t=rep(seq(1,TT),each=11) ) %>%
  dplyr::group_split(par) %>%
  purrr::map(
    ~ggplot(.,aes(estimate)) +
      geom_histogram()+
      theme_bw()+
      facet_wrap(~par,scales = "free")+
      #geom_hline(data = d,aes(yintercept = kp))+
      #geom_hline(yintercept = q)+
      theme(legend.position = "none",axis.text.x=element_text(angle=90,size=8)))%>%
  cowplot::plot_grid(plotlist = .,nrow=3)
x11()
fig

path_estimation <- "estimations_predicts/estimations.rds"
results <- readRDS(path_estimation)
estimation <- c(results$ar$Estimate,
  results$kl$Estimate,
  results$delta$Estimate,
  results$alpha$Estimate)
al <- .05/2
est <- estimation_mc %>% group_by(par,id) %>%
  summarise(Mean=mean(estimate),
            Sd=sd(estimate),
            Interval=t(quantile(estimate,c(al,1-al)))) %>%
  arrange(id) %>% data.frame() %>% select(-id)


est1 <- est %>% mutate(Estimate=estimation) %>% select(par,Estimate,Mean,everything())
est1$Estimate > est1$Interval[,1]
est1$Estimate < est1$Interval[,2]
est1[c(1,2,3,4,6,7,9,10,11),]

# Error in checkForRemoteErrors(val) :
#   23 nodes produced errors; first error: valor ausente onde TRUE/FALSE necessário
leonardobfn/ThesiR documentation built on March 19, 2022, 5:42 a.m.