R+script+for+response+surface+design

creaminess carrageenan <- rep(rep(c(-1,-1,1,1),times=2),times=51) guar <- rep(c(rep(c(1),times=4),rep(c(-1),times=4)),times=51) panodan <- rep(rep(c(1,-1),times=4),times=51) level.design <- data.frame(carrageenan=factor(carrageenan), guar=factor(guar),panodan=factor(panodan)) level.design
 * 1) Examine experimental design
 * 1) view design

A <- rep(rep(c(0.1,0.1,0.25,0.25),times=2),times=51) B <- rep(c(rep(c(1),times=4),rep(c(0.5),times=4)),times=51) C <- rep(rep(c(1,0.5),times=4),times=51) R1<-c(5,5,6,6,5,6,6,8) R2<-c(6,7,7,5,6,8,7,7) R3<-c(9,8,8,7,8,7,9,9) R4<-c(8,9,9,8,7,8,9,9) R5<-c(8,8,8,8,8,8,7,7) R6<-c(8,8,7,7,8,8,6,8) R7<-c(5,8,5,8,4,6,6,4) R8<-c(8,7,7,6,7,9,5,8) R9<-c(6,6,7,8,8,7,8,8) R10<-c(6,8,8,6,8,8,7,9) R11<-c(8,8,8,8,7,7,8,7) R12<-c(8,8,8,9,8,9,9,9) R13<-c(8,8,8,8,8,8,7,6) R14<-c(7,8,6,9,8,8,8,8) R15<-c(7,7,8,7,6,8,7,8) R16<-c(6,6,4,7,6,7,6,7) R17<-c(5,7,5,7,3,3,4,5) R18<-c(8,6,9,7,7,8,8,8) R19<-c(8,7,7,8,6,8,6,7) R20<-c(8,9,8,8,7,7,7,7) R21<-c(8,7,8,6,5,8,8,7) R22<-c(3,7,2,3,2,2,6,7) R23<-c(6,8,2,8,7,8,9,9) R24<-c(7,8,9,8,8,8,8,8) R25<-c(7,8,8,8,8,8,8,8) R26<-c(7,6,7,7,6,5,6,7) R27<-c(7,7,8,7,7,7,7,7) R28<-c(8,8,8,8,8,8,8,8) R29<-c(3,6,7,5,6,5,5,3) R30<-c(6,8,7,5,8,7,7,8) R31<-c(6,5,7,8,8,8,8,7) R32<-c(9,9,9,8,9,7,7,6) R33<-c(6,6,8,8,3,7,6,5) R34<-c(7,8,5,8,4,8,6,7) R35<-c(6,8,6,7,5,6,5,4) R36<-c(7,7,6,7,5,6,5,6) R37<-c(8,8,8,8,8,8,8,7) R38<-c(7,6,6,6,6,5,6,5) R39<-c(6,5,7,8,9,7,7,7) R40<-c(7,7,7,7,6,6,6,6) R41<-c(7,7,8,7,9,8,7,8) R42<-c(7,6,6,7,6,8,5,6) R43<-c(6,6,7,7,6,7,6,6) R44<-c(6,6,6,8,7,6,7,7) R45<-c(6,6,8,6,8,7,7,9) R46<-c(8,7,6,7,7,7,7,7) R47<-c(8,7,7,7,7,7,8,7) R48<-c(7,7,6,7,8,6,5,7) R49<-c(6,7,7,7,7,6,9,8) R50<-c(6,7,6,8,7,6,8,7) R51<-c(7,6,8,7,7,7,8,8) Response <- c(R1,R2,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12,R13,R14,R15,R16,R17,R18,R19,R20, R21,R22,R23,R24,R25,R26,R27,R28,R29,R30,R31,R32,R33,R34,R35,R36,R37,R38,R39,R40, R41,R42,R43,R44,R45,R46,R47,R48,R49,R50,R51) design<- data.frame(A=factor(A),B=factor(B),C=factor(C),Response) design
 * 1) Create levels for each factor
 * 1) Step 2. Add response R1to R51
 * 1) Create table of data as a data.frame

design.aov <- aov(Response~A*B*C,data=design) summary(design.aov)
 * 1) Examine ANOVA table

oldpar <- par(oma=c(0,0,3,0), mfrow=c(2,2)) plot(design.aov) par(oldpar)

