1. MLR of Permeability given all well logs without Facies.
  2. Apply Stepwise Elimination on the previous model.
  3. MLR of Permeability given all well logs with Facies.
  4. Apply Stepwise Elimination on the previous model
  5. MLR of Log10(Permeability) given all well logs with Facies.
  6. Apply Stepwise Elimination on the previous model
  7. Random Subsampling Cross-Validation applied on MLR of Log10(Permeability) given all well logs with Facies .
  8. Apply Stepwise Elimination on the previous model.

#Loading Data…

data=read.csv("karpur.csv")
library(caret)
## Warning: package 'caret' was built under R version 4.4.2
## Loading required package: ggplot2
## Warning: package 'ggplot2' was built under R version 4.4.2
## Loading required package: lattice

#MLR of Permeability given all well logs without Facies.

model_1 <- lm(k.core~ . - Facies , data=data)
k.predicted_1 <-predict(model_1 , data=data)
Rsaquard_1 <- summary(model_1)$adj.r.squared
rmse_1 <- RMSE(k.predicted_1,data$k.core )
cat("Adjusted R2:", Rsaquard_1, " | RMSE:", rmse_1)
## Adjusted R2: 0.5841845  | RMSE: 1430.118

#Plotting …

par(  mfrow = c(1, 2) , oma = c(0, 0, 2, 0) )
plot(data$k.core, data$depth, xlab = "Measured Permeability", ylab = "Depth", ylim = rev(c(5667,6083)), xlim = c(0,15000), type = "l" , col = "black")
plot(k.predicted_1, data$depth, xlab = "Predicted Permeability", ylab = "Depth", ylim = rev(c(5667,6083)),  xlim = c(0,15000),type = "l" , col = "blue")
mtext("MLR of Permeability given all well logs without Facies.", side = 3 , outer = TRUE , cex = 1.5)

#Stepwise Elimination on the previous model

sink(tempfile())
model_2 <- step(model_1 , direction = "backward")
sink()
k.predicted_2 <- predict(model_2,data=data)
Rsaquard_2 <- summary(model_2)$adj.r.squared
rmse_2 <- RMSE(k.predicted_2,data$k.core )


cat("Adjusted R2:", Rsaquard_2, " | RMSE:", rmse_2)
## Adjusted R2: 0.5846949  | RMSE: 1430.126

#Plotting …

par(  mfrow = c(1, 2) , oma = c(0, 0, 2, 0) )
plot(data$k.core, data$depth, xlab = "Measured Permeability", ylab = "Depth", ylim = rev(c(5667,6083)), xlim = c(0,15000), type = "l" , col = "black")
plot(k.predicted_2, data$depth, xlab = "Predicted Permeability", ylab = "Depth", ylim = rev(c(5667,6083)), xlim = c(0,15000), type = "l" , col = "blue")
mtext("Stepwise Elimination MLR of Permeability given all well logs without Facies.", side = 3 , outer = TRUE , cex = 1)

#MLR of Permeability given all well logs with Facies.

model_3<- lm(k.core~ .,data=data)
Rsaquard_3 <- summary(model_3)$adj.r.squared
k.predicted_3 <-predict(model_3,data=data)
Rsaquard_3 <- summary(model_3)$adj.r.squared
rmse_3<- RMSE(k.predicted_3,data$k.core )

cat("Adjusted R2:", Rsaquard_3, " | RMSE:", rmse_3)
## Adjusted R2: 0.6814911  | RMSE: 1246.201

#Plotting …

par(  mfrow = c(1, 2) , oma = c(0, 0, 2, 0) )
plot(data$k.core, data$depth, xlab = "Measured Permeability", ylab = "Depth", ylim = rev(c(5667,6083)), xlim = c(0,15000), type = "l" , col = "black")
plot(k.predicted_3, data$depth, xlab = "Predicted Permeability", ylab = "Depth", ylim = rev(c(5667,6083)), xlim = c(0,15000), type = "l" , col = "blue")
mtext("MLR of Permeability given all well logs with Facies.", side = 3 , outer = TRUE , cex = 1.5)

#Stepwise Elimination on the previous model

