# --------------------------------------
# Example 1: 3x3 factorial design
# --------------------------------------
# The first column is filled with a sequence of NA values.
# data(fmdata1)
# fmdata1
# For a two factors design, the matrix data contains the one-way
# sub-design and the two-ways full factorial design observed data.
# Pay attention to the columns order:
# sub-design: A1, A2, A3, B1, B2, B3
# full factorial: A1B1, A1B2, A1B3, A2B1, A2B2, A2B3, A3B1, A3B2, A3B3
# Start the R-Average procedure:
# fm1 <- rav(fmdata1, lev=c(3,3))
# fm1 # print the best model selected
# summary(fm1) # print the fitted models
# To insert the factor names:
# fact.names <- c("Name of factor A", "Name of factor B")
# fm1 <- rav(fmdata1, lev=c(3,3), names = fact.names)
# To insert a output title:
# out.title <- c("Put your title here")
# fm1 <- rav(fmdata1, lev=c(3,3), title=out.title)
# To supervise the information criterion work flow:
# fm1 <- rav(fmdata1, lev=c(3,3), verbose=TRUE)
# To increase the number of iterations of the minimization routine:
# fm1 <- rav(fmdata1, lev=c(3,3), control=list(maxit=5000))
# To set a fixed value for weights:
# wfix <- list(A=c(NA,0.4,0.4), B=c(NA,NA,NA))
# wfix
# Warning: NA specify no-fixed weights
# fm1.fix <- rav(fmdata1, lev=c(3,3), w.fixed=wfix)
# Otherwise, it's possible to call a GUI:
# fm1.fix <- rav(fmdata1, lev=c(3,3), w.fixed=TRUE)
# rav can work without sub-designs. If any sub-design is not available,
# the corresponding column must be coded with NA values. For example:
# fmdata1[,1:3] <- NA
# fmdata1
# fmdata1 # the A sub-design is empty
# fm1.bis <- rav(fmdata1, lev=c(3,3), title="Sub-design A is empty")
# Using a subset of data:
# data(pasta)
# pasta
# Analyzing "subj.04" only:
# fact.names <- c("Price","Packaging")
# fm.subj04 <- rav(pasta, subset="subj.04", lev=c(3,3), names=fact.names)
# --------------------------------------
# Example 2: 3x5 factorial design
# --------------------------------------
# data(fmdata2)
# (Pay attention to the columns order)
# fmdata2
# fm2 <- rav(fmdata2, lev=c(3,5))
# Removing all the one-way sub-design:
# fmdata2[,1:8] <- NA
# fm2.bis <- rav(fmdata2, lev=c(3,5))
# --------------------------------------
# Example 3: 3x2x3 factorial design
# --------------------------------------
# data(fmdata3)
# (Pay attention to the columns order)
# fm3 <- rav(fmdata3, lev=c(3,2,3))
# Removing all the one-way design and the AxC sub-design:
# fmdata3[,1:8] <- NA # one-way designs
# fmdata3[,15:23] <- NA # AxC design
# fm3 <- rav(fmdata3, lev=c(3,2,3))Run the code above in your browser using DataLab