library(rsm) design.rsm <- data.frame(A,B,C,Response) design.CR <- coded.data(design.rsm, x1~(A-0.175)/0.075, x2~(B-0.75)/0.25, x3~(C-0.75)/0.25) design.CR
 * 1) load RSM library
 * 1) Create data frame for RSM analysis
 * 1) Create coding variables
 * 1) view codings

design.rs1 <- rsm(Response ~ FO(x1,x2,x3)+TWI(x1,x2,x3), data=design.CR) summary (design.rs1)
 * 1) Fit first order (FO) model of main effects and 2-way interactions (TWI)

x11 par(mfrow = c(1,2)) persp(design.rs1, ~x1+x2,col = rainbow(50),contours = "colors", xlab=c("carrageenan (x1)", "guar (x2)"), at=list(x3="1"),zlab = "Response", cex.lab=1.2) contour(design.rs1, ~x1+x2,col = rainbow(10), xlab=c("carrageenan (x1)", "guar (x2)"),labcex=1.5,at=list(x3="1"))
 * 1) Plot 3D and contour plot

carrageenan <- rep(rep(c(-1,-1,1,1),times=2),times=50) guar <- rep(c(rep(c(1),times=4),rep(c(-1),times=4)),times=50) panodan <- rep(rep(c(1,-1),times=4),times=50) level.design <- data.frame(carrageenan=factor(carrageenan), guar=factor(guar),panodan=factor(panodan)) level.design
 * 1) softness
 * 2) Examine experimental design
 * 1) view design

A <- rep(rep(c(0.1,0.1,0.25,0.25),times=2),times=50) B <- rep(c(rep(c(1),times=4),rep(c(0.5),times=4)),times=50) C <- rep(rep(c(1,0.5),times=4),times=50) R1<-c(4,4,5,4,4,6,7,6) R2<-c(7,7,7,5,6,8,7,8) R3<-c(9,8,8,7,8,7,9,9) R4<-c(9,8,8,8,7,8,9,9) R5<-c(7,7,7,7,7,7,8,7) R6<-c(4,4,4,3,8,8,6,8) R7<-c(8,8,5,7,4,5,6,5) R8<-c(8,5,7,6,7,9,5,8) R9<-c(6,7,7,7,8,6,8,8) R10<-c(7,3,8,6,4,8,8,4) R11<-c(8,9,9,8,9,8,9,9) R12<-c(8,8,8,8,8,8,8,6) R13<-c(8,8,7,8,8,9,9,8) R14<-c(7,8,8,7,7,8,7,8) R15<-c(4,7,6,6,7,5,6,6) R16<-c(6,7,6,7,4,4,4,6) R17<-c(8,7,8,7,7,9,7,9) R18<-c(8,7,8,7,6,8,7,7) R19<-c(6,8,7,6,4,4,4,7) R20<-c(8,7,7,7,6,7,7,6) R21<-c(3,7,2,4,2,6,6,7) R22<-c(6,8,4,7,9,8,8,8) R23<-c(7,8,8,8,7,8,8,8) R24<-c(8,7,8,7,7,8,8,8) R25<-c(6,6,7,7,5,6,5,7) R26<-c(8,8,8,6,7,7,8,7) R27<-c(8,8,8,8,8,8,8,8) R28<-c(3,7,4,6,4,3,4,3) R29<-c(7,7,7,5,8,8,7,7) R30<-c(8,6,6,8,6,8,8,8) R31<-c(9,9,8,8,8,7,7,6) R32<-c(7,5,8,7,1,6,7,4) R33<-c(9,8,8,9,5,6,7,8) R34<-c(6,7,5,5,6,6,6,5) R35<-c(7,7,7,7,7,7,7,6) R36<-c(7,8,8,7,7,7,8,8) R37<-c(6,6,7,7,7,6,6,5) R38<-c(6,7,8,7,6,7,6,7) R39<-c(7,8,6,6,6,7,7,7) R40<-c(8,8,8,8,8,6,6,8) R41<-c(6,6,6,8,6,8,7,6) R42<-c(6,6,7,6,6,7,6,5) R43<-c(7,6,7,7,7,6,7,8) R44<-c(6,7,9,6,9,8,7,9) R45<-c(7,7,7,6,7,8,6,8) R46<-c(7,7,6,8,7,8,9,8) R47<-c(6,7,7,7,8,5,5,7) R48<-c(7,7,8,6,8,6,8,9) R49<-c(7,8,6,8,7,7,8,9) R50<-c(8,6,7,7,7,8,7,8) Response <- c(R1,R2,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12,R13,R14,R15,R16,R17,R18,R19,R20, R21,R22,R23,R24,R25,R26,R27,R28,R29,R30,R31,R32,R33,R34,R35,R36,R37,R38,R39,R40, R41,R42,R43,R44,R45,R46,R47,R48,R49,R50) design<- data.frame(A=factor(A),B=factor(B),C=factor(C),Response) design
 * 1) Create levels for each factor
 * 1) Step 2. Add response R1to R50
 * 1) Create table of data as a data.frame

