Intro:
A common problem farmers face across all The United States is being able to look into the predicted forecasts and try to find what will be the most profitable for their farm. Here we have conducted the research and pulled data from the USDA as well as other credible sources to build a report as to what we suggest would be the most profitable for soybean and corn producers. We decided to narrow our focus to just corn and soybeans due to the fact that they are widely produced nationwide and typically both grown by one farmer. When finding the data for past prices nationwide we decided to use FRED, this is a database that consists of hundreds of thousands of economic data that has been collected over the years. With this we looked at specific years starting from 2000-present, we felt this would allow for a more accurate forecast with eliminating prior years that could have outliers. Once we located our data and the information from USDA we were then able to get the best and most accurate predicted forecast for over the next 3 years.
Question:
In 3 years should the producer plant all 1,000 acres with either soybeans or corn to make more profit?
Background:
A producer is facing the challenges of trying to decide what they should do with 1,000 acres of crop ground.
They have the option to either put all 1,000 acres into corn or soybean production but not a combination of both.
Data we utilized measured the quantity in Metric tons so conversions from bushels to metric tons is below.
Average U.S. corn yields have been recognized at 177 bu/ac
1 metric ton of corn = 39.368 bushels
Average U.S. soybean yields have been recognized at 51.4 bu/ac
1 metric ton of soybeans = 36.7437 bushels
This means our producer can produce one of the following:
Corn: 1,000 acres x 177 bu/ac= 177,000 bu / 39.368 bu = 4,496.04 Metric Tons
Soybean: 1,000 acres x 51.4 bu/ac= 51,400 bu / 36.7437 bu = 1,398.88 Metric Tons
Data:
We utilized the Federal Reserve Bank of St. Louis otherwise known as “FRED”
Looked at two different commodity data sets that were global prices faced by all from futures markets
Corn: PMAIZMTUSDM
Soybeans: PSOYBUSDM
Decomposition:
When we looked at our decomposition we saw that both commodities that we looked at were facing rising continuous trends. This was good because we saw that would help to raise our trendline to be positive sloping. When we looked into the seasonality at first it appears as though that they are very similar buy when you dive into the details of the spread on the graph you see that soybeans actually fluctuate seasonally from -20 to 20 while corn only fluctuates seasonally from -5 to 5. This means that corn faces less seasonality in the price markets that it faces. But when you put all the information back into one price line you see that the prices are steadily increasing, partly due to the increasing trend witnessed by both commodities.
Analysis:
When analyzing the data after it was produced in R there is one major point that stuck out and was further solidified after making the graphs. Due to the volatility within the data it makes our P-values much higher resulting in inaccurate trendlines. This can be seen visually through the graphs but maybe more easily understood when looking directly at the resulting P-values. A common threshold of P- value is less than 0.05, this is stating that anything higher than this point can be looked as not being the most accurate within our trendline. When calculating the P-value we found that soybeans were 0.184248 and corn was 0.205926, though both of these are much higher than the threshold, it can be seen that the volatility within our data has a direct effect on making our trendline inaccurate.
August 2026 Predictions With 95% Confidence
Soybeans
Upper Bound: $968.30
Predicted Forecast: $613.3
Lower Bound: $258.4
Spread from Upper & Lower Bounds: $709.90
Corn
Upper Bound: $600.80
Predicted Forecast: $354.20
Lower Bound: $107.50
Spread from Upper & Lower Bounds: $493.30
When looking at our forecasts that were generated in R we made those forecasts with 95% confidence intervals. When you look at our soybean prediction for August 2026 you see our predicted value is $613.30, but what may be more interesting is looking at the potential high and potential low the producer may face if markets do something unexpected. When we looked at the high price of corn with 95% confidence we saw a price of $968.30 and a low price of $258.40. Then if you subtract the high and low bounds of the prediction of potential outcome you see there is a potential fluctuation of $709.90. You can then compare this to the same potential fluctuation seen in corn. Corn high bound in August 2026 was seen to be $600.80 and its low bound was $107.50 and the difference of the two is $493.30. With the two values of $968.30 and $493.30 this tells you the spread of gross margin you may make from either best case scenario or worst case scenario. When you think about this you would want to pick the commodity that has a lower spread in the prices they may receive, this is because while both are being evaluated with 95% confidence in the prediction there is less fluctuation in the price if you go with the lower spread. In this example that would be corn with only a spread from upper to lower bounds of $493.30.
Conclusion:
When looking at our forecasts and the potential output in yields that this producer could potentially face we saw that in just revenue the producer in August 2026 based on our predictions would be best of choosing to produce corn. This is based on prices times the average yield the producer could experience a revenue of $1,592,497.37. This is the best option that the producer decides to plant corn in 2026, because when you also look at our analysis of the potential fluctuation in the market we also found that the corn market would experience lower fluctuation during the same time period. When you can then establish that corn will not only gross more revenue at the end of the day but also be less volatile then a producer would be able to be confident that producing corn in 2026.
#This lab...
setwd("~/AREC_project_1")
library(tidyquant)
library(fpp3)
corn <- tq_get(c("PMAIZMTUSDM"),get = "economic.data",from="2007-08-01")
#Prep data
corn_ts <- corn %>%
select(date,price) %>% #select only the date and price variables
mutate(date=yearmonth(date)) %>% #convert the date into yearmonth format so the models understand the unit of observation
as_tsibble() #convert the data to a tsibble object - similar to a tibble or data.frame but for time series data
#Fit the model
fit <- corn_ts %>%
model(my_ets=ETS(price ~ trend(method="A") + season(method="A") + error(method="A"))) #fit model
#Forecast the model
corn_forecast <- fit %>%
fabletools::forecast(h="5 years") #forecast model for 5 years
#Plot the forecast
autoplot(corn_forecast,corn_ts) #forecast model for 5 years
#Extract prediction interval
corn_forecast_out <- corn_forecast %>%
hilo(level = 95) %>% #extract 95% prediction interval
mutate(
lower=`95%`$lower,
upper=`95%`$upper
) #unpack into own columns
#Prepare data for export
part2 <- corn_forecast_out %>%
select(date,price=.mean,`lower`,`upper`)
to_export <- bind_rows(corn_ts,part2)
write_csv(to_export,"corn_forecast.csv")
sink("Corn.txt")
source("Corn Lab 7.R",echo=TRUE)
sink()
#This lab...
setwd("~/AREC_ps7")
library(tidyquant)
library(fpp3)
soybean <- tq_get(c("PSOYBUSDM"),get = "economic.data",from="2007-08-01")
#Prep data
soybean_ts <- soybean %>%
select(date,price) %>% #select only the date and price variables
mutate(date=yearmonth(date)) %>% #convert the date into yearmonth format so the models understand the unit of observation
as_tsibble() #convert the data to a tsibble object - similar to a tibble or data.frame but for time series data
#Fit the model
fit <- soybean_ts %>%
model(my_ets=ETS(price ~ trend(method="A") + season(method="A") + error(method="A"))) #fit model
#Forecast the model
soybean_forecast <- fit %>%
fabletools::forecast(h="5 years") #forecast model for 5 years
#Plot the forecast
autoplot(soybean_forecast,soybean_ts) #forecast model for 5 years
#Extract prediction interval
soybean_forecast_out <- soybean_forecast %>%
hilo(level = 95) %>% #extract 95% prediction interval
mutate(
lower=`95%`$lower,
upper=`95%`$upper
) #unpack into own columns
#Prepare data for export
part2 <- soybean_forecast_out %>%
select(date,price=.mean,`lower`,`upper`)
to_export <- bind_rows(soybean_ts,part2)
write_csv(to_export,"soybean_forecast.csv")
sink("Soybean.txt")
source("soybeanLab7R.R",echo=TRUE)
sink()
#Create time series
install.packages("forecast")
library(forecast)
install.packages("pacman")
library(pacman)
setwd("~/AREC_project_1")
corn=tq_get(c("PMAIZMTUSDM"),get="economic.data",from="2000-01-03")
corn_ts=ts(corn$price,frequency=12,start=c(2000,1))
#Decompose ts
corn_decomp=decompose(corn_ts)
#Plot decomposition
plot(corn_decomp$trend)
plot(corn_decomp$seasonal)
plot(corn_decomp$random)
corn_decomp_out=corn_decomp[1:4] %>%
as_tibble() %>%
rename(price=x) %>%
mutate(measure_date=corn$date)
#Extract components
corn_trend=corn_decomp$trend
corn_seasonal=corn_decomp$seasonal
corn_residuals=corn_decomp$random
#Create seasonal adjusted
adjstd_corn=corn_trend + corn_residuals
plot(adjstd_corn)
adjstd_corn_df=as.data.frame(adjstd_corn)%>%
rename(sa_price=x)%>%
mutate(measure_date=corn$date)
#Forecast 3 years
corn_trend_forecast=forecast::forecast(corn_trend, h=36)
plot(corn_trend_forecast)
corn_seasonal_forecast=forecast::forecast(corn_seasonal,h=36)
plot(corn_seasonal_forecast)
#Create time series object
corn_residuals_ts=ts(corn_residuals,frequency = 12,start=c(2000,1))
# Fit an MA(1) model to the residuals
corn_residuals_model <- arima(corn_residuals_ts, order=c(0,0,1))
#Forecast residual for three years
corn_residuals_forecast=forecast::forecast(corn_residuals_model,h=36)$mean
plot(corn_residuals_forecast)
#Combine three forecasts
corn_forecast_combined=corn_trend_forecast$mean + corn_seasonal_forecast$mean + corn_residuals_forecast
plot(corn_forecast_combined)
#Create data frame
corn_forecast_combined_df=tibble(price = corn_forecast_combined)%>%
mutate(measure_date=seq(as_date("2023-01-01"),by="months",length.out=nrow(.)))
corn_forecast_combined_df=corn_forecast_combined_df %>%
filter(measure_date > max(corn_decomp_out$measure_date)) %>%
mutate(forecast=T)
final_out=bind_rows(corn_decomp_out,corn_forecast_combined_df)
write.csv(final_out,"corn_forecast_decomp.csv")
sink("Corn Decomp.txt")
source("corn decomp.R",echo=TRUE)
sink()
library(tidyquant)
library(dplyr)
library(readr)
library(forecast)
#Create time series
soybeans=tq_get(c("PSOYBUSDM"),get="economic.data",from="2000-01-03")
soybean_ts=ts(soybeans$price,frequency=12,start=c(2000,1))
#Decompose ts
soybean_decomp=decompose(soybean_ts)
#Plot decomposition
plot(soybean_decomp$trend)
plot(soybean_decomp$seasonal)
plot(soybean_decomp$random)
soybean_decomp_out=soybean_decomp[1:4] %>%
as_tibble() %>%
rename(price=x) %>%
mutate(measure_date=soybeans$date)
#Extract components
soybean_trend=soybean_decomp$trend
soybean_seasonal=soybean_decomp$seasonal
soybean_residuals=soybean_decomp$random
#Create seasonal adjusted
adjstd_soybean=soybean_trend + soybean_residuals
plot(adjstd_soybean)
adjstd_soybean_df=as.data.frame(adjstd_soybean)%>%
rename(sa_price=x)%>%
mutate(measure_date=soybeans$date)
#Forecast 3 years
soybean_trend_forecast=forecast(soybean_trend, h=36)
plot(soybean_trend_forecast)
soybean_seasonal_forecast=forecast(soybean_seasonal,h=36)
plot(soybean_seasonal_forecast)
#Create time series object
soybean_residuals_ts=ts(soybean_residuals,frequency = 12,start=c(2000,1))
# Fit an MA(1) model to the residuals
soybean_residuals_model <- arima(soybean_residuals_ts, order=c(0,0,1))
#Forecast residual for three years
soybean_residuals_forecast=forecast(soybean_residuals_model,h=36)$mean
plot(soybean_residuals_forecast)
#Combine three forecasts
soybean_forecast_combined=soybean_trend_forecast$mean + soybean_seasonal_forecast$mean + soybean_residuals_forecast
plot(soybean_forecast_combined)
#Create data frame
soybean_forecast_combined_df=tibble(soybean_forecast_combined)%>%
mutate(measure_date=seq(as_date("2023-01-01"),by="months",length.out=nrow(.)))
soybean_forecast_combined_df=soybean_forecast_combined_df %>%
filter(measure_date > max(soybean_decomp_out$measure_date)) %>%
mutate(forecast=T)
final_out=bind_cols(soybean_decomp_out,adjstd_soybean_df)
final_out=final_out[,-7]%>%
rename(measure_date=measure_date...5)
final_out_forecast=bind_rows(final_out,soybean_forecast_combined_df)
write.csv(final_out_forecast,"soybean_forecast.csv")
sink("Soybean Decomp.txt")
source("PS6 Final.R",echo=TRUE)
sink()
> #This lab...
>
> setwd("~/AREC_project_1")
> library(tidyquant)
> library(fpp3)
> corn <- tq_get(c("PMAIZMTUSDM"),get = "economic.data",from="2007-08-01")
> #Prep data
>
> corn_ts <- corn %>%
+
+ select(date,price) %>% #select only the date and price variables
+
+ mutate(date=yearmonth(date .... [TRUNCATED]
> #Fit the model
>
> fit <- corn_ts %>%
+
+ model(my_ets=ETS(price ~ trend(method="A") + season(method="A") + error(method="A"))) #fit model
> #Forecast the model
>
> corn_forecast <- fit %>%
+
+ fabletools::forecast(h="5 years") #forecast model for 5 years
> #Plot the forecast
>
> autoplot(corn_forecast,corn_ts) #forecast model for 5 years
> #Extract prediction interval
>
> corn_forecast_out <- corn_forecast %>%
+
+ hilo(level = 95) %>% #extract 95% prediction interval
+
+ .... [TRUNCATED]
> #Prepare data for export
>
> part2 <- corn_forecast_out %>%
+
+ select(date,price=.mean,`lower`,`upper`)
> to_export <- bind_rows(corn_ts,part2)
> write_csv(to_export,"corn_forecast.csv")
[1mwrote[0m [32m507.00B[0m in [36m 0s[0m, [32m21.05MB/s[0m
[1mwrote[0m [32m1.00TB[0m in [36m 0s[0m, [32m67.98TB/s[0m
> #This lab...
> setwd("~/AREC_ps7")
> library(tidyquant)
> library(fpp3)
> soybean <- tq_get(c("PSOYBUSDM"),get = "economic.data",from="2007-08-01")
> #Prep data
> soybean_ts <- soybean %>%
+ select(date,price) %>% #select only the date and price variables
+ mutate(date=yearmonth(date)) %>% #co .... [TRUNCATED]
> #Fit the model
> fit <- soybean_ts %>%
+ model(my_ets=ETS(price ~ trend(method="A") + season(method="A") + error(method="A"))) #fit model
> #Forecast the model
> soybean_forecast <- fit %>%
+ fabletools::forecast(h="5 years") #forecast model for 5 years
> #Plot the forecast
> autoplot(soybean_forecast,soybean_ts) #forecast model for 5 years
> #Extract prediction interval
> soybean_forecast_out <- soybean_forecast %>%
+ hilo(level = 95) %>% #extract 95% prediction interval
+ mutate(
+ .... [TRUNCATED]
> #Prepare data for export
> part2 <- soybean_forecast_out %>%
+ select(date,price=.mean,`lower`,`upper`)
> to_export <- bind_rows(soybean_ts,part2)
> write_csv(to_export,"soybean_forecast.csv")
[1mwrote[0m [32m476.00B[0m in [36m 0s[0m, [32m23.77MB/s[0m
[1mwrote[0m [32m1.00TB[0m in [36m 0s[0m, [32m77.05TB/s[0m
> sink("Soybean.txt")
> #Create time series
> install.packages("forecast")
Error in install.packages : Updating loaded packages
> library(forecast)
> install.packages("pacman")
Error in install.packages : Updating loaded packages
> library(pacman)
> setwd("~/AREC_project_1")
> corn=tq_get(c("PMAIZMTUSDM"),get="economic.data",from="2000-01-03")
> corn_ts=ts(corn$price,frequency=12,start=c(2000,1))
> #Decompose ts
>
> corn_decomp=decompose(corn_ts)
> #Plot decomposition
>
> plot(corn_decomp$trend)
> plot(corn_decomp$seasonal)
> plot(corn_decomp$random)
> corn_decomp_out=corn_decomp[1:4] %>%
+
+ as_tibble() %>%
+
+ rename(price=x) %>%
+
+ mutate(measure_date=corn$date)
> #Extract components
>
> corn_trend=corn_decomp$trend
> corn_seasonal=corn_decomp$seasonal
> corn_residuals=corn_decomp$random
> #Create seasonal adjusted
>
> adjstd_corn=corn_trend + corn_residuals
> plot(adjstd_corn)
> adjstd_corn_df=as.data.frame(adjstd_corn)%>%
+
+ rename(sa_price=x)%>%
+
+ mutate(measure_date=corn$date)
> #Forecast 3 years
>
> corn_trend_forecast=forecast::forecast(corn_trend, h=36)
> plot(corn_trend_forecast)
> corn_seasonal_forecast=forecast::forecast(corn_seasonal,h=36)
> library(tidyquant)
> library(dplyr)
> library(readr)
> library(forecast)
> #Create time series
>
> soybeans=tq_get(c("PSOYBUSDM"),get="economic.data",from="2000-01-03")
> soybean_ts=ts(soybeans$price,frequency=12,start=c(2000,1))
> #Decompose ts
>
> soybean_decomp=decompose(soybean_ts)
> #Plot decomposition
>
> plot(soybean_decomp$trend)
> plot(soybean_decomp$seasonal)
> plot(soybean_decomp$random)
> soybean_decomp_out=soybean_decomp[1:4] %>%
+
+ as_tibble() %>%
+
+ rename(price=x) %>%
+
+ mutate(measure_date=soybeans$date)
> #Extract components
>
> soybean_trend=soybean_decomp$trend
> soybean_seasonal=soybean_decomp$seasonal
> soybean_residuals=soybean_decomp$random
> #Create seasonal adjusted
>
> adjstd_soybean=soybean_trend + soybean_residuals
> plot(adjstd_soybean)
> adjstd_soybean_df=as.data.frame(adjstd_soybean)%>%
+
+ rename(sa_price=x)%>%
+
+ mutate(measure_date=soybeans$date)
> #Forecast 3 years
>
> soybean_trend_forecast=forecast(soybean_trend, h=36)
> plot(soybean_trend_forecast)
> soybean_seasonal_forecast=forecast(soybean_seasonal,h=36)
> plot(soybean_seasonal_forecast)
> #Create time series object
>
> soybean_residuals_ts=ts(soybean_residuals,frequency = 12,start=c(2000,1))
> # Fit an MA(1) model to the residuals
>
> soybean_residuals_model <- arima(soybean_residuals_ts, order=c(0,0,1))
> #Forecast residual for three years
>
> soybean_residuals_forecast=forecast(soybean_residuals_model,h=36)$mean
> plot(soybean_residuals_forecast)
> #Combine three forecasts
>
> soybean_forecast_combined=soybean_trend_forecast$mean + soybean_seasonal_forecast$mean + soybean_residuals_forecast
> plot(soybean_forecast_combined)
> #Create data frame
>
> soybean_forecast_combined_df=tibble(soybean_forecast_combined)%>%
+
+ mutate(measure_date=seq(as_date("2023-01-01"), .... [TRUNCATED]
> soybean_forecast_combined_df=soybean_forecast_combined_df %>%
+
+ filter(measure_date > max(soybean_decomp_out$measure_date)) %>%
+
+ mu .... [TRUNCATED]
> final_out=bind_cols(soybean_decomp_out,adjstd_soybean_df)
> final_out=final_out[,-7]%>%
+
+ rename(measure_date=measure_date...5)
> final_out_forecast=bind_rows(final_out,soybean_forecast_combined_df)
> write.csv(final_out_forecast,"soybean_forecast.csv")