\HeaderA{pdTens}{Functions implementing a pdMat class for tensor product smooths}{pdTens}
\aliasA{coef.pdTens}{pdTens}{coef.pdTens}
\aliasA{pdConstruct.pdTens}{pdTens}{pdConstruct.pdTens}
\aliasA{pdFactor.pdTens}{pdTens}{pdFactor.pdTens}
\aliasA{pdMatrix.pdTens}{pdTens}{pdMatrix.pdTens}
\aliasA{summary.pdTens}{pdTens}{summary.pdTens}
\keyword{models}{pdTens}
\keyword{smooth}{pdTens}
\keyword{regression}{pdTens}
\begin{Description}\relax
This set of functions implements an \code{nlme} library \code{pdMat} class to allow
tensor product smooths to be estimated by \code{lme} as called by \code{gamm}. Tensor product smooths
have a penalty matrix made up of a weighted sum of penalty matrices, where the weights are the smoothing 
parameters. In the mixed model formulation the penalty matrix is the inverse of the covariance matrix for 
the random effects of a term, and the smoothing parameters (times a half) are variance parameters to be estimated. 
It's not 
possible to transform the problem to make the required random effects covariance matrix look like one of the standard 
\code{pdMat} classes: hence the need for the \code{pdTens} class. A \code{\LinkA{notLog2}{notLog2}} parameterization ensures that 
the parameters are positive. 

These functions (\code{pdTens}, \code{pdConstruct.pdTens},
\code{pdFactor.pdTens}, \code{pdMatrix.pdTens}, \code{coef.pdTens} and \code{summary.pdTens})
would not normally be called directly.
\end{Description}
\begin{Usage}
\begin{verbatim}
pdTens(value = numeric(0), form = NULL, 
       nam = NULL, data = sys.frame(sys.parent()))
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{value}] Initialization values for parameters. Not normally used.
\item[\code{form}] A one sided formula specifying the random effects structure. The formula should have
an attribute \code{S} which is a list of the penalty matrices the weighted sum of which gives the inverse of the 
covariance matrix for these random effects.
\item[\code{nam}] a names argument, not normally used with this class.
\item[\code{data}] data frame in which to evaluate formula.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
If using this class directly note that it is worthwhile scaling the
\code{S} matrices to be of `moderate size', for example by dividing each
matrix by its largest singular value: this avoids problems with \code{lme}
defaults (\code{\\ref\{smooth.construct.tensor.smooth.spec\}} does this automatically).  

This appears to be the minimum set of functions required to implement a new \code{pdMat} class. 

Note that while the \code{pdFactor} and \code{pdMatrix} functions return the inverse of the scaled random 
effect covariance matrix or its factor, the \code{pdConstruct} function is
sometimes initialised with estimates of the scaled covariance matrix, and
sometimes intialized with its inverse.
\end{Details}
\begin{Value}
A class \code{pdTens} object, or its coefficients or the matrix it
represents or the factor of 
that matrix. \code{pdFactor} returns the factor as a vector (packed
column-wise) (\code{pdMatrix} always returns a matrix).
\end{Value}
\begin{Author}\relax
Simon N. Wood \email{simon.wood@r-project.org}
\end{Author}
\begin{References}\relax
Pinheiro J.C. and Bates, D.M. (2000) Mixed effects Models in S and S-PLUS. Springer

The \code{nlme} source code.

\url{http://www.stats.gla.ac.uk/~simon/}
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{te}{te}}  \code{\LinkA{gamm}{gamm}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
# see gamm
\end{ExampleCode}
\end{Examples}

