pacman::p_load(rio,psych,ggplot2)
karpur_data <- read.csv("karpur.csv")
data <- read.csv("karpur.csv")
library(Metrics)
## Warning: package 'Metrics' was built under R version 4.4.2

step1: MLR model to predict Permeability using all well logs without facies

Predicted_Permeabiity_Model_1<- lm(k.core~ .-Facies,data=data)
summary(Predicted_Permeabiity_Model_1 )
## 
## Call:
## lm(formula = k.core ~ . - Facies, data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5549.5  -755.5  -178.1   578.0 11260.8 
## 
## Coefficients: (1 not defined because of singularities)
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    60762.728  16605.360   3.659 0.000269 ***
## depth             -7.398      1.446  -5.115 3.92e-07 ***
## caliper        -3955.952   1055.105  -3.749 0.000190 ***
## ind.deep         -14.183      2.345  -6.048 2.24e-09 ***
## ind.med           17.300      2.509   6.896 1.08e-11 ***
## gamma            -77.487      5.475 -14.153  < 2e-16 ***
## phi.N          -1784.704   1301.772  -1.371 0.170763    
## R.deep           -26.007      6.974  -3.729 0.000206 ***
## R.med             63.525      9.841   6.455 1.86e-10 ***
## SP                -8.784      3.460  -2.539 0.011313 *  
## density.corr    -523.060   5358.876  -0.098 0.922269    
## density         8011.106   1120.554   7.149 1.96e-12 ***
## phi.core         183.203     23.802   7.697 4.07e-14 ***
## Phi.core.frac.        NA         NA      NA       NA    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1442 on 806 degrees of freedom
## Multiple R-squared:  0.5903, Adjusted R-squared:  0.5842 
## F-statistic: 96.77 on 12 and 806 DF,  p-value: < 2.2e-16
Predicted_Permeabiity_Model_1<- lm(k.core~ .-Facies,data=Karpur) summary(Predicted_Permeabiity_Model_1 )
Predicted_permeability_1 <- predict(Predicted_Permeabiity_Model_1, data = data)
library(ggplot2)
Predicted_permeability_1 <- predict(Predicted_Permeabiity_Model_1, data = data)
library(ggplot2)
ggplot (data) +
  geom_line(aes(x = depth, y = k.core, color = "Measured permeability")) +
  geom_line(aes(x = depth, y = Predicted_permeability_1, color = "Predicted permeability")) +
  labs(title = "Predicted vs Measured Permeability with Respect to Depth",
       x = "Depth",
       y = "Permeability",
       color = "Legend") +
  scale_color_manual(values = c("Measured permeability" = "red", 
                                 "Predicted permeability" = "black")) +
  theme_minimal()

Stepwise_Model_1<-step(Predicted_Permeabiity_Model_1, direction = "backward")
## Start:  AIC=11926.91
## k.core ~ (depth + caliper + ind.deep + ind.med + gamma + phi.N + 
##     R.deep + R.med + SP + density.corr + density + phi.core + 
##     Facies + Phi.core.frac.) - Facies
## 
## 
## Step:  AIC=11926.91
## k.core ~ depth + caliper + ind.deep + ind.med + gamma + phi.N + 
##     R.deep + R.med + SP + density.corr + density + phi.core
## 
##                Df Sum of Sq        RSS   AIC
## - density.corr  1     19799 1675068713 11925
## - phi.N         1   3906205 1678955118 11927
## <none>                      1675048914 11927
## - SP            1  13394190 1688443104 11931
## - R.deep        1  28897686 1703946599 11939
## - caliper       1  29214826 1704263740 11939
## - depth         1  54372650 1729421563 11951
## - ind.deep      1  76022788 1751071701 11961
## - R.med         1  86603706 1761652619 11966
## - ind.med       1  98823752 1773872666 11972
## - density       1 106221406 1781270319 11975
## - phi.core      1 123125117 1798174031 11983
## - gamma         1 416312526 2091361440 12107
## 
## Step:  AIC=11924.92
## k.core ~ depth + caliper + ind.deep + ind.med + gamma + phi.N + 
##     R.deep + R.med + SP + density + phi.core
## 
##            Df Sum of Sq        RSS   AIC
## <none>                  1675068713 11925
## - phi.N     1   4564880 1679633593 11925
## - SP        1  13491079 1688559792 11930
## - R.deep    1  28896144 1703964857 11937
## - caliper   1  29253869 1704322581 11937
## - depth     1  54825159 1729893872 11949
## - ind.deep  1  77573926 1752642639 11960
## - R.med     1  86772220 1761840933 11964
## - ind.med   1 100740701 1775809413 11971
## - density   1 114209586 1789278299 11977
## - phi.core  1 124694278 1799762991 11982
## - gamma     1 417015194 2092083907 12105


