\HeaderA{stam.fit}{Fit StAM Model to Training Data}{stam.fit}
\keyword{classif}{stam.fit}
\begin{Description}\relax
Using the whole expression data provided fit one StAM model 
according to the chosen shrinkage level.
\end{Description}
\begin{Usage}
\begin{verbatim}
stam.fit(cv, expression.matrix, collapse.scnodes = FALSE, 
         alpha = 0.5, delta = NULL, max.nodes = 100)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{cv}] result stam.cv on the same data, must be of class \code{stamCV}
\item[\code{expression.matrix}] holds the expression levels. It may be of
class \code{exprSet} or \code{ExpressionSet}, or a
plain numeric matrix. In the first case \code{exprs} is used to extract the 
expression levels. The matrix is expected to hold one column per sample and one row
per probeset.
\item[\code{collapse.scnodes}] if set to TRUE replace single children nodes after shrinkage
\item[\code{alpha}] root performance vs. mean redundancy weight. If set to NULL the root error
rate is used exclusively to determine the best shrinkage level. If a numeric vector 
is provided, all alternatives are computed and the user is given an interactive 
choice. Values between 0 and 1 are valid, 0 meaning exclusive weight on redundancy 
and 1 putting exclusive weight on performance.
\item[\code{delta}] overrule alpha and set shrinkage level explicitely.
\item[\code{max.nodes}] choose default shrinkage level such that no more than this number of 
nodes remain after shrinkage. 
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
In a first step \code{stam.fit} must choose a shrinkage level. In order to do so it 
uses results stored in the cv. If the user provides a shrinkage level explicitly this 
\code{delta} is used. If he specifies a single weighting factor \code{alpha} the 
corresponding weighted score is used to determine the best shrinkage level. If 
\code{alpha} is set to a vector of values, the corresponding scores are computed and a 
default \code{delta} is suggested using the median value of the \code{alphas}. If this 
shrinkage level leads to more than \code{max.nodes} nodes remaining the shrinkage level
is increase until no more than \code{max.nodes} remain after shrinkage.

Using the thus determined shrinkage level a weighting of nodes is computed using the 
leaf node results from \code{cv}. Thereby, the whole dataset supplied is used.
\end{Details}
\begin{Value}
An object of class stamFit is returned. You may use the print and plot methods 
to further investigate the returned value.
\end{Value}
\begin{Author}\relax
Claudio Lottaz
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{stam.cv}{stam.cv}}, \code{\LinkA{stamFit-class}{stamFit.Rdash.class}}, \code{\LinkA{plot.stamFit}{plot.stamFit}}, 
\code{\LinkA{stam.graph.plot}{stam.graph.plot}}, \code{\LinkA{stam.writeHTML}{stam.writeHTML}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
## Not run: 
# prepare data
library(golubEsets)
data(Golub_Merge)

# load and prepare some data
golubTrain <- Golub_Merge[,1:38]
data(golubTrain.cv)

# compute fit
golubTrain.fit <- stam.fit(golubTrain.cv, golubTrain, alpha=seq(0, 1, 0.1))

# investigate
print(golubTrain.fit)
plot(golubTrain.fit)
## End(Not run)

# show clickable web-page
## Not run: 
map <- stam.graph.plot(golubTrain.fit, outfile="golubTrain")
cat("<HTML><BODY><MAP NAME='graph_map'>", map, "</MAP>",
    "<IMG SRC='golubTrain_graph_plot.png' USEMAP='#graph_map'></BODY></HTML>\n", 
    file="graph_plot.html")
browseURL(paste("file://", getwd(), "/graph_plot.html", sep=""))
## End(Not run)\end{ExampleCode}
\end{Examples}

