library(psych)
library(sjPlot)
## Install package "strengejacke" from GitHub (`devtools::install_github("strengejacke/strengejacke")`) to load all sj-packages at once!
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)
)
# Calculate the maximum possible production based on available reserves
country_data$Maximum_Production <- pmin(country_data$Production_Capacity, country_data$Total_Reserves)
# Calculate the total maximum production for OPEC countries
total_maximum_OPEC_production <- sum(country_data$Maximum_Production)
# Create a data frame with World Production (constrained by maximum possible production) and Price
data_with_reserves <- data.frame(
World_Production = total_maximum_OPEC_production, # Total maximum production is the sum of OPEC countries
Price = c(85.05, 85.52, 81.52, 78.84, 78.86, 74.96, 72.55, 71.40, 70.58, 64.42, 66.66, 62.79, 60.68, 54.04, 57.26, 57.84, 48.88, 54.29, 50.18, 45.66)
)
# Fit a linear regression model to predict production constrained by reserves
model_with_reserves <- lm(World_Production ~ Price, data = data_with_reserves)
# Kuwait's specific data
kuwait_price <- 66.09 # The average price is used for Kuwait
# Calculate the maximum possible production for Kuwait based on available reserves
kuwait_maximum_production <- pmin(3300, 35000) # Production Capacity for Kuwait is 3300, Total Reserves are 35000
# Create a data frame with Kuwait's data (constrained by reserves)
kuwait_data <- data.frame(
Price = kuwait_price,
Maximum_Production = kuwait_maximum_production
)
# Predict the quantity for Kuwait considering available reserves and capacity
predicted_quantity_kuwait_with_reserves <- predict(model_with_reserves, newdata = kuwait_data)
# Print the predicted quantity for Kuwait (constrained by reserves and capacity)
print(predicted_quantity_kuwait_with_reserves)
## 1
## 33700
# Interpretation
## The predicted oil production for Kuwait, considering both production capacity and available reserves, is estimated to be 33,700, or 33.7 thousand barrels per period.