data1 <- read.csv("data1.csv",header=TRUE) data2 <- read.csv("data2.csv",header=TRUE) x1 <- data1[[2]] y1 <- data1[[3]] prom_x1 <- mean(x1) prom_y1 <- mean(y1) a1 <- cov(x1,y1)/var(x1) b1 <- prom_y1 - a1 * prom_x1 modelo_y1 <- b1 + a1*x1 pdf("grafico_data1_dispersion.pdf",width=8,height=10) plot(x1,y1) dev.off() pdf("grafico_data1_dispersion.pdf",width=8,height=10) plot(x1,modelo_y1) dev.off() x2 <- data2[[2]] y2 <- data2[[3]] prom_x2 <- mean(x2) prom_y2 <- mean(y2) a2 <- cov(x2,y2)/var(x2) b2 <- prom_y2 - a2*prom_x2 modelo_y2 <- b2 + a2*x2 pdf("grafico_data2_dispersion.pdf",width=8,height=10) plot(x2,y2) dev.off() pdf("grafico_data2_dispersion.pdf",width=8,height=10) plot(x2,modelo_y2) dev.off() ipsa_jul_98 <- 902.67 indice_jul_98 <- 115 ipsa_est_jul_98_data1 <- b1 + a1*indice_jul_98 ipsa_est_jul_98_data2 <- b2 + a2*indice_jul_98 err_porc_1 <- abs((ipsa_jul_98 - ipsa_est_jul_98_data1)/ipsa_jul_98)*100 err_porc_2 <- abs((ipsa_jul_98 - ipsa_est_jul_98_data2)/ipsa_jul_98)*100 coef_corr_1 <- cov(x1,y1)/(sd(x1)*sd(y1)) coef_corr_2 <- cov(x2,y2)/(sd(x2)*sd(y2)) data3 <- read.csv("data3.csv",header=TRUE) x3 <- data3[[2]] y3 <- data3[[3]] prom_x3 <- mean(x3) prom_y3 <- mean(y3) a3 <- cov(x3,y3)/var(x3) b3 <- prom_y3 - a3*prom_x3 modelo_y3 <- b3 + a3*x3 pdf("grafico_data3_dispersion.pdf",width=8,height=10) plot(x3,y3) dev.off() pdf("grafico_data3_regresion.pdf",width=8,height=10) plot(x3,modelo_y3) dev.off() ipsa_jul_2003 <- 1321.38 indice_jul_2003 <- 175 ipsa_est_jul_2003_data2 <- b2 + a2*indice_jul_2003 ipsa_est_jul_2003_data3 <- b3 + a3*indice_jul_2003 err_porc_3_data2 <- abs((ipsa_jul_2003 - ipsa_est_jul_2003_data2)/ipsa_jul_2003)*100 err_porc_3_data3 <- abs((ipsa_jul_2003 - ipsa_est_jul_2003_data3)/ipsa_jul_2003)*100 coef_corr_3 <- cov(x3,y3)/(sd(x3)*sd(y3)) datafull <- read.csv("datafull.csv",header=TRUE) xfull <- datafull[[2]] yfull <- datafull[[3]] prom_xfull <- mean(xfull) prom_yfull <- mean(yfull) afull <- cov(xfull,yfull)/var(xfull) bfull <- prom_yfull - afull*prom_xfull indice_enero_93 <- 49 ipsa_enero_93 <- 469.92 indice_enero_2008 <- 229 ipsa_enero_2008 <- 2788.34 ipsa_est_enero_93_mod_data1 <- b1 + a1*indice_enero_93 ipsa_est_enero_93_mod_data2 <- b2 + a2*indice_enero_93 ipsa_est_enero_93_mod_data3 <- b3 + a3*indice_enero_93 ipsa_est_enero_93_mod_datafull <- bfull + afull*indice_enero_93 ipsa_est_enero_2008_mod_data1 <- b1 + a1*indice_enero_2008 ipsa_est_enero_2008_mod_data2 <- b2 + a2*indice_enero_2008 ipsa_est_enero_2008_mod_data3 <- b3 + a3*indice_enero_2008 ipsa_est_enero_2008_mod_datafull <- bfull + afull*indice_enero_2008 err_porc_full_data1_enero_93 <- abs((ipsa_enero_93 - ipsa_est_enero_93_mod_data1)/ipsa_enero_93)*100 err_porc_full_data2_enero_93 <- abs((ipsa_enero_93 - ipsa_est_enero_93_mod_data2)/ipsa_enero_93)*100 err_porc_full_data3_enero_93 <- abs((ipsa_enero_93 - ipsa_est_enero_93_mod_data3)/ipsa_enero_93)*100 err_porc_full_datafull_enero_93 <- abs((ipsa_enero_93 - ipsa_est_enero_93_mod_datafull)/ipsa_enero_93)*100 err_porc_full_data1_enero_2008 <- abs((ipsa_enero_2008 - ipsa_est_enero_2008_mod_data1)/ipsa_enero_93)*100 err_porc_full_data2_enero_2008 <- abs((ipsa_enero_2008 - ipsa_est_enero_2008_mod_data2)/ipsa_enero_93)*100 err_porc_full_data3_enero_2008 <- abs((ipsa_enero_2008 - ipsa_est_enero_2008_mod_data3)/ipsa_enero_93)*100 err_porc_full_datafull_enero_2008 <- abs((ipsa_enero_2008 - ipsa_est_enero_2008_mod_datafull)/ipsa_enero_93)*100