design.aov <- aov(Response~A*B*C,data=design) summary(design.aov)
 * 1) Examine ANOVA table

oldpar <- par(oma=c(0,0,3,0), mfrow=c(2,2)) plot(design.aov) par(oldpar)

library(rsm) design.rsm <- data.frame(A,B,C,Response) design.CR <- coded.data(design.rsm, x1~(A-0.175)/0.075, x2~(B-0.75)/0.25, x3~(C-0.75)/0.25) design.CR
 * 1) load RSM library
 * 1) Create data frame for RSM analysis
 * 1) Create coding variables
 * 1) view codings

design.rs1 <- rsm(Response ~ FO(x1,x2,x3)+TWI(x1,x2,x3), data=design.CR) summary (design.rs1)
 * 1) Fit first order (FO) model of main effects and 2-way interactions (TWI)

x11 par(mfrow = c(1,2)) persp(design.rs1, ~x1+x2,col = rainbow(50),contours = "colors", xlab=c("carrageenan (x1)", "guar (x2)"), at=list(x3="1"),zlab = "Response", cex.lab=1.2) contour(design.rs1, ~x1+x2,col = rainbow(10), xlab=c("carrageenan (x1)", "guar (x2)"),labcex=1.5,at=list(x3="1"))
 * 1) Plot 3D and contour plot

carrageenan <- rep(rep(c(-1,-1,1,1),times=2),times=50) guar <- rep(c(rep(c(1),times=4),rep(c(-1),times=4)),times=50) panodan <- rep(rep(c(1,-1),times=4),times=50) level.design <- data.frame(carrageenan=factor(carrageenan), guar=factor(guar),panodan=factor(panodan)) level.design
 * 1) iciness
 * 2) Examine experimental design
 * 1) view design

A <- rep(rep(c(0.1,0.1,0.25,0.25),times=2),times=50) B <- rep(c(rep(c(1),times=4),rep(c(0.5),times=4)),times=50) C <- rep(rep(c(1,0.5),times=4),times=50) R1<-c(6,6,6,3,7,7,7,3) R2<-c(8,7,7,6,6,7,6,7) R3<-c(9,8,9,6,9,6,9,9) R4<-c(8,8,8,8,7,8,9,9) R5<-c(7,7,7,5,7,7,7,7) R6<-c(5,7,3,4,8,8,4,4) R7<-c(4,6,5,5,6,5,6,6) R8<-c(5,4,4,5,7,8,6,7) R9<-c(6,7,7,7,7,7,8,8) R10<-c(7,5,4,8,8,8,8,6) R11<-c(8,7,8,9,8,9,9,8) R12<-c(8,7,8,8,8,8,8,6) R13<-c(8,8,7,8,6,8,9,7) R14<-c(8,5,8,8,8,7,8,7) R15<-c(4,7,6,3,7,5,3,6) R16<-c(3,3,4,5,2,3,2,3) R17<-c(7,7,7,3,7,8,8,8) R18<-c(8,7,9,8,7,7,6,7) R19<-c(8,8,7,8,4,4,5,8) R20<-c(8,4,7,4,4,7,7,6) R21<-c(5,8,2,4,1,6,2,5) R22<-c(4,7,2,7,9,8,9,4) R23<-c(7,7,8,6,8,7,8,6) R24<-c(8,7,8,7,7,8,8,8) R25<-c(7,5,4,7,4,7,7,7) R26<-c(6,7,7,7,8,7,8,6) R27<-c(8,8,8,8,8,8,8,8) R28<-c(6,7,3,6,4,5,5,5) R29<-c(7,7,6,5,8,7,8,7) R30<-c(5,8,4,4,5,4,7,5) R31<-c(7,8,8,8,7,8,6,6) R32<-c(8,4,6,6,1,6,6,5) R33<-c(7,6,7,9,6,8,8,8) R34<-c(5,5,5,6,4,7,6,6) R35<-c(7,8,6,7,6,6,6,6) R36<-c(8,8,7,7,8,8,8,8) R37<-c(5,7,8,6,6,6,7,5) R38<-c(5,7,7,5,7,7,7,7) R39<-c(6,6,6,6,6,6,8,6) R40<-c(6,6,8,7,8,7,7,8) R41<-c(6,6,7,7,6,8,6,6) R42<-c(6,5,6,6,6,6,6,6) R43<-c(7,6,7,7,7,6,7,8) R44<-c(5,7,9,6,9,7,8,9) R45<-c(7,8,6,7,7,7,6,8) R46<-c(8,7,8,6,8,6,8,7) R47<-c(7,7,7,7,8,5,5,7) R48<-c(8,8,8,8,7,8,8,7) R49<-c(6,8,6,8,7,8,8,8) R50<-c(8,7,8,7,7,7,8,8) Response <- c(R1,R2,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12,R13,R14,R15,R16,R17,R18,R19,R20, R21,R22,R23,R24,R25,R26,R27,R28,R29,R30,R31,R32,R33,R34,R35,R36,R37,R38,R39,R40, R41,R42,R43,R44,R45,R46,R47,R48,R49,R50) design<- data.frame(A=factor(A),B=factor(B),C=factor(C),Response) design
 * 1) Create levels for each factor
 * 1) Step 2. Add response R1to R50
 * 1) Create table of data as a data.frame

