library(psych)  
library(sjPlot)
library(lmSupport)
library(car)
## Loading required package: carData
## 
## Attaching package: 'car'
## The following object is masked from 'package:psych':
## 
##     logit
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() ──
## ✖ ggplot2::%+%()   masks psych::%+%()
## ✖ ggplot2::alpha() masks psych::alpha()
## ✖ dplyr::filter()  masks stats::filter()
## ✖ dplyr::lag()     masks stats::lag()
## ✖ dplyr::recode()  masks car::recode()
## ✖ purrr::some()    masks car::some()
library(psych)
library(car)
library(rmarkdown)
library(ggplot2)
library(tibble)
library(ggplot2)
library(Hmisc)
## Loading required package: lattice
## Loading required package: survival
## Loading required package: Formula
## 
## Attaching package: 'Hmisc'
## 
## The following objects are masked from 'package:dplyr':
## 
##     src, summarize
## 
## The following object is masked from 'package:psych':
## 
##     describe
## 
## The following objects are masked from 'package:base':
## 
##     format.pval, units
library(apaTables)
library(nlme)
## 
## Attaching package: 'nlme'
## 
## The following object is masked from 'package:dplyr':
## 
##     collapse
library(lmtest)
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## 
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
library(psych)
library(lme4)
## Loading required package: Matrix
## 
## Attaching package: 'Matrix'
## 
## The following objects are masked from 'package:tidyr':
## 
##     expand, pack, unpack
## 
## 
## Attaching package: 'lme4'
## 
## The following object is masked from 'package:nlme':
## 
##     lmList
library(dplyr)
library(ggplot2)
library(latexpdf)

Dataset

#Data File
O <- read.csv("OPECdata.csv", header = T, na.strings=c(".", "", " ", "NA", "-99"))

#Sample Size: Number of participants (rows)
nrow(O)
## [1] 20
#Print names of columns
names(O)
## [1] "Price"                      "World_Production"          
## [3] "ROW_Production"             "Total_Reserves_Kuwait"     
## [5] "Production_Capacity_Kuwait" "Marginal_Cost_Kuwait"

Predictions

Oct 23 2023 Kuwait

# Create a data frame with the provided country data
country_data <- data.frame(
  Country = c("Saudi Arabia", "Iran", "Iraq", "Kuwait", "UAE", "Venezuela", "Nigeria"),
  Total_Reserves = c(130000, 45000, 50000, 35000, 35000, 45000, 27500),
  Production_Capacity = c(12000, 4600, 3700, 3300, 3000, 4400, 2700),
  Marginal_Cost = c(6, 7, 8, 6, 5, 8, 8)
)

# Create a data frame with the price and world production data
price_data <- data.frame(
  Price = c(85.52, 85.05, 81.52, 78.86, 78.84, 74.96, 72.55, 71.40, 70.58, 66.66, 64.42, 62.79, 60.68, 57.84, 57.26, 54.29, 54.04, 50.18, 48.88, 45.66),
  World_Production = c(60026, 59661, 60340, 60901, 60564, 61543, 61599, 61705, 61873, 62574, 62505, 62808, 63356, 64026, 63767, 64653, 63740, 64663, 64541, 65054),
  ROW_Production = c(48968, 48448, 48252, 48061, 47739, 47554, 47028, 46753, 46520, 46095, 45668, 45253, 45241, 45101, 44884, 44819, 43893, 43758, 43234, 42910)
)

# Calculate OPEC's total production
opec_production <- sum(country_data$Production_Capacity)

# Calculate the rest of the world (ROW) production
row_production <- sum(price_data$ROW_Production)

# Calculate market demand (total world production)
market_demand <- sum(price_data$World_Production)

# Calculate residual demand
residual_demand <- market_demand - (opec_production + row_production)

# Print the residual demand
cat("Residual Demand:", residual_demand, "\n")
## Residual Demand: 296020
# Calculate the price in the competitive monopoly scenario
price_monopoly <- market_demand - row_production

# Print the estimated price
cat("Estimated Price in the OPEC Competitive Monopoly Scenario:", price_monopoly, "\n")
## Estimated Price in the OPEC Competitive Monopoly Scenario: 329720
# Define Kuwait's production capacity limit
kuwait_capacity_limit <- 3300  # Kuwait's production capacity limit is 3,300 thousand barrels

# Create a data frame with Kuwait's data (separate from country_data)
kuwait_data <- data.frame(
  Country = c("Kuwait"),
  Total_Reserves = c(35000),
  Production_Capacity = c(kuwait_capacity_limit),
  Marginal_Cost = c(6)
)

# Define the price (as a monopoly, OPEC would set the price)
prices <- c(85.52, 85.05, 81.52, 78.86, 78.84, 74.96, 72.55, 71.40, 70.58, 66.66, 64.42, 62.79, 60.68, 57.84, 57.26, 54.29, 54.04, 50.18, 48.88, 45.66)

# Initialize a vector to store Kuwait's production
kuwait_production <- numeric(length(prices))

# Calculate Kuwait's profit-maximizing production for each price
for (i in 1:length(prices)) {
  kuwait_production[i] <- (prices[i] - kuwait_data$Marginal_Cost) * kuwait_capacity_limit
  # Ensure that Kuwait's production does not exceed its capacity limit
  if (kuwait_production[i] > kuwait_capacity_limit) {
    kuwait_production[i] <- kuwait_capacity_limit
  }
}

# Print the estimated production for each price
cat("Estimated Kuwait's Production in the OPEC Monopoly with Competitive Fringe:\n")
## Estimated Kuwait's Production in the OPEC Monopoly with Competitive Fringe:
print(kuwait_production)
##  [1] 3300 3300 3300 3300 3300 3300 3300 3300 3300 3300 3300 3300 3300 3300 3300
## [16] 3300 3300 3300 3300 3300