The Gaussian Project was an introduction to statistical analysis. It’s purpose was for the understanding of how linear data could be distributed over a Gaussian function. It also aids in determining the mean of a data set. When the data set is graphed, a peak can also help indicate where most of the data points reside.
In the case for my project, I had compared the heights of males and females in the United States. The data set calculations had indicated that the average height for females in the United States was sixty-four inches while for males it was sixty-nine inches. The data set and graph code below helped show the findings.
M_data <- c(63,64,64,65,65,65,67,67,67,67,67,69,69,69,69,69,69,69,69,69,71,71,71,71,71,71,71,73,73,73,75,75,76)
W_data <- c(60,60,60,61,61,61,62,62,62,62,62,64,64,64,64,64,64,65,65,65,65,65,65,65,67,67,67,67,67,67,67,70,70)
#Here are the mean and standard deviation of the data
M_mean <- mean(M_data)
M_sd <- sd(M_data)
M_sd
## [1] 3.304898
W_mean <-mean(W_data)
W_sd <- sd(W_data)
W_sd
## [1] 2.707313
# Simulated Data for Gauss
simdata <- seq(60,80,0.5)
simdata
## [1] 60.0 60.5 61.0 61.5 62.0 62.5 63.0 63.5 64.0 64.5 65.0 65.5 66.0 66.5 67.0
## [16] 67.5 68.0 68.5 69.0 69.5 70.0 70.5 71.0 71.5 72.0 72.5 73.0 73.5 74.0 74.5
## [31] 75.0 75.5 76.0 76.5 77.0 77.5 78.0 78.5 79.0 79.5 80.0
# dp are for the probability
M_dp <- dnorm(simdata,M_mean,M_sd)
W_dp <- dnorm(simdata,W_mean,W_sd)
W_dp
## [1] 4.241389e-02 5.580673e-02 7.096626e-02 8.721760e-02 1.035960e-01
## [6] 1.189239e-01 1.319416e-01 1.414756e-01 1.466115e-01 1.468389e-01
## [11] 1.421351e-01 1.329684e-01 1.202216e-01 1.050517e-01 8.871779e-02
## [16] 7.241110e-02 5.711977e-02 4.354664e-02 3.208556e-02 2.284818e-02
## [21] 1.572462e-02 1.045914e-02 6.723544e-03 4.177222e-03 2.508209e-03
## [26] 1.455549e-03 8.163503e-04 4.425000e-04 2.318125e-04 1.173673e-04
## [31] 5.743076e-05 2.715993e-05 1.241366e-05 5.483496e-06 2.341004e-06
## [36] 9.659036e-07 3.851698e-07 1.484422e-07 5.529038e-08 1.990346e-08
## [41] 6.924595e-09
# Plot of the graph
plot(simdata,M_dp,col=("Green"),xlab="Height in Inches",ylab="Probability",xlim=c(60,80),ylim=c(0,0.5),main="Heights of Males and Females in The United States")
points(simdata,W_dp,pch=1,col=("red"))
legend("topright",legend=c("Men","Women"),col=c("Green","red"),lty=1:1, cex=.8)
t.test(M_data,W_data)
##
## Welch Two Sample t-test
##
## data: M_data and W_data
## t = 6.6417, df = 61.613, p-value = 9.159e-09
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 3.452576 6.426212
## sample estimates:
## mean of x mean of y
## 69.21212 64.27273
The linear regression project served to aid in our understanding of linear data sets. When a data set is referred to as being linear that means that there is a specific reoccurring trend found in the data. One example of a linear data set would be the increase in height as a child grows to become an adult. There are two main purposes when it comes to linear regression modeling. The first purpose is statistical modeling and the second purpose is predictive modeling. What these essentially mean is that the linear data set being analyzed has the ability to have unknown values determined due to a trend in the linear regression. The slope of the data set can be used to aid in figuring out a desirable data point.
In the case for my project, I used a linear data set showing the correlation between Altitude (In Meters) versus Temperature (In Celsius). The data set was from 1976 and was obtained from the National Oceanic And Atmospheric Administration (NOAA) in conjunction with the United States Air Force. It was found that as pilots increased in altitude, the temperature readings of the atmosphere would decrease. The data set and graph code below helped show the findings.
Altitude <- c(0,1000,2000,3000,4000,5000,6000,7000,8000,9000,10000)
# in meters above sea level
Temperature <- c(15.00,8.50,2.00,-4.49,-10.98,-17.47,-23.96,-30.45,-36.94,-43.42,-49.90)
# in Celsius
Xdata <- data.frame(Altitude,Temperature)
# x and y to a data frame
knitr::kable(Xdata[,],)
| Altitude | Temperature |
|---|---|
| 0 | 15.00 |
| 1000 | 8.50 |
| 2000 | 2.00 |
| 3000 | -4.49 |
| 4000 | -10.98 |
| 5000 | -17.47 |
| 6000 | -23.96 |
| 7000 | -30.45 |
| 8000 | -36.94 |
| 9000 | -43.42 |
| 10000 | -49.90 |
col.names = c('Altitude(meters)','Temperature')
caption = ("Temperature change data") # makes a table
BL <- lm (Temperature ~ Altitude)
# linear regression
summary(BL)
##
## Call:
## lm(formula = Temperature ~ Altitude)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.005455 -0.005455 -0.005455 0.004546 0.014545
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.499e+01 4.877e-03 3073 <2e-16 ***
## Altitude -6.490e-03 8.243e-07 -7873 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.008646 on 9 degrees of freedom
## Multiple R-squared: 1, Adjusted R-squared: 1
## F-statistic: 6.198e+07 on 1 and 9 DF, p-value: < 2.2e-16
# summarize results of linear regression
cf <- coef(BL)
int <- cf[1]
sl <- cf[2]
int
## (Intercept)
## 14.98545
sl
## Altitude
## -0.00649
# vector: intercept and slope
plot(Altitude,Temperature, main = "Altitude versus Temperature", xlab = "",
ylab = "Temperature, celsius", xlim = c(-1000,11000),
ylim = c(-55,20),
sub ="Figure 1. Plot Showing Temperature Decrease as Altitude Increases")
title(xlab="Altitude, meters", line=2, cex.lab=1.0)
library(plotrix)
abline(BL,col = "red")
ablineclip(a =0.0, b = 0.3,x1=2,x2=18)
plot(Altitude,residuals(BL))
Before the discussion of the titration analysis for the monoprotic data set, it is important to first explain what a monoprotic acid is, as well as explaining what monoprotic titration involves. A monoprotic acid refers to an acid that can donate one proton, hence the prefix mono (one) and word protic (proton) coming together to form the word. During a monoprotic titration, the monoprotic acid is titrated by a base. If you were to record the pH of the solution as well as the number of titrant being added, a titration curve could be determined. On the titration curve, an equivalence point can be determined. An equivalence point is the point during titration where an equal amount of acid and base have been added. On the graph, the equivalence point is represented as a steep and steady rise in the y direction. It is here where there is not much of a change in the pH of the monoprotic acid being titrated.
Below is a graph of the monoprotic titration curve. Note, the graph is mainly focused on the data near the equivalence point, the data before and after the equivalence point is not shown on the graph. It can be also noted that as more NaOH was titrated to the monoprotic acid, the pH of the acid was slowly increasing. The level off point in the graph where the base and acid are equal can also be observed
# The data being read is from the following CSV file
mydata <- read.csv("quant_titration_data.csv")
# Below shows how the vectors were identified for the data set
pH <-mydata$pH
volume <- mydata$mL
length(volume)
## [1] 21
length(pH)
## [1] 21
volume
## [1] 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
pH
## [1] 2.83 3.22 3.48 3.65 3.82 3.95 4.06 4.17 4.26 4.35 4.45 4.63 4.73 4.84 4.95
## [16] 5.01 5.10 5.27 5.47 5.79 6.34
# The plot of the data point vectors for the volume of NaOH and pH
plot(volume, pH, main = "Monoprotic Titration Curve", xlab = "volume of NaOH", ylab = "pH")
Below is a graph for the fraction bound binding curve of the monoprotic data set. A fraction bound binding curve analysis is performed in order to understand the binding affinity of the acid that was titrated. Referring to the graph below shows that fraction binding of the acid decreases as it is titrated with a base and the pH increases.
The equation used to create the binding curve shown below was:
fraction bound = 1 - [ CB x Vadd + [H+] x (Vini + Vadd)] / (CB * Vend)
# Binding curve from tiration data
H <- 10^-(pH)
CB <- 0.01 # base concentration
Vadd <- volume # Amount of base added
Vini <- 25 # initial volume of acid
Vend <- 20.5 # estimated volume added to get to the endpoint
# fraction bound = 1 - [ CB x Vadd + [H+] x (Vini + Vadd)] / (CB * Vend)
fb <- 1 - (CB * Vadd + H * (Vini + Vadd)) / (CB * Vend)
fb
## [1] 0.81962093 0.87479732 0.85882663 0.82308088 0.78346669 0.73967778
## [7] 0.69414640 0.64798310 0.60090983 0.55356720 0.50613733 0.45929794
## [13] 0.41127331 0.36317431 0.31493860 0.26638588 0.21792354 0.16963145
## [19] 0.12124047 0.07282264 0.02428991
plot(pH,fb)
library(nls2)
## Loading required package: proto
fit <- nls2(fb ~ H/(KD+H), start=c(KD=0.0001))
summary(fit)
##
## Formula: fb ~ H/(KD + H)
##
## Parameters:
## Estimate Std. Error t value Pr(>|t|)
## KD 3.237e-05 2.200e-06 14.71 3.43e-12 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.05318 on 20 degrees of freedom
##
## Number of iterations to convergence: 7
## Achieved convergence tolerance: 1.183e-06
lines(pH,predict(fit), col="Blue")
The concentration of the acid or base used in the titration can be measured directly.
Titrations are simple to perform.
Titration analysis is usually only performed with acid-base reactions.
The titration curve obtained only allows for partial understanding of the kinectics of the reaction since only one end point can be determined.
Binding analysis doesn’t only pertain to acid-base reactions. It can be used when dealing with enzymes and protein interactions. This is very beneficial in the medical world.
Binding curve graphs allow for a visual representation of how molecular interactions occur.
There are a lot more sophisticated techniques required to accurately determine your data. Having a higher understanding of analytical chemistry is necessary.
Interpreting the data obtained can be difficult and it may be neccessay to experiment with different parameters used to obtain graphs and functions.
A diprotic acid refers to an acid that can donate two protons. The word diprotic is composed of the prefix di (two) and the word protic (proton). During a diprotic titration, the diprotic acid is titrated by a base. When a titration curve is created for the diprotic acid, a very different result is obtained compared to a monoprotic acid. Rather than having one sharp rise in pH (as in the case for a monoprotic acid), there are two sharp rises in pH. The reason why there are two sharp jumps in pH is because a diprotic acid has two protons to donate. At specific pH levels a proton is given off to the base two times. What this means is that two equivalence points are able to be recorded.
Below is the code used to produce the titration curve for the diprotic acid. The titration curves has to sharp rises in pH at the 7 pH range and 14 pH range. The code is very similar to the code used to make the titration curve for the monoprotic acid titration curve above.
library(readxl)
mydata <- read.csv("DP Data.csv")
mydata
## Consumption..mL. Potential..pH.
## 1 1.728 1.90
## 2 1.928 1.92
## 3 2.128 1.94
## 4 2.328 1.97
## 5 2.528 2.01
## 6 2.728 2.05
## 7 2.928 2.07
## 8 3.129 2.10
## 9 3.329 2.14
## 10 3.529 2.18
## 11 3.729 2.22
## 12 3.929 2.27
## 13 4.129 2.31
## 14 4.329 2.37
## 15 4.529 2.42
## 16 4.729 2.48
## 17 4.929 2.56
## 18 5.129 2.61
## 19 5.329 2.71
## 20 5.529 2.81
## 21 5.729 2.92
## 22 5.929 3.11
## 23 6.115 3.29
## 24 6.304 3.58
## 25 6.377 3.73
## 26 6.446 3.89
## 27 6.515 4.06
## 28 6.585 4.23
## 29 6.661 4.40
## 30 6.752 4.56
## 31 6.876 4.76
## 32 7.014 4.92
## 33 7.214 5.10
## 34 7.414 5.23
## 35 7.614 5.35
## 36 7.814 5.45
## 37 8.014 5.53
## 38 8.214 5.61
## 39 8.414 5.68
## 40 8.614 5.74
## 41 8.814 5.80
## 42 9.014 5.86
## 43 9.214 5.92
## 44 9.414 5.97
## 45 9.614 6.02
## 46 9.814 6.08
## 47 10.014 6.12
## 48 10.214 6.17
## 49 10.414 6.21
## 50 10.614 6.23
## 51 10.814 6.31
## 52 11.015 6.37
## 53 11.215 6.42
## 54 11.415 6.43
## 55 11.615 6.52
## 56 11.815 6.58
## 57 12.015 6.64
## 58 12.215 6.65
## 59 12.415 6.76
## 60 12.615 6.77
## 61 12.815 6.91
## 62 13.015 6.92
## 63 13.215 7.09
## 64 13.415 7.10
## 65 13.615 7.35
## 66 13.724 7.36
## 67 13.924 7.69
## 68 13.987 7.70
## 69 14.145 8.16
## 70 14.165 8.18
## 71 14.214 8.40
## 72 14.223 8.44
## 73 14.245 8.53
## 74 14.294 8.55
## 75 14.418 9.08
## 76 14.427 9.11
## 77 14.450 9.13
## 78 14.506 9.28
## 79 14.529 9.30
## 80 14.587 9.43
## 81 14.620 9.48
## 82 14.704 9.60
## 83 14.856 9.77
## 84 15.056 9.95
volume <- mydata$Consumption..mL.
volume
## [1] 1.728 1.928 2.128 2.328 2.528 2.728 2.928 3.129 3.329 3.529
## [11] 3.729 3.929 4.129 4.329 4.529 4.729 4.929 5.129 5.329 5.529
## [21] 5.729 5.929 6.115 6.304 6.377 6.446 6.515 6.585 6.661 6.752
## [31] 6.876 7.014 7.214 7.414 7.614 7.814 8.014 8.214 8.414 8.614
## [41] 8.814 9.014 9.214 9.414 9.614 9.814 10.014 10.214 10.414 10.614
## [51] 10.814 11.015 11.215 11.415 11.615 11.815 12.015 12.215 12.415 12.615
## [61] 12.815 13.015 13.215 13.415 13.615 13.724 13.924 13.987 14.145 14.165
## [71] 14.214 14.223 14.245 14.294 14.418 14.427 14.450 14.506 14.529 14.587
## [81] 14.620 14.704 14.856 15.056
pH <- mydata$Potential..pH.
pH
## [1] 1.90 1.92 1.94 1.97 2.01 2.05 2.07 2.10 2.14 2.18 2.22 2.27 2.31 2.37 2.42
## [16] 2.48 2.56 2.61 2.71 2.81 2.92 3.11 3.29 3.58 3.73 3.89 4.06 4.23 4.40 4.56
## [31] 4.76 4.92 5.10 5.23 5.35 5.45 5.53 5.61 5.68 5.74 5.80 5.86 5.92 5.97 6.02
## [46] 6.08 6.12 6.17 6.21 6.23 6.31 6.37 6.42 6.43 6.52 6.58 6.64 6.65 6.76 6.77
## [61] 6.91 6.92 7.09 7.10 7.35 7.36 7.69 7.70 8.16 8.18 8.40 8.44 8.53 8.55 9.08
## [76] 9.11 9.13 9.28 9.30 9.43 9.48 9.60 9.77 9.95
H <- 10^(-pH)
H
## [1] 1.258925e-02 1.202264e-02 1.148154e-02 1.071519e-02 9.772372e-03
## [6] 8.912509e-03 8.511380e-03 7.943282e-03 7.244360e-03 6.606934e-03
## [11] 6.025596e-03 5.370318e-03 4.897788e-03 4.265795e-03 3.801894e-03
## [16] 3.311311e-03 2.754229e-03 2.454709e-03 1.949845e-03 1.548817e-03
## [21] 1.202264e-03 7.762471e-04 5.128614e-04 2.630268e-04 1.862087e-04
## [26] 1.288250e-04 8.709636e-05 5.888437e-05 3.981072e-05 2.754229e-05
## [31] 1.737801e-05 1.202264e-05 7.943282e-06 5.888437e-06 4.466836e-06
## [36] 3.548134e-06 2.951209e-06 2.454709e-06 2.089296e-06 1.819701e-06
## [41] 1.584893e-06 1.380384e-06 1.202264e-06 1.071519e-06 9.549926e-07
## [46] 8.317638e-07 7.585776e-07 6.760830e-07 6.165950e-07 5.888437e-07
## [51] 4.897788e-07 4.265795e-07 3.801894e-07 3.715352e-07 3.019952e-07
## [56] 2.630268e-07 2.290868e-07 2.238721e-07 1.737801e-07 1.698244e-07
## [61] 1.230269e-07 1.202264e-07 8.128305e-08 7.943282e-08 4.466836e-08
## [66] 4.365158e-08 2.041738e-08 1.995262e-08 6.918310e-09 6.606934e-09
## [71] 3.981072e-09 3.630781e-09 2.951209e-09 2.818383e-09 8.317638e-10
## [76] 7.762471e-10 7.413102e-10 5.248075e-10 5.011872e-10 3.715352e-10
## [81] 3.311311e-10 2.511886e-10 1.698244e-10 1.122018e-10
plot(volume, pH, main = "Diprotic Titration Curve", xlab = "volume of NaOH", ylab = "pH")
Below is the code used to perform the binding curve transformation for the diprotic data set. The code is similar to the code used for the monoprotic binding curve transformation, however there are a few differences. There is no code pertaining to H as in the monoprotic data code. The Vend also is being divided by 2 and there are two kd values being used in the fit line. The reason for the division and two kd’s is because this code refers to the data for the diprotic acid.
The code for the fit line is:
fit <- nls2(FB ~ (H/KD1+(2H^2)/(KD1KD2))/(1+H/KD1+H^2/(KD1*KD2)),start=c(KD1=0.0000005799,KD2=0.02439))
If you were to compare the code used for the diprotic data set with the code used for the monoprotic data set then you can see that the drastic difference in complexity. The complexity in achieving the proper formula is due to the fact that there are multiple kd values that have to be taken into account during graphing. When using the summary fit command it gives you the kd values needed for the equation above.
Vinital <- 25.00
Vadd <- volume
Vend <- 14/2
CB <- 0.100
FB <- 2 - ((CB * Vadd) + H * (Vinital + Vadd)) / (CB * Vend)
FB
## [1] 1.272449166 1.262077476 1.251041265 1.249107435 1.254551625
## [6] 1.257248486 1.242134527 1.233804873 1.231249338 1.226586809
## [11] 1.219986652 1.216774388 1.206331897 1.202840704 1.192619819
## [16] 1.183797184 1.178098127 1.161631536 1.154233090 1.142594539
## [21] 1.128793737 1.118702076 1.103631883 1.087666013 1.080653327
## [26] 1.073355672 1.065364512 1.056628768 1.046627933 1.034179253
## [31] 1.016922941 0.997450153 0.969063022 0.940584475 0.912077598
## [36] 0.883547959 0.855003670 0.826454956 0.797900269 0.769341189
## [41] 0.740780583 0.712218639 0.683655522 0.655090178 0.626524206
## [46] 0.597958633 0.569390627 0.540823132 0.512254520 0.483684327
## [51] 0.455117799 0.426406624 0.397837473 0.369266386 0.340698489
## [56] 0.312129024 0.283559315 0.254988098 0.226419283 0.197848017
## [61] 0.169279068 0.140707757 0.112138420 0.083567069 0.054997536
## [66] 0.039426157 0.010856008 0.001856032 -0.020714673 -0.023571798
## [71] -0.030571652 -0.031857346 -0.035000165 -0.042000158 -0.059714333
## [76] -0.061000044 -0.064285756 -0.072285744 -0.075571457 -0.083857164
## [81] -0.088571447 -0.100571443 -0.122285724 -0.150857149
plot(pH,FB,main ="FB Vs. pH of Diprotic Acid ",xlim = c(2,10),ylim = c(0.0,1.5) )
library(nls2)
fit <- nls2(FB ~ (H/KD1+(2*H^2)/(KD1*KD2))/(1+H/KD1+H^2/(KD1*KD2)), start=c(KD1=0.0000005799,KD2=0.02439))
summary(fit)
##
## Formula: FB ~ (H/KD1 + (2 * H^2)/(KD1 * KD2))/(1 + H/KD1 + H^2/(KD1 *
## KD2))
##
## Parameters:
## Estimate Std. Error t value Pr(>|t|)
## KD1 5.799e-07 2.717e-08 21.34 <2e-16 ***
## KD2 2.439e-02 1.737e-03 14.04 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.05214 on 82 degrees of freedom
##
## Number of iterations to convergence: 2
## Achieved convergence tolerance: 7.441e-07
lines(pH,predict(fit),col="red")