summary(Stepwise_Model_1)
## 
## Call:
## lm(formula = k.core ~ depth + caliper + ind.deep + ind.med + 
##     gamma + phi.N + R.deep + R.med + SP + density + phi.core, 
##     data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5545.3  -753.4  -177.1   576.8 11260.2 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 60910.619  16525.937   3.686 0.000243 ***
## depth          -7.409      1.442  -5.139 3.46e-07 ***
## caliper     -3957.892   1054.270  -3.754 0.000186 ***
## ind.deep      -14.146      2.314  -6.113 1.52e-09 ***
## ind.med        17.263      2.478   6.967 6.74e-12 ***
## gamma         -77.461      5.465 -14.174  < 2e-16 ***
## phi.N       -1825.771   1231.150  -1.483 0.138470    
## R.deep        -25.972      6.961  -3.731 0.000204 ***
## R.med          63.466      9.816   6.466 1.75e-10 ***
## SP             -8.803      3.453  -2.549 0.010974 *  
## density      7980.761   1075.902   7.418 3.02e-13 ***
## phi.core      183.436     23.667   7.751 2.75e-14 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1441 on 807 degrees of freedom
## Multiple R-squared:  0.5903, Adjusted R-squared:  0.5847 
## F-statistic: 105.7 on 11 and 807 DF,  p-value: < 2.2e-16

plot the predicted vs measured permeability with respect to depth.

Predicted_permeability_2 <-predict(Stepwise_Model_1,data=data)

ggplot(data) +
  geom_line(aes(x = depth, y = k.core, color = "Measured permeability")) +
  geom_line(aes(x = depth, y = Predicted_permeability_2, color = "Predicted permeability")) +
  labs(title = "Predicted vs Measured Permeability with Respect to Depth",
       x = "Depth",
       y = "Permeability",
       color = "Legend") + 
  scale_color_manual(values = c("Measured permeability" = "red", 
                                 "Predicted permeability" = "black")) +
  theme_minimal()

step3 MLR model to predict Permeability using all well logs ,this time including facies

Predicted_Permeabiity_Model_2<- lm(k.core~ .,data=data)
summary(Predicted_Permeabiity_Model_2 )
## 
## Call:
## lm(formula = k.core ~ ., data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5585.6  -568.9    49.2   476.5  8928.4 
## 
## Coefficients: (1 not defined because of singularities)
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    -6.783e+04  1.760e+04  -3.853 0.000126 ***
## depth           8.544e+00  1.785e+00   4.786 2.02e-06 ***
## caliper         1.413e+03  1.019e+03   1.387 0.165789    
## ind.deep       -2.418e-01  2.354e+00  -0.103 0.918220    
## ind.med         1.224e+00  2.585e+00   0.473 0.636062    
## gamma          -4.583e+01  6.010e+00  -7.626 6.88e-14 ***
## phi.N          -2.010e+03  1.476e+03  -1.362 0.173540    
## R.deep         -2.344e+01  6.288e+00  -3.727 0.000207 ***
## R.med           5.643e+01  9.065e+00   6.225 7.76e-10 ***
## SP             -7.125e+00  3.145e+00  -2.266 0.023736 *  
## density.corr   -2.567e+03  4.809e+03  -0.534 0.593602    
## density         2.319e+03  1.173e+03   1.976 0.048458 *  
## phi.core        1.921e+02  2.282e+01   8.418  < 2e-16 ***
## FaciesF10       8.921e+02  3.590e+02   2.485 0.013157 *  
## FaciesF2        9.243e+02  5.818e+02   1.589 0.112514    
## FaciesF3        4.393e+02  3.344e+02   1.313 0.189394    
## FaciesF5        7.411e+02  3.428e+02   2.162 0.030908 *  
## FaciesF7       -4.152e+01  5.742e+02  -0.072 0.942377    
## FaciesF8       -1.179e+03  3.927e+02  -3.002 0.002770 ** 
## FaciesF9       -2.969e+03  4.298e+02  -6.908 1.00e-11 ***
## Phi.core.frac.         NA         NA      NA       NA    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1262 on 799 degrees of freedom
## Multiple R-squared:  0.6889, Adjusted R-squared:  0.6815 
## F-statistic: 93.12 on 19 and 799 DF,  p-value: < 2.2e-16

plot the predicted vs measured permeability with respect to depth.

Predicted_permeability_3 <-predict(Predicted_Permeabiity_Model_2,data=data)

