% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/rAMMIModel.R
\name{rAMMIModel}
\alias{rAMMIModel}
\title{Robust AMMI Model Fitting}
\usage{
rAMMIModel(
  Data,
  genotype = "gen",
  environment = "env",
  response = "Y",
  rep = NULL,
  Ncomp = 2,
  type = "AMMI"
)
}
\arguments{
\item{Data}{a dataframe with genotypes, environments, repetitions (if any)
and the phenotypic trait of interest. Other variables that will not be used
in the analysis can be included.}

\item{genotype}{column name containing genotypes. Defaults to `"gen"`.}

\item{environment}{column name containing environments. Defaults to `"env"`.}

\item{response}{column name containing the phenotypic trait of interest.
Defaults to `"Y"`.}

\item{rep}{column name containing replications. If this argument is `NULL`
(default), it is assumed that the data already contains means per genotype
in each environment. If provided, means are calculated automatically.}

\item{Ncomp}{number of principal components to retain for the interaction
part. Defaults to 2.}

\item{type}{method for fitting the AMMI model: `"AMMI"` (classical),
`"rAMMI"`, `"hAMMI"`, `"gAMMI"`, `"lAMMI"` or `"ppAMMI"` (robust variants).
Defaults to `"AMMI"`.}
}
\value{
A list of class \code{rAMMI} containing: \item{gen_scores}{Matrix of
  genotype scores (U * D).} \item{env_scores}{Matrix of environment loadings
  (V).} \item{eigenvalues}{Vector of singular values for the retained
  components.} \item{gen_labels}{Names of the genotypes.}
  \item{env_labels}{Names of the environments.} \item{Ncomp}{Number of
  principal components used.} \item{type}{The fitting method used.}
  \item{vartotal}{Total variance explained by the multiplicative terms.}
}
\description{
Fits a classical or robust Additive Main effects and
  Multiplicative Interaction (AMMI) model for genotype-by-environment data.
}
\details{
To overcome the problem of data contamination with outlying
observations, Rodrigues, Monteiro and Lourenco (2015) propose a robust AMMI
model based on the M-Huber estimator and robust SVD/PCA procedures.

The `type` argument allows choosing between several robust strategies:
\itemize{
  \item \bold{AMMI}: Classical AMMI model using Least Squares and standard SVD.
  \item \bold{rAMMI}: Uses the L1 norm instead of the L2 norm to compute a
    robust approximation to the SVD (via \pkg{pcaMethods}).
  \item \bold{hAMMI}: Uses the Hubert's approach (PcaHubert) combining
    projection-pursuit and robust covariance estimation.
  \item \bold{gAMMI}: Uses the Grid search algorithm for PCA (PcaGrid).
  \item \bold{lAMMI}: Performs PCA on the data projected onto a unit sphere (PcaLocantore).
  \item \bold{ppAMMI}: Uses projection-pursuit (PcaProj) to calculate robust
    eigenvalues and eigenvectors.
}
}
\examples{
library(agridat)
data(yan.winterwheat)

# Classical AMMI
mod_ammi <- rAMMIModel(yan.winterwheat, genotype = "gen",
                       environment = "env", response = "yield", type = "AMMI")

# Robust AMMI (using Hubert's method)
mod_rammi <- rAMMIModel(yan.winterwheat, genotype = "gen",
                        environment = "env", response = "yield", type = "hAMMI")


}
\references{
Rodrigues P.C., Monteiro A., Lourenco V.M. (2015). A robust AMMI
   model for the analysis of genotype-by-environment data. Bioinformatics 32,
   58-66.
}