design.aov <- aov(Response~A*B*C,data=design) summary(design.aov)
 * 1) Examine ANOVA table

oldpar <- par(oma=c(0,0,3,0), mfrow=c(2,2)) plot(design.aov) par(oldpar)

library(rsm) design.rsm <- data.frame(A,B,C,Response) design.CR <- coded.data(design.rsm, x1~(A-0.175)/0.075, x2~(B-0.75)/0.25, x3~(C-0.75)/0.25) design.CR
 * 1) load RSM library
 * 1) Create data frame for RSM analysis
 * 1) Create coding variables
 * 1) view codings

design.rs1 <- rsm(Response ~ FO(x1,x2,x3)+TWI(x1,x2,x3), data=design.CR) summary (design.rs1)
 * 1) Fit first order (FO) model of main effects and 2-way interactions (TWI)

x11 par(mfrow = c(1,2)) persp(design.rs1, ~x1+x2,col = rainbow(50),contours = "colors", xlab=c("carrageenan (x1)", "guar (x2)"), at=list(x3="1"),zlab = "Response", cex.lab=1.2) contour(design.rs1, ~x1+x2,col = rainbow(10), xlab=c("carrageenan (x1)", "guar (x2)"),labcex=1.5,at=list(x3="1"))
 * 1) Plot 3D and contour plot

carrageenan <- rep(rep(c(-1,-1,1,1),times=2),times=51) guar <- rep(c(rep(c(1),times=4),rep(c(-1),times=4)),times=51) panodan <- rep(rep(c(1,-1),times=4),times=51) level.design <- data.frame(carrageenan=factor(carrageenan), guar=factor(guar),panodan=factor(panodan)) level.design
 * 1) overall
 * 2) Examine experimental design
 * 1) view design

