Skip to content

Commit

Permalink
version 1.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jsl5-code authored and gaborcsardi committed Feb 13, 2014
1 parent 8c159a6 commit 5b1c9fa
Show file tree
Hide file tree
Showing 19 changed files with 544 additions and 123 deletions.
19 changes: 9 additions & 10 deletions DESCRIPTION
@@ -1,19 +1,18 @@
Package: mixexp
Type: Package
Title: Design and analysis of mixture experiments
Version: 1.0-5
Date: 2011-5-24
Author: John Lawson <lawson@byu.edu>
Version: 1.1.1
Date: 2014-2-13
Author: John Lawson <lawson@byu.edu> and Cameron Willden <ccwillden@gmail.com>, with contributions from Greg Piepel
Maintainer: John Lawson <lawson@byu.edu>
Description: This package contains functions for creating designs for
mixture experiments, making ternary contour plots, and making
mixture effect plots.
Description: This package contains functions for creating designs for mixture experiments, making ternary contour plots, and making mixture effect plots.
License: GPL-2
Depends: gdata, lattice, grid
LazyLoad: yes
Repository: CRAN
Repository/R-Forge/Project: daewr
Repository/R-Forge/Revision: 51
Repository/R-Forge/DateTimeStamp: 2012-09-20 21:06:17
Date/Publication: 2012-09-22 04:52:53
Packaged: 2012-09-20 22:19:45 UTC; rforge
Repository/R-Forge/Revision: 75
Repository/R-Forge/DateTimeStamp: 2014-03-26 20:51:57
Date/Publication: 2014-03-27 15:39:47
Packaged: 2014-03-26 23:16:13 UTC; rforge
NeedsCompilation: yes
31 changes: 17 additions & 14 deletions MD5
@@ -1,29 +1,32 @@
a2ded1cac627c8e3b3133046c0f88e05 *DESCRIPTION
591d5d747a2a80697ac67675135e6144 *NAMESPACE
8566a5151df8dff7fee7650faaaf107e *R/DesignPoints.R
84a3fc3dfbfff49a7f116b2230856ea7 *R/Effplot.R
7a37e2ad35d717cdf35c875363999f29 *DESCRIPTION
70f353bbcf9f063d80b8ccd215315a86 *NAMESPACE
3ec52fe3e08a373b966eced0bbbfc92b *R/DesignPoints.R
499449d4931740e97e004e96d4ba7762 *R/Effplot.R
3ad3c71d8af463b0f60927c48b6e748a *R/Eflags.R
e5923423320694b42f114b885f71a72e *R/Fillv.R
48f799ab1362785579b52bec6df7472a *R/MixturePlot.R
7bc2189d5de6273eb0e1d398370af7f5 *R/MixturePlot.R
5249a4ad3378db1f384f2bd9e803b688 *R/ModelPlot.R
7c14430661e5a923dc39735d2cfa28a6 *R/Nrows.R
1d1e41d2404b692fcb2a12609635db5a *R/SCD.R
85308cc0960ee332036cfdc426f161f2 *R/SLD.R
e70968351adb60ab99a8571bb4c0a18a *R/Vertcen.R
289636bd25e5d50e2e799a5e19c50429 *R/Xvert.R
fef7c9f2b5b951c9cd087a7e6ead8bea *R/Xvert.R
030481ace7350906616dd1664f94e931 *R/crvtave.R
d41d8cd98f00b204e9800998ecf8427e *TestDocument.txt
a94d34945550adbaf299dd7551511f26 *data/conmx.rda
1630883d19a5f740451a348f09a1a034 *man/DesignPoints.Rd
4b80bd7c4c827e7e4759cf8a11250d40 *man/Effplot.Rd
75a1e03e9d65616f743212e6fe8f3058 *data/SneeMq.rda
327018175ab5d8af478faf02b6be957e *data/conmx.rda
690bdc5266b0bd9a5633deeb7196a285 *man/DesignPoints.Rd
1a9750a4011da10ebb6b58ed6cccdcd0 *man/Effplot.Rd
930d16c38933f69720e0910e9f050c86 *man/Eflags.Rd
c752862189a65e7cb34a3bb13f6db8b3 *man/Fillv.Rd
1bfa8ec1e5b1c31d5653a59806055d01 *man/MixturePlot.Rd
2389c92a2cd76add93a308c993e8fc00 *man/MixturePlot.Rd
573176afe5ac0b52007df7d62a115c29 *man/ModelPlot.Rd
71f8733f0730ff37a61618cefb0a7871 *man/Nrows.Rd
93752cb0de5f573cc8aab1c4d3eca31c *man/SCD.Rd
7d54d42a54f3d4c616a078c2a831d874 *man/SLD.Rd
ef120358472acaeef56830a2e77c4003 *man/SneeMq.Rd
870ccf1614d78de0662d33ea11262dba *man/Vertcen.Rd
844eb6fbf7936e8baba22dcdff5071b0 *man/Xvert.Rd
2c3a45267dc0c55a72a106322f9da309 *man/Xvert.Rd
8d4f983e4fe013565d31f5fd4575152d *man/conmx.Rd
0a9d64b87b580a549215010903aa65f9 *man/crvtave.Rd
3ca50c699a506bb55464e385a2c96cd5 *man/mixexp-package.Rd
ff941e13a03d5a0ba297a7cb17124fbf *src/cnvrt.f
879ff06b9f0110386f01cd9806ce3b2c *man/mixexp-package.Rd
4adf6166def03e0720733fa47d8e82c0 *src/cnvrt.f
3 changes: 2 additions & 1 deletion NAMESPACE
@@ -1,12 +1,13 @@
useDynLib(mixexp)

