

amazon_open_scaled <- scale(Amazon_dt$Amazon_Open, center = TRUE, scale = FALSE)

boeing_open_scaled <- scale(Boeing_dt$Boeing_Open, center = TRUE, scale = FALSE)
 
cattle_open_scaled <- scale(Cattle_dt$Cattle_Open, center = TRUE, scale = FALSE)

cocoa_open_scaled  <- scale(Cocoa_dt$Cocoa_Open, center = TRUE, scale = FALSE)

coffee_open_scaled <- scale(Coffee_dt$Coffee_Open, center = TRUE, scale = FALSE)

gold_open_scaled   <- scale(Gold_dt$Gold_Open, center = TRUE, scale = FALSE)

crude_open_scaled  <- scale(Crude_dt$Crude_Open, center = TRUE, scale = FALSE)

nyse_open_scaled   <- scale(NYSE_dt$NYSE_Open, center = TRUE, scale = FALSE)

silver_open_scaled <- scale(Silver_dt$Silver_Open, center = TRUE, scale = FALSE)

sp500_open_scaled  <- scale(sp500_dt$sp500_Open, center = TRUE, scale = FALSE)

sugar_open_scaled  <- scale(Sugar_dt$Sugar_Open, center = TRUE, scale = FALSE)

wheat_open_scaled  <- scale(Wheat_dt$Wheat_Open, center = TRUE, scale = FALSE)



# gold_open_multivariate_lm_object <- lm(Gold_dt$Gold_Open ~ amazon_open_scaled + boeing_open_scaled + cattle_open_scaled +
#                                          cocoa_open_scaled + coffee_open_scaled + crude_open_scaled + nyse_open_scaled +
#                                          silver_open_scaled + sp500_open_scaled + sugar_open_scaled + wheat_open_scaled, data = full_center_scaled_data)
# 
# 
# summary(gold_open_multivariate_lm_object)

# gold_on_lm_list <- list(
# 
# gold_on_amazon_lm <- lm(Gold_dt$Gold_Open ~ amazon_open_scaled, data = full_center_scaled_data),
# 
# gold_on_boeing_lm <- lm(Gold_dt$Gold_Open ~ boeing_open_scaled, data = full_center_scaled_data),
# 
# gold_on_cattle_lm <- lm(Gold_dt$Gold_Open ~ cattle_open_scaled, data = full_center_scaled_data),
# 
# gold_on_cocoa_lm  <- lm(Gold_dt$Gold_Open ~ cocoa_open_scaled, data = full_center_scaled_data),
# 
# gold_on_coffee_lm <- lm(Gold_dt$Gold_Open ~ coffee_open_scaled, data = full_center_scaled_data),
# 
# gold_on_crude_lm  <- lm(Gold_dt$Gold_Open ~ crude_open_scaled, data = full_center_scaled_data),
# 
# gold_on_nyse_lm   <- lm(Gold_dt$Gold_Open ~ nyse_open_scaled, data = full_center_scaled_data),
# 
# gold_on_silver_lm <- lm(Gold_dt$Gold_Open ~ silver_open_scaled, data = full_center_scaled_data),
# 
# gold_on_sp500_lm  <- lm(Gold_dt$Gold_Open ~ sp500_open_scaled, data = full_center_scaled_data),
# 
# gold_on_sugar_lm  <- lm(Gold_dt$Gold_Open ~ sugar_open_scaled, data = full_center_scaled_data),
# 
# gold_on_wheat_lm  <- lm(Gold_dt$Gold_Open ~ wheat_open_scaled, data = full_center_scaled_data)
# 
# ) # end gold_on_lm_list
# 
# 
# gold_open_lm_summary_list <- list(
# 
# gold_on_amazon_lm_summary <- summary(gold_on_amazon_lm),
# 
# 
# gold_on_boeing_lm_summary <- summary(gold_on_boeing_lm),
# 
#   
# gold_on_cattle_lm_summary <- summary(gold_on_cattle_lm),
# 
#   
# gold_on_cocoa_lm_summary <- summary(gold_on_cocoa_lm),
# 
# 
# gold_on_coffee_lm_summary <- summary(gold_on_coffee_lm),
# 
#   
# gold_on_crude_lm_summary <- summary(gold_on_crude_lm),
# 
# 
# gold_on_nyse_lm_summary <- summary(gold_on_nyse_lm),
# 
# 
# gold_on_silver_lm_summary <- summary(gold_on_silver_lm),
# 
# 
# gold_on_sp500_lm_summary <- summary(gold_on_sp500_lm),
# 
# 
# gold_on_sugar_lm_summary <- summary(gold_on_sugar_lm),
# 
# 
# gold_on_wheat_lm_summary <- summary(gold_on_wheat_lm)
# 
# ) # end gold_open_lm_summary_list
# 
# # -----
# 
# gold_open_r_squared_results <- as.data.frame(matrix(nrow = 1, ncol = 11))
# 
# colnames(gold_open_r_squared_results) <- c("Amazon", "Boeing", "Cattle",  "Cocoa",  
# "Coffee",  "Crude",  "NYSE",  "Silver",  "sp500",  "Sugar",  "Wheat")
# 
# for(i in 1:11)
# {
#   gold_open_r_squared_results[[colnames(gold_open_r_squared_results)[[i]]]] <- gold_open_lm_summary_list[[i]]$r.squared
# 
# } # end for
# 
# 
# correlation_data <- gold_open_r_squared_results[,gold_open_r_squared_results > 0.1] # 10% explanatory power mininum
# 
# correlation_gold_open_lm_object <- lm(Gold_dt$Gold_Open ~ coffee_open_scaled + crude_open_scaled + nyse_open_scaled + 
#                                       sp500_open_scaled + sugar_open_scaled + wheat_open_scaled, data = full_center_scaled_data)
# 
# summary(correlation_gold_open_lm_object)
# 
# 
# gold_open_lm_summary_list[1:length(gold_open_lm_summary_list)]
# 
# cor(gold_open_scaled, sugar_open_scaled)
# 
# gold_on_sugar_lm <- lm(Gold_dt$Gold_Open ~ Sugar_open_scaled, data = full_center_scaled_data)
# 
# confint(gold_on_sugar_lm, level = 0.95)



