ANN10
correlationz
at selected Ppr
and Tpr
# get a z value using DPR correlation
library(zFactor)
# library(rJava)
z.Ann10(pres.pr = 1.5, temp.pr = 2.0)
# HY = 0.9580002
[1] 0.9572277
From the Standing-Katz chart we obtain a digitized point at the same Ppr
and Tpr
:
# get a z value from the SK chart at the same Ppr and Tpr
library(zFactor)
tpr_vec <- c(2.0)
getStandingKatzMatrix(tpr_vector = tpr_vec,
pprRange = "lp")[1, "1.5"]
1.5
0.956
It looks pretty good.
z
at selected Ppr
and Tpr
library(zFactor)
z.Ann10(pres.pr = 1.5, temp.pr = 1.1)
[1] 0.4309125
From the Standing-Katz
chart we obtain a digitized point:
library(zFactor)
tpr_vec <- c(1.1)
getStandingKatzMatrix(tpr_vector = tpr_vec,
pprRange = "lp")[1, "1.5"]
1.5
0.426
At lower
Tpr
there is some error. We see a difference between the values of z from the ANN10 calculation and the value read from the Standing-Katz chart.
z
for several Ppr
and Tpr
# test HY with 1st-derivative using the values from paper
ppr <- c(0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5)
tpr <- c(1.3, 1.5, 1.7, 2)
dpr <- z.Ann10(ppr, tpr)
print(dpr)
# From Hall-Yarborough
# 0.5 1.5 2.5 3.5 4.5 5.5 6.5
# 1.3 0.9176300 0.7534433 0.6399020 0.6323003 0.6881127 0.7651710 0.8493794
# 1.5 0.9496855 0.8581232 0.7924067 0.7687902 0.7868071 0.8316848 0.8906351
# 1.7 0.9682547 0.9134862 0.8756412 0.8605668 0.8694525 0.8978885 0.9396353
# 2 0.9838234 0.9580002 0.9426939 0.9396286 0.9490995 0.9697839 0.9994317
# From Dranchuk-AbouKassem
# 0.5 1.5 2.5 3.5 4.5 5.5 6.5
# 1.3 0.9203019 0.7543694 0.6377871 0.6339357 0.6898314 0.7663247 0.8499523
# 1.5 0.9509373 0.8593144 0.7929993 0.7710525 0.7896224 0.8331893 0.8904317
# 1.7 0.9681353 0.9128087 0.8753784 0.8619509 0.8721085 0.9003962 0.9409634
# 2 0.9824731 0.9551087 0.9400752 0.9385273 0.9497137 0.9715388 1.0015560
0.5 1.5 2.5 3.5 4.5 5.5 6.5
1.3 0.9196115 0.7567070 0.6394479 0.6341957 0.6857549 0.7611212 0.8471371
1.5 0.9508509 0.8607096 0.7940885 0.7685691 0.7867923 0.8323518 0.8918874
1.7 0.9682749 0.9146453 0.8767457 0.8581919 0.8672123 0.8978116 0.9413442
2 0.9839990 0.9572277 0.9414698 0.9352303 0.9453140 0.9693022 1.0014522
With the same ppr
and tpr
vectors, we do the same for the Standing-Katz chart:
library(zFactor)
sk <- getStandingKatzMatrix(ppr_vector = ppr, tpr_vector = tpr)
print(sk)
0.5 1.5 2.5 3.5 4.5 5.5 6.5
1.30 0.916 0.756 0.638 0.633 0.684 0.759 0.844
1.50 0.948 0.859 0.794 0.770 0.790 0.836 0.892
1.70 0.968 0.914 0.876 0.857 0.864 0.897 0.942
2.00 0.982 0.956 0.941 0.937 0.945 0.969 1.003
Subtract the two matrices and find the difference:
err <- round((sk - dpr) / sk * 100, 2)
err
# DAK
# 0.5 1.5 2.5 3.5 4.5 5.5 6.5
# 1.30 -0.47 0.22 0.03 -0.15 -0.85 -0.97 -0.71
# 1.50 -0.31 -0.04 0.13 -0.14 0.05 0.34 0.18
# 1.70 -0.01 0.13 0.07 -0.58 -0.94 -0.38 0.11
# 2.00 -0.05 0.09 0.10 -0.16 -0.50 -0.26 0.14
0.5 1.5 2.5 3.5 4.5 5.5 6.5
1.30 -0.39 -0.09 -0.23 -0.19 -0.26 -0.28 -0.37
1.50 -0.30 -0.20 -0.01 0.19 0.41 0.44 0.01
1.70 -0.03 -0.07 -0.09 -0.14 -0.37 -0.09 0.07
2.00 -0.20 -0.13 -0.05 0.19 -0.03 -0.03 0.15
Ppr
and by PPr
print(colSums(err))
0.5 1.5 2.5 3.5 4.5 5.5 6.5
-0.92 -0.49 -0.38 0.05 -0.25 0.04 -0.14
print(rowSums(err))
1.30 1.50 1.70 2.00
-1.81 0.54 -0.72 -0.10
Tpr
library(zFactor)
tpr2 <- c(1.05, 1.1)
ppr2 <- c(0.5, 1.5, 2.5, 3.5, 4.5, 5.5)
sk2 <- getStandingKatzMatrix(ppr_vector = ppr2, tpr_vector = tpr2, pprRange = "lp")
sk2
0.5 1.5 2.5 3.5 4.5 5.5
1.05 0.829 0.253 0.343 0.471 0.598 0.727
1.10 0.854 0.426 0.393 0.500 0.615 0.729
We do the same with the DPR correlation:
# calculate z values at lower values of Tpr
library(zFactor)
dpr2 <- z.Ann10(ppr2, tpr2)
print(dpr2)
0.5 1.5 2.5 3.5 4.5 5.5
1.05 0.8324799 0.2526076 0.3420322 0.4693520 0.5991874 0.7254470
1.1 0.8547310 0.4309125 0.3930420 0.4983162 0.6136523 0.7278621
Subtract the matrices and calculate the error in percentage:
err2 <- round((sk2 - dpr2) / sk2 * 100, 2)
err2
# DAK
# 0.5 1.5 2.5 3.5 4.5 5.5
# 1.05 -0.13 -12.15 -12.78 -7.49 -4.34 -1.68
# 1.10 -0.36 -4.79 -4.97 -3.56 -2.14 -1.21
0.5 1.5 2.5 3.5 4.5 5.5
1.05 -0.42 0.16 0.28 0.35 -0.20 0.21
1.10 -0.09 -1.15 -0.01 0.34 0.22 0.16
Transposing the matrix with Tpr
as columns and Ppr
as rows:
t_err2 <- t(err2)
t_err2
1.05 1.10
0.5 -0.42 -0.09
1.5 0.16 -1.15
2.5 0.28 -0.01
3.5 0.35 0.34
4.5 -0.20 0.22
5.5 0.21 0.16
A statistical summary by Tpr
curve:
sum_t_err2 <- summary(t_err2)
sum_t_err2
1.05 1.10
Min. :-0.42000 Min. :-1.15000
1st Qu.:-0.11000 1st Qu.:-0.07000
Median : 0.18500 Median : 0.07500
Mean : 0.06333 Mean :-0.08833
3rd Qu.: 0.26250 3rd Qu.: 0.20500
Max. : 0.35000 Max. : 0.34000
# We can see that the errors in `z` with `ANN10` are less than `HY` with a `r sum_t_err2[1,1]`% and `r sum_t_err2[6,1]`% for `Tpr = 1.05`, and a `r sum_t_err2[1,2]`% and `r sum_t_err2[6,2]`% for `Tpr = 1.10`.
SK
chart vs ANN10
model.library(zFactor)
library(tibble)
tpr2 <- c(1.05, 1.1, 1.2, 1.3)
ppr2 <- c(0.5, 1.0, 1.5, 2, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5)
sk_dpr_2 <- createTidyFromMatrix(ppr2, tpr2, correlation = "N10")
as.tibble(sk_dpr_2)
# A tibble: 52 x 5
Tpr Ppr z.chart z.calc dif
<chr> <dbl> <dbl> <dbl> <dbl>
1 1.05 0.5 0.829 0.8324799 -0.0034799212
2 1.1 0.5 0.854 0.8547310 -0.0007310197
3 1.2 0.5 0.893 0.8953923 -0.0023923156
4 1.3 0.5 0.916 0.9196115 -0.0036115485
5 1.05 1.0 0.589 0.5896265 -0.0006265401
6 1.1 1.0 0.669 0.6708697 -0.0018696755
7 1.2 1.0 0.779 0.7807145 -0.0017144762
8 1.3 1.0 0.835 0.8363278 -0.0013277938
9 1.05 1.5 0.253 0.2526076 0.0003924371
10 1.1 1.5 0.426 0.4309125 -0.0049124610
# ... with 42 more rows
library(ggplot2)
p <- ggplot(sk_dpr_2, aes(x=Ppr, y=z.calc, group=Tpr, color=Tpr)) +
geom_line() +
geom_point() +
geom_errorbar(aes(ymin=z.calc-dif, ymax=z.calc+dif), width=.4,
position=position_dodge(0.05))
print(p)
Tpr
Extract only values at Tpr = 1.05
.
sk_dpr_3 <- sk_dpr_2[sk_dpr_2$Tpr==1.05,]
sk_dpr_3
Tpr Ppr z.chart z.calc dif
1 1.05 0.5 0.829 0.8324799 -0.0034799212
5 1.05 1.0 0.589 0.5896265 -0.0006265401
9 1.05 1.5 0.253 0.2526076 0.0003924371
13 1.05 2.0 0.280 0.2813986 -0.0013986023
17 1.05 2.5 0.343 0.3420322 0.0009678343
21 1.05 3.0 0.407 0.4046718 0.0023282390
25 1.05 3.5 0.471 0.4693520 0.0016480466
29 1.05 4.0 0.534 0.5347267 -0.0007266737
33 1.05 4.5 0.598 0.5991874 -0.0011874468
37 1.05 5.0 0.663 0.6627276 0.0002723595
41 1.05 5.5 0.727 0.7254470 0.0015529844
45 1.05 6.0 0.786 0.7868394 -0.0008393750
49 1.05 6.5 0.846 0.8464481 -0.0004481081
p <- ggplot(sk_dpr_3, aes(x=Ppr, y=z.calc, group=Tpr, color=Tpr)) +
geom_line() +
geom_point() +
geom_errorbar(aes(ymin=z.calc-dif, ymax=z.calc+dif), width=.4,
position=position_dodge(0.05))
print(p)
summary(sk_dpr_3)
# dif ANN10
# Min. :-0.048404
# 1st Qu.:-0.035300
# Median :-0.025978
# Mean :-0.023178
# 3rd Qu.:-0.009960
# Max. : 0.002325
Tpr Ppr z.chart z.calc
Length:13 Min. :0.5 Min. :0.2530 Min. :0.2526
Class :character 1st Qu.:2.0 1st Qu.:0.4070 1st Qu.:0.4047
Mode :character Median :3.5 Median :0.5890 Median :0.5896
Mean :3.5 Mean :0.5635 Mean :0.5637
3rd Qu.:5.0 3rd Qu.:0.7270 3rd Qu.:0.7254
Max. :6.5 Max. :0.8460 Max. :0.8464
dif
Min. :-0.0034799
1st Qu.:-0.0008394
Median :-0.0004481
Mean :-0.0001188
3rd Qu.: 0.0009678
Max. : 0.0023282
ANN10
correlation for all the Tpr
curveslibrary(ggplot2)
library(tibble)
# get all `lp` Tpr curves
tpr_all <- getCurvesDigitized(pprRange = "lp")
ppr <- c(0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5)
sk_corr_all <- createTidyFromMatrix(ppr, tpr_all, correlation = "N10")
as.tibble(sk_corr_all)
p <- ggplot(sk_corr_all, aes(x=Ppr, y=z.calc, group=Tpr, color=Tpr)) +
geom_line() +
geom_point() +
geom_errorbar(aes(ymin=z.calc-dif, ymax=z.calc+dif), width=.4,
position=position_dodge(0.05))
print(p)
# A tibble: 208 x 5
Tpr Ppr z.chart z.calc dif
<chr> <dbl> <dbl> <dbl> <dbl>
1 1.05 0.5 0.829 0.8324799 -0.0034799212
2 1.1 0.5 0.854 0.8547310 -0.0007310197
3 1.2 0.5 0.893 0.8953923 -0.0023923156
4 1.3 0.5 0.916 0.9196115 -0.0036115485
5 1.4 0.5 0.936 0.9367118 -0.0007118312
6 1.5 0.5 0.948 0.9508509 -0.0028509478
7 1.6 0.5 0.959 0.9607316 -0.0017315940
8 1.7 0.5 0.968 0.9682749 -0.0002748589
9 1.8 0.5 0.974 0.9758251 -0.0018251256
10 1.9 0.5 0.978 0.9814269 -0.0034269385
# ... with 198 more rows
# MSE: Mean Squared Error
# RMSE: Root Mean Sqyared Error
# RSS: residual sum of square
# ARE: Average Relative Error, %
# AARE: Average Absolute Relative Error, %
library(dplyr)
grouped <- group_by(sk_corr_all, Tpr, Ppr)
smry_tpr_ppr <- summarise(grouped,
#mean=mean(z.calc),
#sd=sd(z.calc),
RMSE= sqrt(mean((z.chart-z.calc)^2)),
MSE = sum((z.calc - z.chart)^2) / n(),
# rmse2 = sqrt(sum((z.chart-z.calc)^2)/n()),
RSS = sum((z.calc - z.chart)^2),
ARE = sum((z.calc - z.chart) / z.chart) * 100 / n(),
AARE = sum( abs((z.calc - z.chart) / z.chart)) * 100 / n()
)
ggplot(smry_tpr_ppr, aes(Ppr, Tpr)) +
geom_tile(data=smry_tpr_ppr, aes(fill=AARE), color="white") +
scale_fill_gradient2(low="blue", high="red", mid="yellow", na.value = "pink",
midpoint=12.5, limit=c(0, 25), name="AARE") +
theme(axis.text.x = element_text(angle=45, vjust=1, size=11, hjust=1))+
coord_equal()
DKP
vs SK
chart# get all `lp` Tpr curves
tpr <- getCurvesDigitized(pprRange = "lp")
ppr <- c(0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5)
# calculate HY for the given Tpr
all_dak <- z.Ann10(pres.pr = ppr, temp.pr = tpr)
cat("Calculated from the correlation \n")
print(all_dak)
cat("\nStanding-Katz chart\n")
all_sk <- getStandingKatzMatrix(ppr_vector = ppr, tpr_vector = tpr)
all_sk
# find the error
cat("\n Errors in percentage \n")
all_err <- round((all_sk - all_dak) / all_sk * 100, 2) # in percentage
all_err
cat("\n Errors in Ppr\n")
summary(all_err)
# for the transposed matrix
cat("\n Errors for the transposed matrix: Tpr \n")
summary(t(all_err))
Calculated from the correlation
0.5 1.5 2.5 3.5 4.5 5.5 6.5
1.05 0.8324799 0.2526076 0.3420322 0.4693520 0.5991874 0.7254470 0.8464481
1.1 0.8547310 0.4309125 0.3930420 0.4983162 0.6136523 0.7278621 0.8417240
1.2 0.8953923 0.6607512 0.5179963 0.5676801 0.6492856 0.7424365 0.8393892
1.3 0.9196115 0.7567070 0.6394479 0.6341957 0.6857549 0.7611212 0.8471371
1.4 0.9367118 0.8179531 0.7301083 0.7058966 0.7360320 0.7938440 0.8650626
1.5 0.9508509 0.8607096 0.7940885 0.7685691 0.7867923 0.8323518 0.8918874
1.6 0.9607316 0.8909372 0.8413772 0.8186001 0.8303206 0.8669610 0.9174184
1.7 0.9682749 0.9146453 0.8767457 0.8581919 0.8672123 0.8978116 0.9413442
1.8 0.9758251 0.9330673 0.9033038 0.8900081 0.8983954 0.9253309 0.9638663
1.9 0.9814269 0.9463194 0.9244863 0.9154178 0.9242331 0.9491918 0.9841183
2 0.9839990 0.9572277 0.9414698 0.9352303 0.9453140 0.9693022 1.0014522
2.2 0.9900357 0.9744007 0.9641093 0.9632802 0.9770073 1.0002489 1.0281919
2.4 0.9948006 0.9851441 0.9796739 0.9835802 0.9995876 1.0223775 1.0476552
2.6 0.9973689 0.9948164 0.9945873 1.0008562 1.0160982 1.0374500 1.0612594
2.8 1.0003231 1.0036769 1.0082887 1.0163706 1.0293895 1.0474565 1.0693476
3 1.0028553 1.0095269 1.0179196 1.0286167 1.0412701 1.0563968 1.0751669
Standing-Katz chart
0.5 1.5 2.5 3.5 4.5 5.5 6.5
1.05 0.829 0.253 0.343 0.471 0.598 0.727 0.846
1.10 0.854 0.426 0.393 0.500 0.615 0.729 0.841
1.20 0.893 0.657 0.519 0.565 0.650 0.741 0.841
1.30 0.916 0.756 0.638 0.633 0.684 0.759 0.844
1.40 0.936 0.816 0.727 0.705 0.734 0.792 0.865
1.50 0.948 0.859 0.794 0.770 0.790 0.836 0.892
1.60 0.959 0.888 0.839 0.816 0.829 0.868 0.918
1.70 0.968 0.914 0.876 0.857 0.864 0.897 0.942
1.80 0.974 0.933 0.905 0.891 0.901 0.929 0.967
1.90 0.978 0.945 0.924 0.916 0.924 0.949 0.985
2.00 0.982 0.956 0.941 0.937 0.945 0.969 1.003
2.20 0.989 0.973 0.963 0.963 0.976 1.000 1.029
2.40 0.993 0.984 0.980 0.983 0.999 1.023 1.049
2.60 0.997 0.994 0.994 1.000 1.016 1.038 1.062
2.80 0.999 1.002 1.008 1.016 1.030 1.049 1.069
3.00 1.002 1.009 1.018 1.029 1.041 1.056 1.075
Errors in percentage
0.5 1.5 2.5 3.5 4.5 5.5 6.5
1.05 -0.42 0.16 0.28 0.35 -0.20 0.21 -0.05
1.10 -0.09 -1.15 -0.01 0.34 0.22 0.16 -0.09
1.20 -0.27 -0.57 0.19 -0.47 0.11 -0.19 0.19
1.30 -0.39 -0.09 -0.23 -0.19 -0.26 -0.28 -0.37
1.40 -0.08 -0.24 -0.43 -0.13 -0.28 -0.23 -0.01
1.50 -0.30 -0.20 -0.01 0.19 0.41 0.44 0.01
1.60 -0.18 -0.33 -0.28 -0.32 -0.16 0.12 0.06
1.70 -0.03 -0.07 -0.09 -0.14 -0.37 -0.09 0.07
1.80 -0.19 -0.01 0.19 0.11 0.29 0.39 0.32
1.90 -0.35 -0.14 -0.05 0.06 -0.03 -0.02 0.09
2.00 -0.20 -0.13 -0.05 0.19 -0.03 -0.03 0.15
2.20 -0.10 -0.14 -0.12 -0.03 -0.10 -0.02 0.08
2.40 -0.18 -0.12 0.03 -0.06 -0.06 0.06 0.13
2.60 -0.04 -0.08 -0.06 -0.09 -0.01 0.05 0.07
2.80 -0.13 -0.17 -0.03 -0.04 0.06 0.15 -0.03
3.00 -0.09 -0.05 0.01 0.04 -0.03 -0.04 -0.02
Errors in Ppr
0.5 1.5 2.5 3.5
Min. :-0.4200 Min. :-1.1500 Min. :-0.43000 Min. :-0.47000
1st Qu.:-0.2775 1st Qu.:-0.2100 1st Qu.:-0.09750 1st Qu.:-0.13250
Median :-0.1800 Median :-0.1350 Median :-0.04000 Median :-0.03500
Mean :-0.1900 Mean :-0.2081 Mean :-0.04125 Mean :-0.01188
3rd Qu.:-0.0900 3rd Qu.:-0.0775 3rd Qu.: 0.01500 3rd Qu.: 0.13000
Max. :-0.0300 Max. : 0.1600 Max. : 0.28000 Max. : 0.35000
4.5 5.5 6.5
Min. :-0.3700 Min. :-0.2800 Min. :-0.3700
1st Qu.:-0.1700 1st Qu.:-0.0525 1st Qu.:-0.0225
Median :-0.0300 Median : 0.0150 Median : 0.0650
Mean :-0.0275 Mean : 0.0425 Mean : 0.0375
3rd Qu.: 0.0725 3rd Qu.: 0.1525 3rd Qu.: 0.1000
Max. : 0.4100 Max. : 0.4400 Max. : 0.3200
Errors for the transposed matrix: Tpr
1.05 1.10 1.20 1.30
Min. :-0.42000 Min. :-1.15000 Min. :-0.5700 Min. :-0.3900
1st Qu.:-0.12500 1st Qu.:-0.09000 1st Qu.:-0.3700 1st Qu.:-0.3250
Median : 0.16000 Median :-0.01000 Median :-0.1900 Median :-0.2600
Mean : 0.04714 Mean :-0.08857 Mean :-0.1443 Mean :-0.2586
3rd Qu.: 0.24500 3rd Qu.: 0.19000 3rd Qu.: 0.1500 3rd Qu.:-0.2100
Max. : 0.35000 Max. : 0.34000 Max. : 0.1900 Max. :-0.0900
1.40 1.50 1.60 1.70
Min. :-0.430 Min. :-0.30000 Min. :-0.3300 Min. :-0.3700
1st Qu.:-0.260 1st Qu.:-0.10500 1st Qu.:-0.3000 1st Qu.:-0.1150
Median :-0.230 Median : 0.01000 Median :-0.1800 Median :-0.0900
Mean :-0.200 Mean : 0.07714 Mean :-0.1557 Mean :-0.1029
3rd Qu.:-0.105 3rd Qu.: 0.30000 3rd Qu.:-0.0500 3rd Qu.:-0.0500
Max. :-0.010 Max. : 0.44000 Max. : 0.1200 Max. : 0.0700
1.80 1.90 2.00
Min. :-0.1900 Min. :-0.35000 Min. :-0.20000
1st Qu.: 0.0500 1st Qu.:-0.09500 1st Qu.:-0.09000
Median : 0.1900 Median :-0.03000 Median :-0.03000
Mean : 0.1571 Mean :-0.06286 Mean :-0.01429
3rd Qu.: 0.3050 3rd Qu.: 0.02000 3rd Qu.: 0.06000
Max. : 0.3900 Max. : 0.09000 Max. : 0.19000
2.20 2.40 2.60
Min. :-0.14000 Min. :-0.18000 Min. :-0.09000
1st Qu.:-0.11000 1st Qu.:-0.09000 1st Qu.:-0.07000
Median :-0.10000 Median :-0.06000 Median :-0.04000
Mean :-0.06143 Mean :-0.02857 Mean :-0.02286
3rd Qu.:-0.02500 3rd Qu.: 0.04500 3rd Qu.: 0.02000
Max. : 0.08000 Max. : 0.13000 Max. : 0.07000
2.80 3.00
Min. :-0.17000 Min. :-0.09000
1st Qu.:-0.08500 1st Qu.:-0.04500
Median :-0.03000 Median :-0.03000
Mean :-0.02714 Mean :-0.02571
3rd Qu.: 0.01500 3rd Qu.:-0.00500
Max. : 0.15000 Max. : 0.04000