Learn R Programming

gnm (version 1.1-5)

wheat: Wheat Yields from Mexican Field Trials

Description

Data from a 10-year experiment at the CIMMYT experimental station located in the Yaqui Valley near Ciudad Obregon, Sonora, Mexico --- factorial design using 24 treatments in all. In each of the 10 years the experiment was arranged in a randomized complete block design with three replicates.

Usage

wheat

Arguments

Format

A data frame with 240 observations on the following 33 variables.

yield

numeric, mean yield in kg/ha for 3 replicates

year

a factor with levels 1988:1997

tillage

a factor with levels T t

summerCrop

a factor with levels S s

manure

a factor with levels M m

N

a factor with levels 0 N n

MTD

numeric, mean max temp sheltered (deg C) in December

MTJ

same for January

MTF

same for February

MTM

same for March

MTA

same for April

mTD

numeric, mean min temp sheltered (deg C) in December

mTJ

same for January

mTF

same for February

mTM

same for March

mTA

same for April

mTUD

numeric, mean min temp unsheltered (deg C)in December

mTUJ

same for January

mTUF

same for February

mTUM

same for March

mTUA

same for April

PRD

numeric, total precipitation (mm) in December

PRJ

same for January

PRF

same for February

PRM

same for March

SHD

numeric, mean sun hours in December

SHJ

same for January

SHF

same for February

EVD

numeric, total evaporation (mm) in December

EVJ

same for January

EVF

same for February

EVM

same for March

EVA

same for April

Examples

Run this code
set.seed(1)

##  Scale yields to reproduce analyses reported in Vargas et al (2001)
yield.scaled <- wheat$yield * sqrt(3/1000)

##  Reproduce (up to error caused by rounding) Table 1 of Vargas et al (2001)
aov(yield.scaled ~ year*tillage*summerCrop*manure*N, data = wheat)
treatment <- interaction(wheat$tillage, wheat$summerCrop, wheat$manure,
                         wheat$N, sep = "")
mainEffects <- lm(yield.scaled ~ year + treatment, data = wheat)
svdStart <- residSVD(mainEffects, year, treatment, 3)
bilinear1 <- update(asGnm(mainEffects), . ~ . + 
                    Mult(year, treatment),
                    start = c(coef(mainEffects), svdStart[,1]))
bilinear2 <- update(bilinear1, . ~ . + 
                    Mult(year, treatment, inst = 2),
                    start = c(coef(bilinear1), svdStart[,2]))
bilinear3 <- update(bilinear2, . ~ . + 
                    Mult(year, treatment, inst = 3),
                    start = c(coef(bilinear2), svdStart[,3]))
anova(mainEffects, bilinear1, bilinear2, bilinear3)

##  Examine the extent to which, say, mTF explains the first bilinear term
bilinear1mTF <- gnm(yield.scaled ~ year + treatment + Mult(1 + mTF, treatment),
                    family = gaussian, data = wheat)
anova(mainEffects, bilinear1mTF, bilinear1)

##  How to get the standard SVD representation of an AMMI-n model
##
##  We'll work with the AMMI-2 model, which here is called "bilinear2"
##
##  First, extract the contributions of the 5 terms in the model:
##
wheat.terms <- termPredictors(bilinear2)
##
##  That's a matrix, whose 4th and 5th columns are the interaction terms
##
##  Combine those two interaction terms, to get the total estimated
##  interaction effect:
##
wheat.interaction <- wheat.terms[, 4] + wheat.terms[, 5]
##
##  That's a vector, so we need to re-shape it as a 24 by 10 matrix
##  ready for calculating the SVD:
##
wheat.interaction <- matrix(wheat.interaction, 24, 10)
##
##  Now we can compute the SVD:
##
wheat.interaction.SVD <- svd(wheat.interaction)
##
##  Only the first two singular values are nonzero, as expected
##  (since this is an AMMI-2 model, the interaction has rank 2)
##
##  So the result object can be simplified by re-calculating the SVD with
##  just two dimensions:
##
wheat.interaction.SVD <- svd(wheat.interaction, nu = 2, nv = 2)

Run the code above in your browser using DataLab