Agenda
This lecture will practice running
- Plackett-Burman Design (PBD)
and
- Response surface method (RSM)
Before begin..
Let’s install packages.
install.packages("daewr")
##
## The downloaded binary packages are in
## /var/folders/z2/kwm76s1n3jj2sjznjyj9thqc0000gn/T//RtmpbjVHk8/downloaded_packages
library(daewr)
PBDes
function creates the experimental design of the
PBD. randomize = T will generate a matrix with mixed orders.
daewr::PBDes(nfactors = 11, nruns = 12)
## A B C D E F G H J K L
## 1 1 1 -1 1 1 1 -1 -1 -1 1 -1
## 2 -1 1 1 -1 1 1 1 -1 -1 -1 1
## 3 1 -1 1 1 -1 1 1 1 -1 -1 -1
## 4 -1 1 -1 1 1 -1 1 1 1 -1 -1
## 5 -1 -1 1 -1 1 1 -1 1 1 1 -1
## 6 -1 -1 -1 1 -1 1 1 -1 1 1 1
## 7 1 -1 -1 -1 1 -1 1 1 -1 1 1
## 8 1 1 -1 -1 -1 1 -1 1 1 -1 1
## 9 1 1 1 -1 -1 -1 1 -1 1 1 -1
## 10 -1 1 1 1 -1 -1 -1 1 -1 1 1
## 11 1 -1 1 1 1 -1 -1 -1 1 -1 1
## 12 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
After setting your higher level
and
lower level
based on your intuition, you can run a
experiment with 12 experimental groups, and get the result out of the
data.
analyiss of PBD outcome
You can run a miultiple linear regression that is containing all the data!
library(tidyverse)
read.csv("/Volumes/MacMini Drive/Dropbox (Personal)/Git/BTE3207_Advanced_Biostatistics(Macmini)_git/BTE3207_Advanced_Biostatistics/PBD_example_data.csv") %>%
names
## [1] "X" "Glucose" "YE" "KH2PO4" "K2HPO4" "MgSO4"
## [7] "CaCl2" "FeSO4" "Fructose" "NH4Cl" "TM" "Vitamin"
## [13] "Biomass"
lm(Biomass ~ Glucose + YE + KH2PO4 + K2HPO4 + MgSO4 + CaCl2 + FeSO4 + Fructose + NH4Cl + TM + Vitamin,
data = read.csv("/Volumes/MacMini Drive/Dropbox (Personal)/Git/BTE3207_Advanced_Biostatistics(Macmini)_git/BTE3207_Advanced_Biostatistics/PBD_example_data.csv")) %>% summary
##
## Call:
## lm(formula = Biomass ~ Glucose + YE + KH2PO4 + K2HPO4 + MgSO4 +
## CaCl2 + FeSO4 + Fructose + NH4Cl + TM + Vitamin, data = read.csv("/Volumes/MacMini Drive/Dropbox (Personal)/Git/BTE3207_Advanced_Biostatistics(Macmini)_git/BTE3207_Advanced_Biostatistics/PBD_example_data.csv"))
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.04 -0.02 0.00 0.02 0.04
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.437500 0.007022 347.134 < 2e-16 ***
## Glucose -0.012500 0.007022 -1.780 0.100360
## YE 0.845833 0.007022 120.458 < 2e-16 ***
## KH2PO4 0.037500 0.007022 5.341 0.000176 ***
## K2HPO4 0.572500 0.007022 81.532 < 2e-16 ***
## MgSO4 0.032500 0.007022 4.628 0.000582 ***
## CaCl2 -0.054167 0.007022 -7.714 5.45e-06 ***
## FeSO4 0.055833 0.007022 7.951 4.00e-06 ***
## Fructose 0.080833 0.007022 11.512 7.67e-08 ***
## NH4Cl -0.017500 0.007022 -2.492 0.028315 *
## TM 0.015833 0.007022 2.255 0.043611 *
## Vitamin -0.019167 0.007022 -2.730 0.018280 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.0344 on 12 degrees of freedom
## Multiple R-squared: 0.9994, Adjusted R-squared: 0.9989
## F-statistic: 1953 on 11 and 12 DF, p-value: < 2.2e-16
This is your Plackett-Burman result.
RSM
install.packages("rsm")
##
## The downloaded binary packages are in
## /var/folders/z2/kwm76s1n3jj2sjznjyj9thqc0000gn/T//RtmpbjVHk8/downloaded_packages
library(rsm)
using ccd
function, you can generate a experimental
design that can be used for RSM experiment and analysis
ccd (3)
## run.order std.order x1.as.is x2.as.is x3.as.is Block
## 1 1 12 0.000000 0.000000 0.000000 1
## 2 2 10 0.000000 0.000000 0.000000 1
## 3 3 11 0.000000 0.000000 0.000000 1
## 4 4 4 1.000000 1.000000 -1.000000 1
## 5 5 8 1.000000 1.000000 1.000000 1
## 6 6 6 1.000000 -1.000000 1.000000 1
## 7 7 5 -1.000000 -1.000000 1.000000 1
## 8 8 7 -1.000000 1.000000 1.000000 1
## 9 9 1 -1.000000 -1.000000 -1.000000 1
## 10 10 2 1.000000 -1.000000 -1.000000 1
## 11 11 9 0.000000 0.000000 0.000000 1
## 12 12 3 -1.000000 1.000000 -1.000000 1
## 13 1 9 0.000000 0.000000 0.000000 2
## 14 2 4 0.000000 1.825742 0.000000 2
## 15 3 6 0.000000 0.000000 1.825742 2
## 16 4 10 0.000000 0.000000 0.000000 2
## 17 5 2 1.825742 0.000000 0.000000 2
## 18 6 5 0.000000 0.000000 -1.825742 2
## 19 7 7 0.000000 0.000000 0.000000 2
## 20 8 1 -1.825742 0.000000 0.000000 2
## 21 9 3 0.000000 -1.825742 0.000000 2
## 22 10 8 0.000000 0.000000 0.000000 2
##
## Data are stored in coded form using these coding formulas ...
## x1 ~ x1.as.is
## x2 ~ x2.as.is
## x3 ~ x3.as.is
SOdes2 <- ccd (2, n0 = c(4,6), alpha = "rotatable", inscribed = F)
SOdes2
## run.order std.order x1.as.is x2.as.is Block
## 1 1 1 -1.000000 -1.000000 1
## 2 2 5 0.000000 0.000000 1
## 3 3 8 0.000000 0.000000 1
## 4 4 4 1.000000 1.000000 1
## 5 5 2 1.000000 -1.000000 1
## 6 6 6 0.000000 0.000000 1
## 7 7 7 0.000000 0.000000 1
## 8 8 3 -1.000000 1.000000 1
## 9 1 6 0.000000 0.000000 2
## 10 2 8 0.000000 0.000000 2
## 11 3 7 0.000000 0.000000 2
## 12 4 9 0.000000 0.000000 2
## 13 5 3 0.000000 -1.414214 2
## 14 6 5 0.000000 0.000000 2
## 15 7 4 0.000000 1.414214 2
## 16 8 10 0.000000 0.000000 2
## 17 9 1 -1.414214 0.000000 2
## 18 10 2 1.414214 0.000000 2
##
## Data are stored in coded form using these coding formulas ...
## x1 ~ x1.as.is
## x2 ~ x2.as.is
With coding
argument, you can set the levels of your
data into actual values
SOdes2 <- ccd (3, n0 = c(4,6), alpha = "rotatable", inscribed = F,
coding = list (
x1 ~ (Glucose - 50)/10,
x2 ~ (NaNO3 - 5)/2,
x3 ~ (K2HPO4 - 2)/1)
)
SOdes2
## run.order std.order Glucose NaNO3 K2HPO4 Block
## 1 1 9 50.00000 5.000000 2.0000000 1
## 2 2 1 40.00000 3.000000 1.0000000 1
## 3 3 8 60.00000 7.000000 3.0000000 1
## 4 4 4 60.00000 7.000000 1.0000000 1
## 5 5 12 50.00000 5.000000 2.0000000 1
## 6 6 7 40.00000 7.000000 3.0000000 1
## 7 7 11 50.00000 5.000000 2.0000000 1
## 8 8 3 40.00000 7.000000 1.0000000 1
## 9 9 6 60.00000 3.000000 3.0000000 1
## 10 10 10 50.00000 5.000000 2.0000000 1
## 11 11 2 60.00000 3.000000 1.0000000 1
## 12 12 5 40.00000 3.000000 3.0000000 1
## 13 1 6 50.00000 5.000000 3.6817928 2
## 14 2 4 50.00000 8.363586 2.0000000 2
## 15 3 8 50.00000 5.000000 2.0000000 2
## 16 4 2 66.81793 5.000000 2.0000000 2
## 17 5 7 50.00000 5.000000 2.0000000 2
## 18 6 3 50.00000 1.636414 2.0000000 2
## 19 7 1 33.18207 5.000000 2.0000000 2
## 20 8 10 50.00000 5.000000 2.0000000 2
## 21 9 12 50.00000 5.000000 2.0000000 2
## 22 10 11 50.00000 5.000000 2.0000000 2
## 23 11 5 50.00000 5.000000 0.3182072 2
## 24 12 9 50.00000 5.000000 2.0000000 2
##
## Data are stored in coded form using these coding formulas ...
## x1 ~ (Glucose - 50)/10
## x2 ~ (NaNO3 - 5)/2
## x3 ~ (K2HPO4 - 2)/1
Analysis of RSM
CR1.rsm <- rsm(Yield ~ Block + SO(Time, Temp), data = ChemReact)
summary(CR1.rsm)
##
## Call:
## rsm(formula = Yield ~ Block + SO(Time, Temp), data = ChemReact)
##
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -1.3992e+03 9.0919e+01 -15.390 1.180e-06 ***
## BlockB2 -4.4575e+00 8.7226e-02 -51.103 2.877e-10 ***
## Time 8.2097e+00 7.0225e-01 11.691 7.576e-06 ***
## Temp 1.2759e+01 8.8554e-01 14.408 1.848e-06 ***
## Time:Temp 5.0000e-03 3.2637e-03 1.532 0.1694
## Time^2 -5.2342e-02 2.4025e-03 -21.786 1.083e-07 ***
## Temp^2 -3.7338e-02 2.4025e-03 -15.541 1.104e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Multiple R-squared: 0.9981, Adjusted R-squared: 0.9964
## F-statistic: 607.2 on 6 and 7 DF, p-value: 3.811e-09
##
## Analysis of Variance Table
##
## Response: Yield
## Df Sum Sq Mean Sq F value Pr(>F)
## Block 1 69.531 69.531 2611.0950 2.879e-10
## FO(Time, Temp) 2 9.626 4.813 180.7341 9.450e-07
## TWI(Time, Temp) 1 0.062 0.062 2.3470 0.1694
## PQ(Time, Temp) 2 17.791 8.896 334.0539 1.135e-07
## Residuals 7 0.186 0.027
## Lack of fit 3 0.053 0.018 0.5307 0.6851
## Pure error 4 0.133 0.033
##
## Stationary point of response surface:
## Time Temp
## 86.86148 176.67190
##
## Eigenanalysis:
## eigen() decomposition
## $values
## [1] -0.03693211 -0.05274780
##
## $vectors
## [,1] [,2]
## Time -0.1601375 -0.9870947
## Temp -0.9870947 0.1601375
Here, besides the interaction term, all the term is significant.
Anova here tests the “lack of fit” which tests the variance not explaned by model but by the error (from the repeated experiments). This term’s p-values should be greater than effect of others!
To draw contour, use contour
function
contour(CR1.rsm, ~ Time + Temp, image = TRUE, at = summary(CR1.rsm)$canonical$xs)
To draw 3d plot, use persp
function
persp(CR1.rsm,
Time ~ Temp, #plot xs
col=rainbow(50),
xlabs = c(expression("Time (min)", "Temperature (°C)")), # axis labels
theta=30,
phi=30, r = 120, d=120,
border = NULL,
ltheta = 0,
lphi = 0,
shade = 0.75, zlab="Yield", col.axis=37, font.lab=2, col.lab=35,
contour=("colors"))
Bibliography
## Computing. R Foundation for Statistical Computing, Vienna, Austria. <https://www.R-project.org/>. We have invested a lot of time and effort in creating R, please cite it when using it for data analysis. See also 'citation("pkgname")' for citing R packages.
## Grolemund G, Hayes A, Henry L, Hester J, Kuhn M, Pedersen TL, Miller E, Bache SM, Müller K, Ooms J, Robinson D, Seidel DP, Spinu V, Takahashi K, Vaughan D, Wilke C, Woo K, Yutani H (2019). "Welcome to the tidyverse." Journal of Open Source Software_, *4*(43), 1686. doi:10.21105/joss.01686 <https://doi.org/10.21105/joss.01686>.
## R. version 0.5.0. Buffalo, New York. http://github.com/trinker/pacman
## J, reikoch, Beasley W, O'Connor B, Warnes GR, Quinn M, Kamvar ZN (2023). yaml: Methods to Convert R Data to YAML and Back_. R package version 2.3.7, <https://CRAN.R-project.org/package=yaml>. ATTENTION: This citation information has been auto-generated from the package DESCRIPTION file and may need manual editing, see 'help("citation")'.