ggplot(data) +
  geom_line(aes(x = depth, y = k.core, color = "Measured permeability")) +
  geom_line(aes(x = depth, y = Predicted_permeability_3, color = "Predicted permeability")) +
  labs(title = "Predicted vs Measured Permeability with Respect to Depth",
       x = "Depth",
       y = "Permeability",
       color = "Legend") + 
  scale_color_manual(values = c("Measured permeability" = "red", 
                                 "Predicted permeability" = "black")) +
  theme_minimal()

Step4 Applying step wise elimination to this model.

Stepwise_Model_2<-step(Predicted_Permeabiity_Model_2, direction = "backward")
## Start:  AIC=11715.43
## k.core ~ depth + caliper + ind.deep + ind.med + gamma + phi.N + 
##     R.deep + R.med + SP + density.corr + density + phi.core + 
##     Facies + Phi.core.frac.
## 
## 
## Step:  AIC=11715.43
## k.core ~ depth + caliper + ind.deep + ind.med + gamma + phi.N + 
##     R.deep + R.med + SP + density.corr + density + phi.core + 
##     Facies
## 
##                Df Sum of Sq        RSS   AIC
## - ind.deep      1     16793 1271937992 11713
## - ind.med       1    356746 1272277945 11714
## - density.corr  1    453661 1272374861 11714
## - phi.N         1   2953609 1274874809 11715
## - caliper       1   3063007 1274984206 11715
## <none>                      1271921199 11715
## - density       1   6217927 1278139127 11717
## - SP            1   8171834 1280093033 11719
## - R.deep        1  22117394 1294038593 11728
## - depth         1  36466976 1308388176 11737
## - R.med         1  61690461 1333611660 11752
## - gamma         1  92579723 1364500923 11771
## - phi.core      1 112793101 1384714301 11783
## - Facies        7 403127714 1675048914 11927
## 
## Step:  AIC=11713.44
## k.core ~ depth + caliper + ind.med + gamma + phi.N + R.deep + 
##     R.med + SP + density.corr + density + phi.core + Facies
## 
##                Df Sum of Sq        RSS   AIC
## - density.corr  1    437546 1272375538 11712
## - phi.N         1   2938766 1274876758 11713
## - caliper       1   3074396 1275012389 11713
## <none>                      1271937992 11713
## - density       1   6228928 1278166920 11715
## - ind.med       1   6905855 1278843848 11716
## - SP            1   8191802 1280129794 11717
## - R.deep        1  22125695 1294063687 11726
## - depth         1  39139470 1311077462 11736
## - R.med         1  61773953 1333711946 11750
## - gamma         1  92865220 1364803212 11769
## - phi.core      1 112960440 1384898432 11781
## - Facies        7 479133709 1751071701 11961
## 
## Step:  AIC=11711.72
## k.core ~ depth + caliper + ind.med + gamma + phi.N + R.deep + 
##     R.med + SP + density + phi.core + Facies
## 
##            Df Sum of Sq        RSS   AIC
## - caliper   1   2980713 1275356252 11712
## <none>                  1272375538 11712
## - phi.N     1   3279032 1275654571 11712
## - density   1   5792837 1278168375 11713
## - ind.med   1   6813959 1279189497 11714
## - SP        1   8391302 1280766840 11715
## - R.deep    1  22009402 1294384940 11724
## - depth     1  38705776 1311081314 11734
## - R.med     1  61436819 1333812357 11748
## - gamma     1  93974329 1366349868 11768
## - phi.core  1 115336515 1387712053 11781
## - Facies    7 480267100 1752642639 11960
## 
## Step:  AIC=11711.64
## k.core ~ depth + ind.med + gamma + phi.N + R.deep + R.med + SP + 
##     density + phi.core + Facies
## 
##            Df Sum of Sq        RSS   AIC
## - phi.N     1   2534906 1277891157 11711
## <none>                  1275356252 11712
## - density   1   7270311 1282626562 11714
## - SP        1   8733336 1284089587 11715
## - ind.med   1  12924050 1288280301 11718
## - R.deep    1  22449117 1297805369 11724
## - depth     1  51507476 1326863728 11742
## - R.med     1  60137982 1335494234 11747
## - phi.core  1 112564835 1387921086 11779
## - gamma     1 141535555 1416891807 11796
## - Facies    7 520094756 1795451008 11978
## 
## Step:  AIC=11711.26
## k.core ~ depth + ind.med + gamma + R.deep + R.med + SP + density + 
##     phi.core + Facies
## 
##            Df Sum of Sq        RSS   AIC
## <none>                  1277891157 11711
## - density   1   5155969 1283047127 11713
## - SP        1   8515796 1286406953 11715
## - ind.med   1  10944937 1288836095 11716
## - R.deep    1  23273312 1301164469 11724
## - depth     1  49725248 1327616405 11740
## - R.med     1  59454645 1337345802 11746
## - phi.core  1 110154394 1388045551 11777
## - gamma     1 219059092 1496950249 11839
## - Facies    7 526383446 1804274603 11980
summary(Stepwise_Model_2)
## 
## Call:
## lm(formula = k.core ~ depth + ind.med + gamma + R.deep + R.med + 
##     SP + density + phi.core + Facies, data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5608.3  -567.8    35.9   500.7  8989.7 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -4.322e+04  6.625e+03  -6.523 1.22e-10 ***
## depth        6.648e+00  1.189e+00   5.590 3.11e-08 ***
## ind.med      1.078e+00  4.111e-01   2.623 0.008894 ** 
## gamma       -5.324e+01  4.537e+00 -11.733  < 2e-16 ***
## R.deep      -2.395e+01  6.264e+00  -3.824 0.000141 ***
## R.med        5.515e+01  9.022e+00   6.112 1.53e-09 ***
## SP          -7.214e+00  3.118e+00  -2.313 0.020960 *  
## density      1.880e+03  1.044e+03   1.800 0.072240 .  
## phi.core     1.817e+02  2.184e+01   8.320 3.77e-16 ***
## FaciesF10    8.266e+02  3.533e+02   2.340 0.019553 *  
## FaciesF2     7.035e+02  5.567e+02   1.264 0.206697    
## FaciesF3     4.100e+02  3.228e+02   1.270 0.204443    
## FaciesF5     5.913e+02  3.211e+02   1.841 0.065924 .  
## FaciesF7    -3.159e+02  5.402e+02  -0.585 0.558866    
## FaciesF8    -1.455e+03  3.122e+02  -4.661 3.69e-06 ***
## FaciesF9    -3.017e+03  3.764e+02  -8.017 3.82e-15 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1262 on 803 degrees of freedom
## Multiple R-squared:  0.6874, Adjusted R-squared:  0.6816 
## F-statistic: 117.7 on 15 and 803 DF,  p-value: < 2.2e-16