# amazon_full_scaled <- (Amaz)
# 
# gold_full_scaled   <- (Gold_dt$Gold_Open - mean(Gold_dt$Gold_Open)) / sd(Gold_dt$Gold_Open)
# 
# coffee_full_scaled <- (Coffee_dt$Coffee_Open - mean(Coffee_dt$Coffee_Open)) / sd(Coffee_dt$Coffee_Open)
# 
# crude_full_scaled  <- (Crude_dt$Crude_Open - mean(Crude_dt$Crude_Open)) / sd(Crude_dt$Crude_Open)





# 
# sp500_full_scaled  <- (sp500_dt$sp500_Open - mean(sp500_dt$sp500_Open)) / sd(sp500_dt$sp500_Open)
# 
# sugar_full_scaled  <- (Sugar_dt$Sugar_Open - mean(Sugar_dt$Sugar_Open)) / sd(Sugar_dt$Sugar_Open)
# 
# wheat_full_scaled  <- (Wheat_dt$Wheat_Open - mean(Wheat_dt$Wheat_Open)) / sd(Wheat_dt$Wheat_Open)
# 
# gold_correlates_plot_df <- as.data.frame(cbind(Gold_dt$Gold_Date, gold_full_scaled, coffee_full_scaled, crude_full_scaled, 
#                                           sp500_full_scaled, sugar_full_scaled, wheat_full_scaled))
# 
# colnames(gold_correlates_plot_df) <- c("Date", "Gold_scaled", "Coffee_scaled", "Crude_scaled", 
#                                                 "SP500_scaled", "Sugar_scaled", "Wheat_scaled")
# 
# gold_correlates_plot_df$Date <- lubridate::ymd(Gold_dt$Gold_Date)
# 
# lem <- ggplot(gold_correlates_plot_df, aes(x = Date)) +
#   geom_line(aes(y = Gold_scaled, color = "Gold")) +  
#   # geom_line(aes(y = Coffee_scaled, color = "Coffee")) +
#   # geom_line(aes(y = Crude_scaled, color = "Crude")) +
#   # geom_line(aes(y = SP500_scaled, color = "S&P 500")) +
#   # geom_line(aes(y = Sugar_scaled, color = "Sugar")) +
#   geom_line(aes(y = Wheat_scaled, color = "Wheat")) +
#   scale_y_continuous(limits = as.double(c(-2,4))) + 
#   ylab("Cofee & Sugar") +
#   labs(colour = "Items")
#   
# ggplotly(lem)
# 