import(gdata, lattice, grid)
export(crvtave,
Eflags,
Nrows,
Vertcen,
SCD,
SLD,
MixturePlot,
ModelPlot,
DesignPoints,
Xvert,
Effplot,
Expand Down
99 changes: 46 additions & 53 deletions R/DesignPoints.R
@@ -1,53 +1,46 @@
DesignPoints = function(des=NULL,x=NULL,y=NULL,z=NULL,x1lower=0,x1upper=0,
x2lower=0,x2upper=0,x3lower=0,x3upper=0)
{

# Checks to See if there are design points

check1<-is.null(des)
check2<-is.null(x)

#check wheter to print design points
if (check1 & check2) {
design=FALSE } else {design=TRUE }


if (check2) {
# if not make dummy design points to send to MixturePlot function
x<-c(0,0,1)
y<-c(0,1,0)
z<-c(1,0,0)
}
if (check1) {
}else {

x<-des$x3
y<-des$x2
z<-des$x1
}

# Makes dummy response points
w<-runif(length(x))


# Checks to see if there are constraints

Check<-x1lower+x1upper+x2lower+x2upper+x3lower+x3upper
if (Check==0) {
cls<-c(rep(0,6))
constraints=FALSE
} else {
cls <-c(rep(0,6))
cls[1]<-x1lower
cls[2]<-x1upper
cls[3]<-x2lower
cls[4]<-x2upper
cls[5]<-x3lower
cls[6]<-x3upper
constraints=TRUE
}

MixturePlot(x,y,z,w,x3lab="Fraction x3",
x2lab="Fraction x2", x1lab="Fraction x1", corner.labs=c("x3","x2","x1"),lims=cls,
constrts=constraints,contrs=FALSE,cols=FALSE, mod=1,n.breaks=9,despts=design)
}
DesignPoints = function (des = NULL, x = NULL, y = NULL, z = NULL, x1lower = 0,
x1upper = 0, x2lower = 0, x2upper = 0, x3lower = 0, x3upper = 0,
axislabs=c("Fraction x1","Fraction x2","Fraction x3"),
cornerlabs = c("x1","x2","x3")){
check1 <- is.null(des)
check2 <- is.null(x)
if (check1 & check2) {
design = FALSE
}
else {
design = TRUE
}
if (check2) {
x <- c(0, 0, 1)
y <- c(0, 1, 0)
z <- c(1, 0, 0)
}
if (check1) {
}
else {
x <- des$x3
y <- des$x2
z <- des$x1
}
w <- runif(length(x))
Check <- x1lower + x1upper + x2lower + x2upper + x3lower +
x3upper
if (Check == 0) {
cls <- c(rep(0, 6))
constraints = FALSE
}
else {
cls <- c(rep(0, 6))
cls[1] <- x1lower
cls[2] <- x1upper
cls[3] <- x2lower
cls[4] <- x2upper
cls[5] <- x3lower
cls[6] <- x3upper
constraints = TRUE
}
MixturePlot(x, y, z, w, x3lab = axislabs[3], x2lab = axislabs[2],
x1lab = axislabs[1], corner.labs = cornerlabs,
lims = cls, constrts = constraints, contrs = FALSE, cols = FALSE,
mod = 1, n.breaks = 9, despts = design)
}
62 changes: 38 additions & 24 deletions R/Effplot.R
@@ -1,12 +1,20 @@
Effplot = function(des,mod=1,dir=1)
Effplot = function(des=NULL,nfac=3,mod=1,dir=1,ufunc=NULL,dimensions = list(NULL),
x1=c(0,1),x2=c(0,1),x3=c(0,1),x4=c(0,1),x5=c(0,1),x6=c(0,1),x7=c(0,1),x8=c(0,1),x9=c(0,1),x10=c(0,1),x11=c(0,1),x12=c(0,1))
{
# glimit is the resolution for the plot
glimit<-25

# get the number of factors from the design
# check for valid mod
if(mod < 1 | mod > 4)
stop("mod must be a number between 1 and 4")
if(mod==4 & is.null(ufunc))
stop("When mod=4, you must supply the user model as an lm function through ufunc=object")

# get the number of factors from the design
if(! is.null(des)) {
dd<-dim(des)
nfac<-dd[2]-1
}

# checks for valid number of factors
if (nfac<2 | nfac>12)
Expand All @@ -17,9 +25,8 @@ if (nfac<3 & mod>3)
stop("Special cubic model requires at least 3 factors")


# set up lower and upper bounds for factors
x1=c(0,1); x2=c(0,1); x3=c(0,1); x4=c(0,1); x5=c(0,1); x6=c(0,1)
x7=c(0,1); x8=c(0,1); x9=c(0,1); x10=c(0,1); x11=c(0,1); x12=c(0,1)
# set up lower and upper bounds for factors if design is in des
if(! is.null(des)) {
if (nfac>=1) {
x1[1]<-min(des[,1])
x1[2]<-max(des[,1])
Expand Down Expand Up @@ -120,12 +127,16 @@ modl<-lm(y~x1+x2+x3+x4+x5+x6+x1*x2+x1*x3+x1*x4+x1*x5+x1*x6+x2*x3+x2*x4+x2*x5+x2*
Beta<-modl$coeff
}
}
if (mod==4) {
modl<-lm(y~.-1,data=des)
Beta<-ufunc$coeff
}



## end of calculations involving the data frame des
}

# prints back beta
#cat("beta=", ,"\n")


# get constraint matrix for crvtave
Expand All @@ -136,7 +147,7 @@ v<-c(-x1[1],x1[2])
}


library(gdata)

Ip<-diag(nfac)
In<--1*Ip
conmx<-interleave(Ip,In)
Expand All @@ -161,8 +172,6 @@ pcent<-c(rep(0,times=nfac))
for (i in 1:nfac) {
pcent[i]<-(cent[i]-ck[1,i])/Den
}
#prints centroid in pseudo component space
#cat("pcent=",pcent,"\n")

# create grid
grid<-glimit:1
Expand All @@ -173,7 +182,7 @@ Xgrid<-array(rep(0,times=glimit*nfac*nfac))
dim(Xgrid)<-c(nfac,glimit,nfac)


# gets direction for Cox method
# gets direction for Piepel method

if (dir==1) {

Expand Down Expand Up @@ -279,13 +288,13 @@ if (ifac<nfac) {
}
}

mTitle<-"Effect Plot (Cox direction)"
mTitle<-"Effect Plot (Piepel direction)"
}
# end of code for Cox direction coordinates
# end of code for Piepel direction coordinates