sink(tempfile())
model_4<-step(model_3 , direction = "backward")
sink()
k.predicted_4 <-predict(model_4,data=data)

Rsaquard_4 <- summary(model_4)$adj.r.squared
rmse_4<- RMSE(k.predicted_4,data$k.core )
cat("Adjusted R2:", Rsaquard_4, " | RMSE:", rmse_4)
## Adjusted R2: 0.6815901  | RMSE: 1249.122

#Plotting …

par(  mfrow = c(1, 2) , oma = c(0, 0, 2, 0) )
plot(data$k.core, data$depth, xlab = "Measured Permeability", ylab = "Depth", ylim = rev(c(5667,6083)), xlim = c(0,15000), type = "l" , col = "black")
plot(k.predicted_4, data$depth, xlab = "Predicted Permeability", ylab = "Depth", ylim = rev(c(5667,6083)), xlim = c(0,15000), type = "l" , col = "blue")
mtext("Stepwise Elimination MLR of Permeability given all well logs with Facies.", side = 3 , outer = TRUE , cex = 1)

#MLR of Log10(Permeability) given all well logs with Facies.

data$log10_k.core <- log10(data$k.core)
model_5<- lm(log10_k.core ~ . - k.core  ,data=data)
log_k.predicted_5 <-predict(model_5,data=data)
k.predicted_5<-10^log_k.predicted_5

Rsaquard_5 <- summary(model_5)$adj.r.squared
rmse_5<- RMSE(k.predicted_5,data$k.core )
cat("Adjusted R2:", Rsaquard_5, " | RMSE:", rmse_5)
## Adjusted R2: 0.6729783  | RMSE: 1333.017

#Plotting …

par(  mfrow = c(1, 2) , oma = c(0, 0, 2, 0) )
plot(data$k.core, data$depth, xlab = "Measured Permeability", ylab = "Depth", ylim = rev(c(5667,6083)),xlim = c(0,15000), type = "l" , col = "black")
plot(k.predicted_5, data$depth, xlab = "Predicted Permeability", ylab = "Depth", ylim = rev(c(5667,6083)),xlim = c(0,15000), type = "l" , col = "blue")
mtext("MLR of Log10(Permeability) given all well logs with Facies.", side = 3 , outer = TRUE , cex = 1.5)

#Stepwise Elimination on the previous model

sink(tempfile())
model_6<-step(model_5, direction = "backward")
sink()
log_k.predicted_6 <-predict(model_6,data=data)
k.predicted_6 <- 10^log_k.predicted_6

Rsaquard_6 <- summary(model_6)$adj.r.squared
rmse_6<- RMSE(k.predicted_6,data$k.core )
cat("Adjusted R2:", Rsaquard_6, " | RMSE:", rmse_6)
## Adjusted R2: 0.6722495  | RMSE: 1330.932

#Plotting …

par(  mfrow = c(1, 2) , oma = c(0, 0, 2, 0) )
plot(data$k.core, data$depth, xlab = "Measured Permeability", ylab = "Depth", ylim = rev(c(5667,6083)),xlim = c(0,15000), type = "l" , col = "black")
plot(k.predicted_6, data$depth, xlab = "Predicted Permeability", ylab = "Depth", ylim = rev(c(5667,6083)),xlim = c(0,15000), type = "l" , col = "blue")
mtext("Stepwise Elimination MLR of Log10(Permeability) given all well logs with Facies.", side = 3 , outer = TRUE , cex = 1)

#Random Subsampling Cross-Validation applied on MLR of Log10(Permeability)

library(dplyr)
## Warning: package 'dplyr' was built under R version 4.4.2
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
set.seed(12345)
training<-sample_frac(data, .76)
testing<-anti_join(data,training)
## Joining with `by = join_by(depth, caliper, ind.deep, ind.med, gamma, phi.N,
## R.deep, R.med, SP, density.corr, density, phi.core, k.core, Facies,
## log10_k.core)`
model_7<- lm(log10_k.core~.-k.core,data=training)
log_k.predicted_7 <-predict(model_7,newdata=testing)
k.predicted_7<-10^log_k.predicted_7