plot the predicted vs measured permeability with respect to depth.

Predicted_permeability_4 <-predict(Stepwise_Model_2,data=data)

ggplot(data) +
  geom_line(aes(x = depth, y = k.core, color = "Measured permeability")) +
  geom_line(aes(x = depth, y = Predicted_permeability_4, color = "Predicted permeability")) +
  labs(title = "Predicted vs Measured Permeability with Respect to Depth",
       x = "Depth",
       y = "Permeability",
       color = "Legend") + 
  scale_color_manual(values = c("Measured permeability" = "red", 
                                 "Predicted permeability" = "black")) +
  theme_minimal()

Step5 MLR model to predict log10(Permeability) using all well logs including facies.

data$log10_Permeability <-log10(data$k.core)
Predicted_Permeabiity_Model_3<- lm(log10_Permeability~.-k.core,data=data)
summary(Predicted_Permeabiity_Model_3 )
## 
## Call:
## lm(formula = log10_Permeability ~ . - k.core, data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.5804 -0.1138  0.0322  0.1529  0.7384 
## 
## Coefficients: (1 not defined because of singularities)
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    -2.3461877  4.6532000  -0.504  0.61425    
## depth           0.0007425  0.0004718   1.574  0.11596    
## caliper        -0.4605945  0.2693103  -1.710  0.08760 .  
## ind.deep       -0.0007951  0.0006222  -1.278  0.20168    
## ind.med         0.0007137  0.0006833   1.044  0.29659    
## gamma          -0.0091269  0.0015885  -5.746 1.30e-08 ***
## phi.N          -1.7628155  0.3901024  -4.519 7.16e-06 ***
## R.deep         -0.0025878  0.0016620  -1.557  0.11987    
## R.med           0.0044073  0.0023960   1.839  0.06622 .  
## SP             -0.0016935  0.0008312  -2.037  0.04194 *  
## density.corr    1.4462633  1.2712045   1.138  0.25558    
## density         1.6148374  0.3100921   5.208 2.44e-07 ***
## phi.core        0.0948634  0.0060329  15.724  < 2e-16 ***
## FaciesF10       0.0786460  0.0948909   0.829  0.40746    
## FaciesF2       -0.0184334  0.1537793  -0.120  0.90462    
## FaciesF3       -0.0307548  0.0883957  -0.348  0.72799    
## FaciesF5        0.1094193  0.0906034   1.208  0.22753    
## FaciesF7        0.2811620  0.1517797   1.852  0.06433 .  
## FaciesF8       -0.0976234  0.1038054  -0.940  0.34727    
## FaciesF9       -0.3562116  0.1135966  -3.136  0.00178 ** 
## Phi.core.frac.         NA         NA      NA       NA    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.3335 on 799 degrees of freedom
## Multiple R-squared:  0.6806, Adjusted R-squared:  0.673 
## F-statistic:  89.6 on 19 and 799 DF,  p-value: < 2.2e-16

