---

title: “Corn Production” format: html editor: visual ---

The Impact of Drought on Corn Production and Prices in Iowa.

Drought is a major concern for agricultural production, especially in the Midwest where corn is a significant crop. Iowa is the leading producer of corn in the United States, making it an important state to study the impact of drought on corn production and prices. This research proposal aims to investigate the following:

Ø  The historical impact of drought on corn production and prices in Iowa: This study will use historical data on drought and corn production in Iowa to analyze how drought has affected corn production and prices in the past. The analysis will also identify the key factors that contributed to the impact of drought on corn production and prices.

Ø  The potential impact of future droughts on corn production in Iowa and prices  Iowa: This study will use climate change projections and models to forecast the potential impact of future droughts on corn production and prices in Iowa. The analysis will consider the different scenarios of drought severity and their impact on corn production and prices.

Methodology:

Data collection:

Data cleaning:

  • Clean and preprocess the data to remove any outliers, missing values, or errors that may affect the analysis.

The data did not require cleaning. Only the PDSI metric converted to annual one by taking the average

Exploratory data analysis

Conduct exploratory data analysis (EDA) to understand the distribution and relationships among the variables. Use R packages such as ggplot2 for data visualization.

  • Drought analysis: Analyze the historical climate data to identify periods of drought in Iowa. Use R packages such as climatol and ggplot2 for climate analysis and visualization.

  • Corn production analysis: Analyze the historical corn production data to identify the relationship between drought and corn yields in Iowa. Use R packages such as ggplot2 and tidyr for data analysis and visualization.

  • Corn price analysis: Analyze the historical corn price data to identify the relationship between corn prices and corn production in Iowa. Use R packages such as ggplot2 and dplyr for data analysis and visualization.

Modeling

Develop statistical models to estimate the impact of drought on corn production and prices in Iowa. You can use regression models, time series models, or machine learning models for this analysis. Use R packages such as lm, arima, prophet, and randomForest for modeling.

Sensitivity analysis

Conduct sensitivity analysis to evaluate the robustness of the models to changes in input parameters and assumptions. Use R packages such as sensitivity and ggplot2 for sensitivity analysis and visualization.

Reporting

Present the results of the analysis in a clear and concise manner using data visualization, tables, and text..

Conclusion

Draw conclusions and based on the analysis

library(tidyverse) 
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
✔ ggplot2 3.4.0     ✔ purrr   1.0.1
✔ tibble  3.1.8     ✔ dplyr   1.1.0
✔ tidyr   1.3.0     ✔ stringr 1.5.0
✔ readr   2.1.3     ✔ forcats 1.0.0
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
library(readxl)
library(tidyr)
library(dplyr)
Corn_Prod_Data <- read_csv("C:/Users/aishu/OneDrive/Desktop/Corn Production Data ( Final).csv", skip = 1)
Rows: 33 Columns: 7
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
dbl (7): Year, Average Temperature (Deg F), Precipitation (Inches), Average ...

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
print(Corn_Prod_Data)
# A tibble: 33 × 7
    Year `Average Temperature (Deg F)` Precipi…¹ Avera…² Yeild…³ Produ…⁴ Corn …⁵
   <dbl>                         <dbl>     <dbl>   <dbl>   <dbl>   <dbl>   <dbl>
 1  1990                          47.6      29.6  -1.41      126  1.56e9    2.52
 2  1991                          46.7      32.7   0.519     117  1.43e9    2.47
 3  1992                          46.1      34.5   2.83      147  1.90e9    2.39
 4  1993                          43.2      39.4   5.87       80  8.8 e8    2.39
 5  1994                          45.4      28.0   3.63      152  1.92e9    2.50
 6  1995                          45.4      32.2   3.12      123  1.43e9    2.81
 7  1996                          43        29.9   2.52      138  1.71e9    3.67
 8  1997                          45.3      23.4   0.931     138  1.64e9    2.75
 9  1998                          49.1      31.4   0.383     145  1.77e9    2.38
10  1999                          48.1      24.8  -0.318     149  1.76e9    2.12
# … with 23 more rows, and abbreviated variable names
#   ¹​`Precipitation (Inches)`, ²​`Average Palmer Drought Severity Index (PDSI)`,
#   ³​`Yeild (BU/Acre)`, ⁴​`Production (BU)`, ⁵​`Corn Price (USD)`
# Load required packages
library(ggplot2)


ggplot(Corn_Prod_Data, aes(x = Year)) +
  geom_line(aes(y = `Average Temperature (Deg F)`, color = "Average Temperature (Deg F)")) +
  geom_line(aes(y = `Precipitation (Inches)`, color = "Precipitation (Inches)")) +
  geom_line(aes(y =`Average Palmer Drought Severity Index (PDSI)`, color = "Average Palmer Drought Severity Index (PDSI)")) +
  labs(x = "Year", y = "Value", color = "Variable") +
  scale_color_manual(values = c("red", "blue", "green"))

library(ggplot2)

ggplot(data =Corn_Prod_Data, aes(x = Year, y = `Average Palmer Drought Severity Index (PDSI)`, group = 1)) +
  geom_line(aes(colour = ifelse(`Average Palmer Drought Severity Index (PDSI)` >= 0, "brown", "green"))) +
  scale_color_manual(values = c("green", "brown"), 
                     guide = guide_legend(title = "PDSI")) +
  labs(x = "Year", y = "Average PDSI", title = "Average Palmer Drought Severity Index (PDSI)", 
       subtitle = "The Palmer Drought Severity Index (PDSI)  is a standardized index that generally spans -10 (dry) to +10 (wet).") +
  theme_bw() +
  theme(plot.title = element_text(size = 14, face = "bold"),
        plot.subtitle = element_text(size = 12),
        legend.position = "bottom") +
  geom_hline(yintercept = 0, linetype = "dashed")

library(ggplot2)

# create scatter plot
ggplot(Corn_Prod_Data, aes(x = Year, y =`Average Temperature (Deg F)`)) +
  geom_point() +
  geom_smooth(method = "lm", se = FALSE) +
  labs(x = "Year", y ="Average Temperature (Deg F)", 
       title = "Average Temperature Trend")
`geom_smooth()` using formula = 'y ~ x'

# create scatter plot
ggplot(Corn_Prod_Data, aes(x = Year, y =`Precipitation (Inches)`)) +
  geom_point() +
  geom_smooth(method = "lm", se = FALSE) +
  labs(x = "Year", y ="Precipitation (Inches)", 
       title = "Precipitation Trend")
`geom_smooth()` using formula = 'y ~ x'

ggplot(Corn_Prod_Data, aes(x = Year, y = `Yeild (BU/Acre)`)) +
  geom_line() +
  ylab("Yield") +
  scale_y_continuous()

ggplot(Corn_Prod_Data, aes(x = Year, y = `Production (BU)`)) +
  geom_line() +
  ylab("Productions(Bu)") +
  scale_y_continuous()

ggplot(Corn_Prod_Data, aes(x = Year, y = `Production (BU)`)) +
  geom_point() +
  geom_smooth(method = "lm", se = FALSE) +
  xlab("Production") +
  ylab("Price")
`geom_smooth()` using formula = 'y ~ x'

ggplot(Corn_Prod_Data, aes(x = Year, y = `Yeild (BU/Acre)`)) +
  geom_point() +
  geom_smooth(method = "lm", se = FALSE) +
  xlab("Yield") +
  ylab("Price")
`geom_smooth()` using formula = 'y ~ x'