Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

Statistics in Geology

Homework 5

National Central University


Graduate Institute of Applied Geology
ID number: 111624603
Student: Truong Huu Duc (鍾胡德)
Date: 2023/10/31
1. Question
In the given GRAHAM data, please use the trend surface to explain and draw the first
order, second order, third order, fourth order, and fifth order to figure out the contour lines.
2. Purpose
On the field trip, we could collect various depth data and sometimes environment data.
From that, we try to determine the topography of this area or the distribution of pollutant
concentration we can use the trend surface to figure out coefficients and the contour map.
3. Method
This assignment used surface trends by first to fifth-order
- First order
d i=m1 +m2 x i +m3 y i
- Second order
2 2
d i=m1 +m2 x +m3 y +m4 xi + m5 x i y i +m6 y i
- Third order
2 2 3 2 2 3
d i=m1 +m2 x +m3 y +m4 xi + m5 x i y i +m6 y i + m7 x i + m8 x i y i +m9 x i y i +m10 y i
- Fourth order
2 2 3 2 2 3 4 3 2 2
d i=m1 +m2 x +m3 y +m4 xi + m5 x i y i +m6 y i + m7 x i + m8 x i y i +m9 x i y i +m10 y i +m11 x i +m12 x i y i+ m13 xi y i
- Fifth order
2 2 3 2 2 3
d i=m1 +m2 x +m3 y +m4 xi + m5 x i y i +m6 y i + m7 x i + m8 x i y i +m9 x i y i +m10 y i
4 3 2 2 3 4 5 4 3 2 2 3 4 5
+m11 x i +m12 x i y i+ m13 xi y i +m14 x i y i + m15 y i +m16 x i +m17 x i y i +m18 x i y i + m19 x i y i +m20 x i y i +m21 y i
And use Maxtrix equation for linear regression to solve
Cubic equation

m1 +m2 x 1 +m3 y i ¿ d 1 1 + x1 + y 1 c1 d1
2
m1 +m2 x 2 + m3 y i ¿ d 2 1 + x2 + x 2 c2 d2
=> x =
⋮ ⋮ ⋮ ⋮ ⋮ ⋮ ⋮ ⋮ ⋮
m1 1 +m2 x n m3 y i ¿ dn 1 + xn + x
2
n
cn dn

AX = B
4. Result

Table 1. Table of Coefficience in surface trends from First to Fifth order

First order Second order Third order Fourth order Fifth order
m1 -1328.974 -1355.525 -1382.331 -1377.742 -1396.570
m2 -1.458 0.981 19.447 20.825 46.396
m3 16.612 44.927 59.487 22.071 17.077
m4 NA -0.910 -5.409 -5.879 -12.355
m5 NA 2.384 -0.637 -10.652 -33.334
m6 NA -6.636 -8.729 34.257 58.002
m7 NA NA 0.348 0.678 1.126
m8 NA NA -0.305 -1.817 1.736
m9 NA NA 1.046 8.685 15.072
m10 NA NA -0.234 -15.683 -26.850
m11 NA NA NA -0.025 0.003
m12 NA NA NA -0.001 -0.215
m13 NA NA NA 0.313 -0.753
m14 NA NA NA -1.176 -0.981
m15 NA NA NA 1.646 3.244
m16 NA NA NA NA -0.003
m17 NA NA NA NA 0.026
m18 NA NA NA NA -0.064
m19 NA NA NA NA 0.219
m20 NA NA NA NA -0.188
m21 NA NA NA NA -0.048
5. Response
6. Source code by R
library(tidyverse)
pacman::p_load(akima,metR,viridis)
df <- read_table2("C:/Users/geohydraulic/Downloads/GRAHAM.TXT", col_names =
TRUE)
names(df)
df <- df %>%
mutate_all(as.numeric)
xi <- df$X
yi <- df$Y
di <- df$Depth
plot(xi,yi, col = "blue")
one <- rep(1, length(xi))
# Create matrices for xi, yi, and di
X <- cbind(one, xi, yi)
coef_1 <- solve(t(X) %*% X) %*% t(X) %*% di
a <- cat(coef_1)

### second order


X2 <- cbind(one, xi, yi, xi^2,xi*yi,yi^2)
coef_2 <- solve(t(X2) %*% X2) %*% t(X2) %*% di

b <- cat(coef_2)
### third order
X3 <- cbind(one, xi, yi, xi^2,xi*yi,yi^2, xi^3, xi^2*yi, xi*yi^2, yi^3)
coef_3 <- solve(t(X3) %*% X3) %*% t(X3) %*% di
c <- cat(coef_3)

### 4th order


X4 <- cbind(one, xi, yi, xi^2,xi*yi,yi^2, xi^3, xi^2*yi, xi*yi^2, yi^3, xi^4, xi^3*yi,
xi^2*yi^2, xi*yi^3, yi^4)
coef_4<- solve(t(X4) %*% X4) %*% t(X4) %*% di
d <- cat(coef_3)

### 5th order


X5 <- cbind(one, xi, yi, xi^2,xi*yi,yi^2, xi^3, xi^2*yi, xi*yi^2, yi^3, xi^4, xi^3*yi,
xi^2*yi^2, xi*yi^3, yi^4,
xi^5, xi^4*yi,xi^3*yi^2, xi^2*yi^3, xi*yi^4, yi^5)
coef_5 <- solve(t(X5) %*% X5) %*% t(X5) %*% di
max_length <- max(length(coef_1), length(coef_2), length(coef_3), length(coef_4),
length(coef_5))

data <- data.frame(


coef_1 = c(coef_1, rep(NA, max_length - length(coef_1))),
coef_2 = c(coef_2, rep(NA, max_length - length(coef_2))),
coef_3 = c(coef_3, rep(NA, max_length - length(coef_3))),
coef_4 = c(coef_4, rep(NA, max_length - length(coef_4))),
coef_5 = c(coef_5, rep(NA, max_length - length(coef_5)))
)
write.csv(data,"SIG_HW5.csv" )

# first to fifth order


d1 <- X %*% coef_1
d2 <- X2 %*% coef_2
d3 <- X3 %*% coef_3
d4 <- X4 %*% coef_4
d5 <- X5 %*% coef_5

df_new <- data.frame(xi,yi,d1,d2,d3,d4,d5)


write.csv(df_new, "New_depth.csv")

You might also like