plot the predicted vs measured permeability with respect to depth

Predicted_log10_permeability_5 <-predict(Predicted_Permeabiity_Model_3,data=data)
Predicted_permeability_5<-10^Predicted_log10_permeability_5 

ggplot(data) +
  geom_line(aes(x = depth, y = k.core, color = "Measured permeability")) +
  geom_line(aes(x = depth, y = Predicted_permeability_5, color = "Predicted permeability")) +
  labs(title = "Predicted vs Measured Permeability with Respect to Depth",
       x = "Depth",
       y = "Permeability",
       color = "Legend") + 
  scale_color_manual(values = c("Measured permeability" = "red", 
                                 "Predicted permeability" = "black")) +
  theme_minimal()

STEP6 Applying step wise elimination to this model.

Stepwise_Model_3<-step(Predicted_Permeabiity_Model_3, direction = "backward")
## Start:  AIC=-1779.02
## log10_Permeability ~ (depth + caliper + ind.deep + ind.med + 
##     gamma + phi.N + R.deep + R.med + SP + density.corr + density + 
##     phi.core + k.core + Facies + Phi.core.frac.) - k.core
## 
## 
## Step:  AIC=-1779.02
## log10_Permeability ~ depth + caliper + ind.deep + ind.med + gamma + 
##     phi.N + R.deep + R.med + SP + density.corr + density + phi.core + 
##     Facies
## 
##                Df Sum of Sq     RSS     AIC
## - ind.med       1    0.1213  88.981 -1779.9
## - density.corr  1    0.1440  89.004 -1779.7
## - ind.deep      1    0.1816  89.042 -1779.3
## <none>                       88.860 -1779.0
## - R.deep        1    0.2696  89.130 -1778.5
## - depth         1    0.2754  89.135 -1778.5
## - caliper       1    0.3253  89.185 -1778.0
## - R.med         1    0.3763  89.236 -1777.6
## - SP            1    0.4617  89.322 -1776.8
## - phi.N         1    2.2710  91.131 -1760.3
## - density       1    3.0160  91.876 -1753.7
## - gamma         1    3.6713  92.531 -1747.9
## - Facies        7    7.0758  95.936 -1730.3
## - phi.core      1   27.4982 116.358 -1560.2
## 
## Step:  AIC=-1779.9
## log10_Permeability ~ depth + caliper + ind.deep + gamma + phi.N + 
##     R.deep + R.med + SP + density.corr + density + phi.core + 
##     Facies
## 
##                Df Sum of Sq     RSS     AIC
## - density.corr  1    0.1931  89.174 -1780.1
## <none>                       88.981 -1779.9
## - ind.deep      1    0.2179  89.199 -1779.9
## - R.deep        1    0.2447  89.226 -1779.7
## - caliper       1    0.2921  89.273 -1779.2
## - R.med         1    0.3397  89.321 -1778.8
## - SP            1    0.4101  89.391 -1778.1
## - depth         1    0.4622  89.444 -1777.7
## - phi.N         1    2.2035  91.185 -1761.9
## - density       1    3.0113  91.993 -1754.6
## - gamma         1    3.5761  92.557 -1749.6
## - Facies        7    9.1242  98.106 -1714.0
## - phi.core      1   27.4190 116.400 -1561.9
## 
## Step:  AIC=-1780.12
## log10_Permeability ~ depth + caliper + ind.deep + gamma + phi.N + 
##     R.deep + R.med + SP + density + phi.core + Facies
## 
##            Df Sum of Sq     RSS     AIC
## - ind.deep  1    0.2180  89.392 -1780.1
## <none>                   89.174 -1780.1
## - R.deep    1    0.2526  89.427 -1779.8
## - caliper   1    0.2676  89.442 -1779.7
## - R.med     1    0.3598  89.534 -1778.8
## - SP        1    0.3832  89.558 -1778.6
## - depth     1    0.5404  89.715 -1777.2
## - phi.N     1    2.0726  91.247 -1763.3
## - gamma     1    3.4838  92.658 -1750.7
## - density   1    3.6220  92.796 -1749.5
## - Facies    7    9.3567  98.531 -1712.4
## - phi.core  1   27.2273 116.402 -1563.9
## 
## Step:  AIC=-1780.12
## log10_Permeability ~ depth + caliper + gamma + phi.N + R.deep + 
##     R.med + SP + density + phi.core + Facies
## 
##            Df Sum of Sq     RSS     AIC
## <none>                   89.392 -1780.1
## - R.deep    1    0.2869  89.679 -1779.5
## - depth     1    0.3332  89.726 -1779.1
## - SP        1    0.4296  89.822 -1778.2
## - R.med     1    0.5085  89.901 -1777.5
## - caliper   1    0.5746  89.967 -1776.9
## - phi.N     1    2.3337  91.726 -1761.0
## - gamma     1    3.8214  93.214 -1747.8
## - density   1    3.8626  93.255 -1747.5
## - Facies    7    9.2100  98.602 -1713.8
## - phi.core  1   27.0935 116.486 -1565.3
summary(Stepwise_Model_3)
## 
## Call:
## lm(formula = log10_Permeability ~ depth + caliper + gamma + phi.N + 
##     R.deep + R.med + SP + density + phi.core + Facies, data = data)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.58182 -0.12001  0.03437  0.15230  0.70317 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -1.2671250  3.9316796  -0.322  0.74732    
## depth        0.0006562  0.0003796   1.729  0.08420 .  
## caliper     -0.5608681  0.2470292  -2.270  0.02344 *  
## gamma       -0.0091497  0.0015626  -5.855 6.94e-09 ***
## phi.N       -1.7463527  0.3816550  -4.576 5.50e-06 ***
## R.deep      -0.0026554  0.0016551  -1.604  0.10903    
## R.med        0.0049837  0.0023334   2.136  0.03300 *  
## SP          -0.0016140  0.0008221  -1.963  0.04996 *  
## density      1.7602255  0.2990153   5.887 5.79e-09 ***
## phi.core     0.0927539  0.0059493  15.591  < 2e-16 ***
## FaciesF10    0.0896953  0.0945929   0.948  0.34330    
## FaciesF2     0.0152576  0.1523676   0.100  0.92026    
## FaciesF3    -0.0292379  0.0869197  -0.336  0.73667    
## FaciesF5     0.1022238  0.0879087   1.163  0.24524    
## FaciesF7     0.2794793  0.1462763   1.911  0.05641 .  
## FaciesF8    -0.0932936  0.0927473  -1.006  0.31477    
## FaciesF9    -0.3877078  0.1030388  -3.763  0.00018 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.3339 on 802 degrees of freedom
## Multiple R-squared:  0.6787, Adjusted R-squared:  0.6722 
## F-statistic: 105.9 on 16 and 802 DF,  p-value: < 2.2e-16

 plot the predicted vs measured permeability with respect to depth.

