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.6)
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.4268 -0.1243  0.0226  0.1428  0.7474 
## 
## Coefficients: (1 not defined because of singularities)
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    -0.7220216  6.3265817  -0.114   0.9092    
## depth           0.0006509  0.0006305   1.032   0.3024    
## caliper        -0.6212611  0.3721654  -1.669   0.0957 .  
## ind.deep       -0.0015868  0.0008894  -1.784   0.0750 .  
## ind.med         0.0015128  0.0009675   1.564   0.1186    
## gamma          -0.0086712  0.0021452  -4.042 6.19e-05 ***
## phi.N          -2.3867476  0.5421777  -4.402 1.33e-05 ***
## R.deep         -0.0028651  0.0021637  -1.324   0.1861    
## R.med           0.0049987  0.0031581   1.583   0.1141    
## SP             -0.0016905  0.0011097  -1.523   0.1283    
## density.corr    3.3938014  1.6691025   2.033   0.0426 *  
## density         1.7529524  0.4358405   4.022 6.72e-05 ***
## phi.core        0.0985553  0.0082320  11.972  < 2e-16 ***
## FaciesF10       0.0219727  0.1340378   0.164   0.8699    
## FaciesF2       -0.0686734  0.1936346  -0.355   0.7230    
## FaciesF3        0.0621385  0.1258343   0.494   0.6217    
## FaciesF5        0.1509199  0.1264118   1.194   0.2331    
## FaciesF7        0.3274238  0.1940484   1.687   0.0922 .  
## FaciesF8       -0.0375228  0.1415730  -0.265   0.7911    
## FaciesF9       -0.2728808  0.1529921  -1.784   0.0751 .  
## Phi.core.frac.         NA         NA      NA       NA    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.3451 on 471 degrees of freedom
## Multiple R-squared:  0.6987, Adjusted R-squared:  0.6865 
## F-statistic: 57.47 on 19 and 471 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=-1025.32
## 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=-1025.32
## 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
## - depth         1    0.1269 56.205 -1026.21
## - R.deep        1    0.2088 56.287 -1025.50
## <none>                      56.078 -1025.32
## - SP            1    0.2763 56.355 -1024.91
## - ind.med       1    0.2911 56.370 -1024.78
## - R.med         1    0.2983 56.377 -1024.71
## - caliper       1    0.3318 56.410 -1024.42
## - ind.deep      1    0.3790 56.457 -1024.01
## - density.corr  1    0.4922 56.571 -1023.03
## - density       1    1.9260 58.004 -1010.74
## - gamma         1    1.9453 58.024 -1010.58
## - phi.N         1    2.3073 58.386 -1007.52
## - Facies        7    4.0184 60.097 -1005.34
## - phi.core      1   17.0659 73.144  -896.87
## 
## Step:  AIC=-1026.21
## log10_Permeability ~ 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
## - R.deep        1    0.1737 56.379 -1026.69
## <none>                      56.205 -1026.21
## - R.med         1    0.2384 56.444 -1026.13
## - SP            1    0.3053 56.511 -1025.55
## - ind.med       1    0.4550 56.660 -1024.25
## - density.corr  1    0.4759 56.681 -1024.07
## - ind.deep      1    0.4928 56.698 -1023.92
## - caliper       1    1.3897 57.595 -1016.22
## - phi.N         1    2.1897 58.395 -1009.44
## - density       1    2.2370 58.442 -1009.05
## - Facies        7    4.4059 60.611 -1003.15
## - gamma         1    3.0970 59.302 -1001.87
## - phi.core      1   17.0041 73.209  -898.43
## 
## Step:  AIC=-1026.69
## log10_Permeability ~ caliper + ind.deep + ind.med + gamma + phi.N + 
##     R.med + SP + density.corr + density + phi.core + Facies
## 
##                Df Sum of Sq    RSS      AIC
## - R.med         1    0.0801 56.459 -1028.00
## <none>                      56.379 -1026.69
## - SP            1    0.2317 56.611 -1026.68
## - ind.med       1    0.3987 56.778 -1025.23
## - ind.deep      1    0.4488 56.828 -1024.80
## - density.corr  1    0.5077 56.887 -1024.29
## - caliper       1    1.3001 57.679 -1017.50
## - density       1    2.1054 58.484 -1010.69
## - phi.N         1    2.2391 58.618 -1009.57
## - gamma         1    2.9553 59.334 -1003.61
## - Facies        7    4.4931 60.872 -1003.05
## - phi.core      1   17.3450 73.724  -896.99
## 
## Step:  AIC=-1028
## log10_Permeability ~ caliper + ind.deep + ind.med + gamma + phi.N + 
##     SP + density.corr + density + phi.core + Facies
## 
##                Df Sum of Sq    RSS      AIC
## <none>                      56.459 -1028.00
## - SP            1    0.2594 56.718 -1027.75
## - ind.med       1    0.3539 56.813 -1026.93
## - ind.deep      1    0.4276 56.887 -1026.29
## - density.corr  1    0.5528 57.012 -1025.21
## - caliper       1    1.4799 57.939 -1017.29
## - density       1    2.0892 58.548 -1012.16
## - phi.N         1    2.1596 58.619 -1011.57
## - Facies        7    4.7336 61.193 -1002.47
## - gamma         1    3.4240 59.883 -1001.09
## - phi.core      1   17.4940 73.953  -897.47
summary(Stepwise_Model_4)
## 
## Call:
## lm(formula = log10_Permeability ~ caliper + ind.deep + ind.med + 
##     gamma + phi.N + SP + density.corr + density + phi.core + 
##     Facies, data = training_set)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.4427 -0.1265  0.0243  0.1526  0.7572 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   5.4816343  2.5473943   2.152 0.031913 *  
## caliper      -0.9006070  0.2555042  -3.525 0.000465 ***
## ind.deep     -0.0016421  0.0008667  -1.895 0.058739 .  
## ind.med       0.0015646  0.0009077   1.724 0.085417 .  
## gamma        -0.0097741  0.0018230  -5.362 1.29e-07 ***
## phi.N        -2.2387574  0.5257756  -4.258 2.49e-05 ***
## SP           -0.0015966  0.0010819  -1.476 0.140700    
## density.corr  3.5725195  1.6583398   2.154 0.031722 *  
## density       1.7664790  0.4217898   4.188 3.36e-05 ***
## phi.core      0.0993825  0.0082006  12.119  < 2e-16 ***
## FaciesF10     0.0406710  0.1330937   0.306 0.760057    
## FaciesF2     -0.0838636  0.1919790  -0.437 0.662428    
## FaciesF3      0.0722151  0.1244222   0.580 0.561918    
## FaciesF5      0.2177716  0.1192170   1.827 0.068376 .  
## FaciesF7      0.3306109  0.1881616   1.757 0.079553 .  
## FaciesF8      0.0226346  0.1288861   0.176 0.860670    
## FaciesF9     -0.1809633  0.1288221  -1.405 0.160749    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.3451 on 474 degrees of freedom
## Multiple R-squared:  0.6966, Adjusted R-squared:  0.6864 
## F-statistic: 68.02 on 16 and 474 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()