# 13.10a
enzyme_data = read.csv("enzyme_data.csv")
summary(enzyme_data)
## Y X
## Min. : 2.10 Min. : 1.00
## 1st Qu.: 7.35 1st Qu.: 4.25
## Median :11.95 Median : 9.25
## Mean :12.04 Mean :13.53
## 3rd Qu.:16.95 3rd Qu.:19.38
## Max. :21.60 Max. :40.00
# transform the data
enzyme_data$tY = 1/enzyme_data$Y
enzyme_data$tX = 1/enzyme_data$X
linear_model = lm(enzyme_data$tY ~ enzyme_data$tX)
summary(linear_model)
##
## Call:
## lm(formula = enzyme_data$tY ~ enzyme_data$tX)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.05668 -0.00412 0.00069 0.00277 0.06357
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.03376 0.00668 5.05 0.00012 ***
## enzyme_data$tX 0.45401 0.02006 22.63 1.4e-13 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.0217 on 16 degrees of freedom
## Multiple R-squared: 0.97, Adjusted R-squared: 0.968
## F-statistic: 512 on 1 and 16 DF, p-value: 1.41e-13
# 13.10b
library(nls2)
## Loading required package: proto
nonlinear_model = nls2(Y ~ (g0 * X)/(g1 + X), data = enzyme_data, start = list(g0 = 1/linear_model$coeff[1],
g1 = linear_model$coeff[2]/linear_model$coeff[1]))
summary(nonlinear_model)
##
## Formula: Y ~ (g0 * X)/(g1 + X)
##
## Parameters:
## Estimate Std. Error t value Pr(>|t|)
## g0 28.137 0.728 38.6 < 2e-16 ***
## g1 12.574 0.763 16.5 1.9e-11 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.519 on 16 degrees of freedom
##
## Number of iterations to convergence: 4
## Achieved convergence tolerance: 4.35e-07
coef(nonlinear_model)
## g0 g1
## 28.14 12.57
# 13.11a
plot(enzyme_data$X, enzyme_data$Y, col = "red", pch = 20, xlab = "Concentration",
ylab = "Velocity")
x = enzyme_data$X
curve((coef(nonlinear_model)[1] * x)/(coef(nonlinear_model)[2] + x), add = TRUE,
col = "steelblue")
# 13.11b
par(mfrow = c(2, 2))
plot(fitted(nonlinear_model), residuals(nonlinear_model), xlab = "Fitted", ylab = "Residuals",
col = "red", pch = 20)
abline(h = 0, col = "steelblue")
plot(enzyme_data$X, residuals(nonlinear_model), xlab = "X", ylab = "Residuals",
col = "red", pch = 20)
abline(h = 0, col = "steelblue")
qqp = qqnorm(residuals(nonlinear_model), main = "Normal Probability Plot", col = "red")
qqline(residuals(nonlinear_model), col = "steelblue")
# 13.12
confint(nonlinear_model, "g0")
## Waiting for profiling to be done...
## 2.5% 97.5%
## 26.65 29.80
# see page 533 in book
qt(0.975, dim(enzyme_data)[1] - 2)
## [1] 2.12