Predicted_log10_permeability_6 <-predict(Stepwise_Model_3,data=data)
Predicted_permeability_6<-10^Predicted_log10_permeability_6

ggplot(data) +
  geom_line(aes(x = depth, y = k.core, color = "Measured permeability")) +
  geom_line(aes(x = depth, y = Predicted_permeability_6, color = "Predicted permeability")) +
  labs(title = "Predicted vs Measured Permeability with Respect to Depth",
       x = "Depth",
       y = "Permeability",
       color = "Legend") + 
  scale_color_manual(values = c("Measured permeability" = "red", 
                                 "Predicted permeability" = "black")) +
  theme_minimal()

STEP7 Random Sub-sampling Cross-Validation applied on MLR of Log10(Permeability) given all well logs with facies (25% testing ,75%training)

library(caTools)
## Warning: package 'caTools' was built under R version 4.4.2
split=sample.split(data$log10_Permeability,SplitRatio = 0.75)
training_set=subset(data,split==TRUE)
testing_set=subset(data,split==FALSE)
Predicted_Permeabiity_Model_4<- lm(log10_Permeability~.-k.core,data=training_set)
summary(Predicted_Permeabiity_Model_4)
## 
## Call:
## lm(formula = log10_Permeability ~ . - k.core, data = training_set)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.5154 -0.1195  0.0292  0.1518  0.7608 
## 
## Coefficients: (1 not defined because of singularities)
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    -2.9065616  5.4699319  -0.531 0.595361    
## depth           0.0009668  0.0005554   1.741 0.082224 .  
## caliper        -0.6044095  0.3194313  -1.892 0.058958 .  
## ind.deep       -0.0008218  0.0007469  -1.100 0.271639    
## ind.med         0.0008176  0.0008216   0.995 0.320080    
## gamma          -0.0072653  0.0018912  -3.842 0.000135 ***
## phi.N          -2.3877378  0.4624549  -5.163 3.32e-07 ***
## R.deep         -0.0031717  0.0019139  -1.657 0.098003 .  
## R.med           0.0055398  0.0027914   1.985 0.047649 *  
## SP             -0.0016646  0.0009685  -1.719 0.086166 .  
## density.corr    1.2934539  1.4497298   0.892 0.372645    
## density         1.8231899  0.3555251   5.128 3.97e-07 ***
## phi.core        0.0970489  0.0072225  13.437  < 2e-16 ***
## FaciesF10       0.0946423  0.1085494   0.872 0.383625    
## FaciesF2        0.0582111  0.1639801   0.355 0.722724    
## FaciesF3       -0.0442158  0.1028563  -0.430 0.667439    
## FaciesF5        0.0979950  0.1073532   0.913 0.361704    
## FaciesF7        0.3283296  0.1751900   1.874 0.061402 .  
## FaciesF8       -0.0661655  0.1234537  -0.536 0.592191    
## FaciesF9       -0.3943510  0.1350931  -2.919 0.003643 ** 
## Phi.core.frac.         NA         NA      NA       NA    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.3345 on 594 degrees of freedom
## Multiple R-squared:  0.6779, Adjusted R-squared:  0.6676 
## F-statistic:  65.8 on 19 and 594 DF,  p-value: < 2.2e-16