# get direction for Piepel method
# get direction for Cox method

if (dir==2) {

Expand Down Expand Up @@ -376,7 +385,6 @@ if (ifac<nfac){

# create bottom half of xi grid
grid<--1*(1:glimit)
#Delta<-(pcent[ifac]-ck[1,ifac])/glimit
Delta<-(pcent[ifac]-0)/glimit

w<-Delta*grid+pcent[ifac]
Expand Down Expand Up @@ -405,12 +413,12 @@ for (i in 1:nfac) {
}


mTitle<-"Effect Plot (Pieple direction)"
mTitle<-"Effect Plot (Cox direction)"
}



# end of code for Pieple direction
# end of code for Cox direction

# set up the plot matrix
PX<-array(rep(0,times=nfac*2*(2*glimit+1)))
Expand All @@ -421,7 +429,7 @@ dim(PX)<-c((2*glimit+1),2*nfac)
# get predicted values
for (ifac in 1:nfac) {
Xtemp<-Xgrid[ifac, , ]
if (mod==1) {
if (mod==1 | mod==4) {
Xmat<-Xtemp
}
if (mod==2) {
Expand Down Expand Up @@ -458,8 +466,18 @@ Xmat<-cbind(Xtemp,Xtemp[,1]*Xtemp[,2],Xtemp[,1]*Xtemp[,3],Xtemp[,1]*Xtemp[,4],Xt
}
}


if(mod<=3) {
yhX<-Xmat%*%Beta
}

if(mod==4) {
Xmatdf<-data.frame(Xmat)
colnames(Xmatdf)<-dimensions
yhU<-predict(ufunc,Xmatdf)
yhX<-yhU
}




# get deviations from centroid
Expand Down Expand Up @@ -507,19 +525,15 @@ yaxismin<-min(ymin)
for (i in 1:nfac) {
xvec<-PX[(sel[,i]==1),(2*i-1)]
yvec<-PX[(sel[,i]==1),(2*i)]
#print(xvec)
#print(yvec)
lines(xvec,yvec,lty=i,col=i)
text(xvec[length(xvec)],yvec[length(yvec)],plabs[i])
text(xvec[1],yvec[1],plabs[i])

}

#print(dim(Xgrid))
#print(dim(Temp))
#print(Temp)

return(PX)
}
##############################################################


6 changes: 3 additions & 3 deletions R/MixturePlot.R
Expand Up @@ -48,10 +48,10 @@ z<-des$x1
w<-des$y
}


base = high = NULL
#Depends on the following libraries
library(lattice)
library(grid)
#library(lattice)
#library(grid)
######################
## Creation of Grid ##
######################
Expand Down

0 comments on commit 5b1c9fa

Please sign in to comment.