Rsaquard_7 <- summary(model_7)$adj.r.squared
rmse_7<- RMSE(k.predicted_7,testing$k.core )
cat("Adjusted R2:", Rsaquard_7, " | RMSE:", rmse_7)
## Adjusted R2: 0.6612391  | RMSE: 1513.307

#Plotting …

par(  mfrow = c(1, 2) , oma = c(0, 0, 2, 0) )
plot(testing$k.core, testing$depth, xlab = "Testing Permeability", ylab = "Depth", ylim = rev(c(5667,6083)),xlim = c(0,15000), type = "l" , col = "black")
plot(k.predicted_7, testing$depth, xlab = "Predicted Permeability", ylab = "Depth", ylim = rev(c(5667,6083)),xlim = c(0,15000), type = "l" , col = "blue")
mtext("Random Subsampling Cross-Validation applied on MLR of Log10(Permeability)", side = 3 , outer = TRUE , cex = 1)

#Stepwise Elimination on the previous model

sink(tempfile())
model_8<-step(model_7, direction = "backward")
sink()
log_k.predicted_8 <-predict(model_8,newdata=testing)
k.predicted_8<-10^log_k.predicted_8


Rsaquard_8 <- summary(model_8)$adj.r.squared
rmse_8<- RMSE(k.predicted_8,testing$k.core )
cat("Adjusted R2:", Rsaquard_8, " | RMSE:", rmse_8)
## Adjusted R2: 0.6619234  | RMSE: 1523.276

#Plotting …

par(  mfrow = c(1, 2) , oma = c(0, 0, 2, 0) )
plot(testing$k.core, testing$depth, xlab = "Testing Permeability", ylab = "Depth", ylim = rev(c(5667,6083)),xlim = c(0,15000), type = "l" , col = "black")
plot(k.predicted_8, testing$depth, xlab = "Predicted Permeability", ylab = "Depth", ylim = rev(c(5667,6083)),xlim = c(0,15000), type = "l" , col = "blue")
mtext("Stepwise Elimination Random Subsampling Cross-Validation applied on MLR of Log10(Permeability)", side = 3 , outer = TRUE , cex = 0.8)

#Create a dataframe summarizing the results

results <- data.frame(
  Model = c("Model 1", "Model 2", "Model 3", "Model 4", "Model 5", "Model 6", "Model 7", "Model 8"),
  Adjusted_R_Squared = c(Rsaquard_1, Rsaquard_2, Rsaquard_3, Rsaquard_4, Rsaquard_5, Rsaquard_6, Rsaquard_7, Rsaquard_8),
  RMSE = c(rmse_1, rmse_2, rmse_3, rmse_4, rmse_5, rmse_6, rmse_7, rmse_8),
  Comments = c(
    "MLR of Permeability without Facies.",
    "Stepwise Elimination on Model 1.",
    "MLR of Permeability with Facies.",
    "Stepwise Elimination on Model 3.",
    "MLR of Log10(Permeability) with Facies.",
    "Stepwise Elimination on Model 5.",
    "Random Subsampling Cross-Validation on Log10 MLR (training set).",
    "Stepwise Elimination on Model 7 (testing set)."
  )
)
results
##     Model Adjusted_R_Squared     RMSE
## 1 Model 1          0.5841845 1430.118
## 2 Model 2          0.5846949 1430.126
## 3 Model 3          0.6814911 1246.201
## 4 Model 4          0.6815901 1249.122
## 5 Model 5          0.6729783 1333.017
## 6 Model 6          0.6722495 1330.932
## 7 Model 7          0.6612391 1513.307
## 8 Model 8          0.6619234 1523.276
##                                                           Comments
## 1                              MLR of Permeability without Facies.
## 2                                 Stepwise Elimination on Model 1.
## 3                                 MLR of Permeability with Facies.
## 4                                 Stepwise Elimination on Model 3.
## 5                          MLR of Log10(Permeability) with Facies.
## 6                                 Stepwise Elimination on Model 5.
## 7 Random Subsampling Cross-Validation on Log10 MLR (training set).
## 8                   Stepwise Elimination on Model 7 (testing set).