plot the predicted (for testing data) vs measured permeability with respect to depth.

Predicted_log10_permeability_7<-predict(Predicted_Permeabiity_Model_4,newdata=testing_set)
Predicted_permeability_7<-10^Predicted_log10_permeability_7

ggplot(testing_set) +
  geom_line(aes(x = depth, y = k.core, color = "Measured permeability")) +
  geom_line(aes(x = depth, y = Predicted_permeability_7, color = "Predicted permeability")) +
  labs(title = "Predicted vs Measured Permeability with Respect to Depth",
       x = "Depth",
       y = "Permeability",
       color = "Legend") + 
  scale_color_manual(values = c("Measured permeability" = "red", 
                                 "Predicted permeability" = "black")) +
  theme_minimal()

STEP8 Applying step wise elimination to this model.

Stepwise_Model_4<-step(Predicted_Permeabiity_Model_4, direction = "backward")
## Start:  AIC=-1325.23
## log10_Permeability ~ (depth + caliper + ind.deep + ind.med + 
##     gamma + phi.N + R.deep + R.med + SP + density.corr + density + 
##     phi.core + k.core + Facies + Phi.core.frac.) - k.core
## 
## 
## Step:  AIC=-1325.23
## log10_Permeability ~ depth + caliper + ind.deep + ind.med + gamma + 
##     phi.N + R.deep + R.med + SP + density.corr + density + phi.core + 
##     Facies
## 
##                Df Sum of Sq    RSS     AIC
## - density.corr  1    0.0891 66.542 -1326.4
## - ind.med       1    0.1108 66.564 -1326.2
## - ind.deep      1    0.1354 66.588 -1326.0
## <none>                      66.453 -1325.2
## - R.deep        1    0.3072 66.760 -1324.4
## - SP            1    0.3305 66.784 -1324.2
## - depth         1    0.3390 66.792 -1324.1
## - caliper       1    0.4005 66.854 -1323.5
## - R.med         1    0.4406 66.894 -1323.2
## - gamma         1    1.6510 68.104 -1312.2
## - density       1    2.9421 69.395 -1300.6
## - phi.N         1    2.9824 69.435 -1300.3
## - Facies        7    6.0843 72.537 -1285.4
## - phi.core      1   20.1991 86.652 -1164.3
## 
## Step:  AIC=-1326.41
## log10_Permeability ~ depth + caliper + ind.deep + ind.med + gamma + 
##     phi.N + R.deep + R.med + SP + density + phi.core + Facies
## 
##            Df Sum of Sq    RSS     AIC
## - ind.med   1    0.1411 66.683 -1327.1
## - ind.deep  1    0.1663 66.708 -1326.9
## <none>                  66.542 -1326.4
## - R.deep    1    0.3190 66.861 -1325.5
## - SP        1    0.3361 66.878 -1325.3
## - depth     1    0.3527 66.895 -1325.2
## - caliper   1    0.3903 66.932 -1324.8
## - R.med     1    0.4668 67.009 -1324.1
## - gamma     1    1.6145 68.157 -1313.7
## - phi.N     1    2.8977 69.440 -1302.2
## - density   1    3.4051 69.947 -1297.8
## - Facies    7    6.1746 72.717 -1285.9
## - phi.core  1   20.1157 86.658 -1166.2
## 
## Step:  AIC=-1327.11
## log10_Permeability ~ depth + caliper + ind.deep + gamma + phi.N + 
##     R.deep + R.med + SP + density + phi.core + Facies
## 
##            Df Sum of Sq    RSS     AIC
## - ind.deep  1    0.0464 66.730 -1328.7
## <none>                  66.683 -1327.1
## - SP        1    0.2892 66.972 -1326.5
## - R.deep    1    0.2927 66.976 -1326.4
## - caliper   1    0.3653 67.049 -1325.8
## - R.med     1    0.4258 67.109 -1325.2
## - depth     1    0.5863 67.270 -1323.7
## - gamma     1    1.5402 68.223 -1315.1
## - phi.N     1    2.7904 69.474 -1303.9
## - density   1    3.4710 70.154 -1298.0
## - Facies    7    8.1384 74.822 -1270.4
## - phi.core  1   19.9746 86.658 -1168.2
## 
## Step:  AIC=-1328.68
## log10_Permeability ~ depth + caliper + gamma + phi.N + R.deep + 
##     R.med + SP + density + phi.core + Facies
## 
##            Df Sum of Sq    RSS     AIC
## <none>                  66.730 -1328.7
## - SP        1    0.3083 67.038 -1327.8
## - R.deep    1    0.3139 67.043 -1327.8
## - R.med     1    0.5136 67.243 -1326.0
## - caliper   1    0.5613 67.291 -1325.5
## - depth     1    0.5815 67.311 -1325.3
## - gamma     1    1.6326 68.362 -1315.8
## - phi.N     1    2.9812 69.711 -1303.8
## - density   1    3.5955 70.325 -1298.5
## - Facies    7    8.1051 74.835 -1272.3
## - phi.core  1   20.2554 86.985 -1167.9
summary(Stepwise_Model_4)
## 
## Call:
## lm(formula = log10_Permeability ~ depth + caliper + gamma + phi.N + 
##     R.deep + R.med + SP + density + phi.core + Facies, data = training_set)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.52378 -0.12404  0.03159  0.15494  0.73156 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -3.0093229  4.6464859  -0.648 0.517457    
## depth        0.0010243  0.0004491   2.281 0.022911 *  
## caliper     -0.6566757  0.2930304  -2.241 0.025394 *  
## gamma       -0.0071273  0.0018649  -3.822 0.000146 ***
## phi.N       -2.3203712  0.4492941  -5.164 3.29e-07 ***
## R.deep      -0.0031862  0.0019015  -1.676 0.094325 .  
## R.med        0.0058036  0.0027073   2.144 0.032463 *  
## SP          -0.0015910  0.0009579  -1.661 0.097264 .  
## density      1.9410260  0.3422359   5.672 2.21e-08 ***
## phi.core     0.0950265  0.0070591  13.462  < 2e-16 ***
## FaciesF10    0.1003899  0.1080278   0.929 0.353111    
## FaciesF2     0.0767705  0.1621035   0.474 0.635966    
## FaciesF3    -0.0530396  0.1006243  -0.527 0.598316    
## FaciesF5     0.0816077  0.1035061   0.788 0.430756    
## FaciesF7     0.3009104  0.1664226   1.808 0.071092 .  
## FaciesF8    -0.0846616  0.1094404  -0.774 0.439482    
## FaciesF9    -0.4434317  0.1209532  -3.666 0.000268 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.3343 on 597 degrees of freedom
## Multiple R-squared:  0.6766, Adjusted R-squared:  0.6679 
## F-statistic: 78.05 on 16 and 597 DF,  p-value: < 2.2e-16

plot the predicted (for testing data) vs measured permeability with respect to depth.

Predicted_log10_permeability_8 <-predict(Stepwise_Model_4,newdata=testing_set)
Predicted_permeability_8<-10^Predicted_log10_permeability_8

ggplot(testing_set) +
  geom_line(aes(x = depth, y = k.core, color = "Measured permeability")) +
  geom_line(aes(x = depth, y = Predicted_permeability_8, color = "Predicted permeability")) +
  labs(title = "Predicted vs Measured Permeability with Respect to Depth",
       x = "Depth",
       y = "Permeability",
       color = "Legend") + 
  scale_color_manual(values = c("Measured permeability" = "red", 
                                 "Predicted permeability" = "black")) +
  theme_minimal()