A <- rep(rep(c(0.1,0.1,0.25,0.25),times=2),times=51) B <- rep(c(rep(c(1),times=4),rep(c(0.5),times=4)),times=51) C <- rep(rep(c(1,0.5),times=4),times=51) R1<-c(5,6,6,4,5,7,7,6) R2<-c(7,7,7,6,6,8,6,7) R3<-c(9,9,9,6,8,6,9,9) R4<-c(9,8,8,8,8,8,9,9) R5<-c(8,8,8,7,8,8,8,8) R6<-c(8,8,8,8,9,9,7,7) R7<-c(6,7,4,5,5,5,8,6) R8<-c(8,6,4,4,7,9,5,7) R9<-c(6,7,7,8,9,7,8,8) R10<-c(6,7,7,7,7,8,8,6) R11<-c(8,8,8,9,8,9,9,9) R12<-c(9,8,8,9,8,8,8,6) R13<-c(7,8,7,8,7,8,8,8) R14<-c(8,7,8,8,7,8,7,8) R15<-c(4,6,4,5,7,6,5,6) R16<-c(6,5,4,7,4,3,3,5) R17<-c(7,7,8,6,8,8,8,8) R18<-c(8,7,8,8,6,7,6,7) R19<-c(6,7,6,7,4,6,7,7) R20<-c(8,6,6,6,5,7,8,6) R21<-c(3,7,2,3,2,5,4,6) R22<-c(5,7,3,7,8,8,9,6) R23<-c(7,8,9,6,8,8,8,7) R24<-c(7,8,8,8,8,8,8,8) R25<-c(6,5,5,7,5,6,6,7) R26<-c(7,8,8,7,7,7,8,7) R27<-c(8,8,8,8,8,8,8,8) R28<-c(4,7,5,6,5,4,5,4) R29<-c(6,7,7,5,8,7,8,7) R30<-c(6,5,6,7,6,7,8,7) R31<-c(9,9,9,8,9,9,9,9) R32<-c(9,9,8,8,8,8,7,6) R33<-c(8,5,8,7,2,8,7,5) R34<-c(8,8,6,9,5,7,7,8) R35<-c(5,8,6,6,5,5,6,5) R36<-c(7,7,6,7,6,6,6,6) R37<-c(8,9,8,9,9,9,9,9) R38<-c(7,7,8,6,5,5,6,5) R39<-c(6,6,7,6,8,7,6,7) R40<-c(7,9,7,7,6,7,7,7) R41<-c(9,6,8,8,9,8,7,8) R42<-c(6,6,6,8,6,8,6,6) R43<-c(6,6,6,6,6,7,6,6) R44<-c(6,7,7,8,7,6,7,8) R45<-c(6,7,8,6,9,7,8,9) R46<-c(8,7,6,7,7,7,6,8) R47<-c(9,7,8,8,8,9,9,8) R48<-c(6,7,7,7,8,6,5,7) R49<-c(8,9,9,7,9,8,9,8) R50<-c(6,8,6,8,7,7,8,8) R51<-c(8,7,8,7,7,7,8,8) Response <- c(R1,R2,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12,R13,R14,R15,R16,R17,R18,R19,R20, R21,R22,R23,R24,R25,R26,R27,R28,R29,R30,R31,R32,R33,R34,R35,R36,R37,R38,R39,R40, R41,R42,R43,R44,R45,R46,R47,R48,R49,R50,R51) design<- data.frame(A=factor(A),B=factor(B),C=factor(C),Response) design
 * 1) Create levels for each factor
 * 1) Step 2. Add response R1to R51
 * 1) Create table of data as a data.frame

design.aov <- aov(Response~A*B*C,data=design) summary(design.aov)
 * 1) Examine ANOVA table

oldpar <- par(oma=c(0,0,3,0), mfrow=c(2,2)) plot(design.aov) par(oldpar)

library(rsm) design.rsm <- data.frame(A,B,C,Response) design.CR <- coded.data(design.rsm, x1~(A-0.175)/0.075, x2~(B-0.75)/0.25, x3~(C-0.75)/0.25) design.CR
 * 1) load RSM library
 * 1) Create data frame for RSM analysis
 * 1) Create coding variables
 * 1) view codings

design.rs1 <- rsm(Response ~ FO(x1,x2,x3)+TWI(x1,x2,x3), data=design.CR) summary (design.rs1)
 * 1) Fit first order (FO) model of main effects and 2-way interactions (TWI)

x11 par(mfrow = c(1,2)) persp(design.rs1, ~x1+x2,col = rainbow(50),contours = "colors", xlab=c("carrageenan (x1)", "guar (x2)"), at=list(x3="1"),zlab = "Response", cex.lab=1.2) contour(design.rs1, ~x1+x2,col = rainbow(10), xlab=c("carrageenan (x1)", "guar (x2)"),labcex=1.5,at=list(x3="1"))
 * 1) Plot 3D and contour plot


 * 3D Graph for Creaminess-**


 * 3D Graph for Softness-**
 * 3D Graph for Iciness-**


 * 3D Graph for overall preference-**