Create a sample gas extraction dataset

gas_data <- data.frame(
  Well = rep(c("Well1", "Well2", "Well3"), each = 10),
  Time = rep(1:10, 3),
  Production_Rate = c(
    100, 95, 90, 85, 80, 75, 70, 65, 60, 55,
    120, 115, 110, 105, 100, 95, 90, 85, 80, 75,
    150, 145, 140, 135, 130, 125, 120, 115, 110, 105
  ),
  Pressure = c(
    2000, 1950, 1900, 1850, 1800, 1750, 1700, 1650, 1600, 1550,
    2200, 2150, 2100, 2050, 2000, 1950, 1900, 1850, 1800, 1750,
    2500, 2450, 2400, 2350, 2300, 2250, 2200, 2150, 2100, 2050
  ),
  Temperature = c(
    150, 145, 140, 135, 130, 125, 120, 115, 110, 105,
    160, 155, 150, 145, 140, 135, 130, 125, 120, 115,
    170, 165, 160, 155, 150, 145, 140, 135, 130, 125
  )
)

Explore the data

head(gas_data) %>% gt() %>% 
    opt_stylize(style=4,color="green")
Well Time Production_Rate Pressure Temperature
Well1 1 100 2000 150
Well1 2 95 1950 145
Well1 3 90 1900 140
Well1 4 85 1850 135
Well1 5 80 1800 130
Well1 6 75 1750 125
summary(gas_data)
##      Well                Time      Production_Rate     Pressure   
##  Length:30          Min.   : 1.0   Min.   : 55.00   Min.   :1550  
##  Class :character   1st Qu.: 3.0   1st Qu.: 81.25   1st Qu.:1812  
##  Mode  :character   Median : 5.5   Median :100.00   Median :2000  
##                     Mean   : 5.5   Mean   :100.83   Mean   :2008  
##                     3rd Qu.: 8.0   3rd Qu.:118.75   3rd Qu.:2188  
##                     Max.   :10.0   Max.   :150.00   Max.   :2500  
##   Temperature   
##  Min.   :105.0  
##  1st Qu.:125.0  
##  Median :137.5  
##  Mean   :137.5  
##  3rd Qu.:150.0  
##  Max.   :170.0

Visualize production rate over time for each well

ggplot(gas_data, aes(x = Time, y = Production_Rate, color = Well)) +
  geom_line() +
  labs(title = "Production Rate Over Time", x = "Time", y = "Production Rate")

Production rate of gas is decreasing monotonic with time.

Visualize relationship between production rate and pressure

ggplot(gas_data, aes(x = Pressure, y = Production_Rate, color = Well)) +
  geom_point() +
  labs(title = "Relationship Between Production Rate and Pressure", x = "Pressure", y = "Production Rate")

As we observe Pressure has a linear effect on the production rate.

Visualize relationship between production rate and temperature

ggplot(gas_data, aes(x = Temperature, y = Production_Rate, color = Well)) +
  geom_point() +
  labs(title = "Relationship Between Production Rate and Temperature", x = "Temperature", y = "Production Rate")

There exists a linear relationship between Temperature and production rate of gas across all wells.

Calculate decline rate for each well

decline_rate <- gas_data %>%
  group_by(Well) %>%
  summarise(Decline_Rate = (Production_Rate[1] - Production_Rate[n()]) / (Time[n()] - Time[1]))

Regression of Production Rate

Model <- lm(Production_Rate ~ Pressure+Temperature,
   data = gas_data)
summary(Model)
## 
## Call:
## lm(formula = Production_Rate ~ Pressure + Temperature, data = gas_data)
## 
## Residuals:
##        Min         1Q     Median         3Q        Max 
## -1.228e-14 -6.130e-15 -2.196e-15  1.661e-15  4.880e-14 
## 
## Coefficients:
##               Estimate Std. Error    t value Pr(>|t|)    
## (Intercept) -1.000e+02  1.789e-14 -5.591e+15   <2e-16 ***
## Pressure     1.000e-01  1.937e-17  5.162e+15   <2e-16 ***
## Temperature  7.400e-16  2.940e-16  2.517e+00   0.0181 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.157e-14 on 27 degrees of freedom
## Multiple R-squared:      1,  Adjusted R-squared:      1 
## F-statistic: 7.041e+31 on 2 and 27 DF,  p-value: < 2.2e-16

Studying most risk factor on Production rate

library(rpart)
library(rpart.plot)
rpart(gas_data$Production_Rate ~., data=gas_data)
## n= 30 
## 
## node), split, n, deviance, yval
##       * denotes terminal node
## 
## 1) root 30 18854.170 100.8333  
##   2) Pressure< 2025 16  2875.000  81.2500 *
##   3) Pressure>=2025 14  2830.357 123.2143 *
model <- rpart(gas_data$Production_Rate ~ ., data=gas_data)
rpart.plot(model)

As we observe pressure is the most affecting factor so that for pressure<2025 there is 53% production rate of gas.