Installing Packages

#install.packages("ggplot2")
#install.packages("dplyr")
library(ggplot2)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union

1. Data Preparation

df <- read.csv("Commodities Market Prices (1).csv")
head(df)
##   Exchange_Rate Commodity_Price
## 1          1.15           210.3
## 2          1.12           220.9
## 3          1.18           205.1
## 4          1.14           215.8
## 5          1.13           218.6
## 6          1.16           208.4
tail(df)
##    Exchange_Rate Commodity_Price
## 25          1.12           221.2
## 26          1.14           215.2
## 27          1.22           197.3
## 28          1.08           228.4
## 29          1.15           209.2
## 30          1.13           218.3

2. Model Fitting

linear_regresion <- lm(Commodity_Price~Exchange_Rate, data = df) 
summary(linear_regresion)
## 
## Call:
## lm(formula = Commodity_Price ~ Exchange_Rate, data = df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.5801 -0.3736  0.0894  0.7086  1.9778 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    484.776      8.375   57.88   <2e-16 ***
## Exchange_Rate -237.102      7.292  -32.51   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.342 on 28 degrees of freedom
## Multiple R-squared:  0.9742, Adjusted R-squared:  0.9733 
## F-statistic:  1057 on 1 and 28 DF,  p-value: < 2.2e-16

3. Analysis and Interpretation

Identify the dependent and independent variable:

In this model, the independent variable is the exchange rate, while the dependent variable is the commodity price. The analysis aims to understand how fluctuations in the exchange rate affect commodity prices.

Identify and explain each coefficient in the model summary:

The coefficient associated with the exchange rate is -237.102. This suggests that for every one-unit increase in the exchange rate, the commodity price decreases by approximately 237.102 units.

Determine whether each predictor is statistically significant based on p-values:

The p-value for the exchange rate is below 0.001, indicating that the exchange rate has a statistically significant effect on commodity prices.

4. Visualization and Model Validation

plot(df$Exchange_Rate, df$Commodity_Price, main = "Exchange Rate vs Commodity Price") 
abline(linear_regresion, col = "purple")

5. Discussion and Conclusion

This model allows us to understand how the exchange rate influences commodity prices. Specifically, it shows that for every one-unit increase in the exchange rate, commodity prices decrease by 237.102 units. In other words, when the exchange rate strengthens, the cost of commodities tends to fall. The p-value (less than 0.001) further supports the statistical significance of this relationship, confirming that the exchange rate has a notable effect on commodity pricing.

Moreover, the model demonstrates strong predictive power. The Adjusted R-squared value of 97.33% indicates that around 97.33% of the variation in commodity prices can be explained by fluctuations in the exchange rate. This highlights the model’s effectiveness in forecasting price movements. Additionally, the residual standard error of 1.342 suggests that the model’s predictions are closely aligned with the observed data.

Thus, the model suggests that changes in the exchange rate directly affect commodity prices: an increase in the exchange rate leads to a drop in prices, while a decrease in the exchange rate causes prices to rise.

However, one potential limitation of this model is the assumption of a linear relationship between exchange rates and commodity prices. In practice, other economic variables—such as inflation—may also influence commodity prices. Furthermore, the data sample used may not fully capture the broader behavior of these variables, which could introduce bias into the conclusions.