Commit 7aa29a81 authored by Dirk Eddelbuettel's avatar Dirk Eddelbuettel

Import Upstream version 1.5-2

parent 6cfd6069
Package: mgcv
Version: 1.5-1
Version: 1.5-2
Author: Simon Wood <simon.wood@r-project.org>
Maintainer: Simon Wood <simon.wood@r-project.org>
Title: GAMs with GCV/AIC/REML smoothness estimation and GAMMs by PQL
......@@ -8,10 +8,10 @@ Description: Routines for GAMs and other generalized ridge regression
UBRE/AIC. Also GAMMs by REML or PQL. Includes a gam() function.
Priority: recommended
Depends: R (>= 2.3.0)
Imports: graphics, stats
Imports: graphics, stats, nlme
Suggests: nlme (>= 3.1-64), splines
LazyLoad: yes
License: GPL (>=2)
Packaged: Tue Mar 17 10:28:50 2009; simon
Packaged: 2009-03-26 13:35:41 UTC; simon
Repository: CRAN
Date/Publication: 2009-03-17 18:17:32
Date/Publication: 2009-03-26 18:25:48
useDynLib(mgcv, .registration = TRUE, .fixes = "C_")
export(
anova.gam,coef.pdIdnot,coef.pdTens,
corMatrix.pdIdnot,cSplineDes,Dim.pdIdnot,
export(anova.gam, cSplineDes,
exclude.too.far,extract.lme.cov, extract.lme.cov2,
formXtViX, full.score, formula.gam,fixDependence,fix.family.link,
fix.family.var, fix.family.ls, gam, gam2derivative,
gam2objective,
gamm, gam.check, gam.control,gam.fit3,
gam.fit, gam.outer, gamm.setup, gamSim , influence.gam,
interpret.gam, gam.setup,
gam.fit, gam.outer, gamSim , influence.gam,
interpret.gam,
gam.side,
get.var,ldTweedie,logDet.pdIdnot,
get.var,ldTweedie,
initial.sp,logLik.gam,
magic, magic.post.proc, mgcv, mgcv.control, model.matrix.gam,
mono.con, mroot, negbin, new.name,
notExp,notExp2,notLog,notLog2,pcls,null.space.dimension,
pdConstruct.pdIdnot,pdFactor.pdIdnot,pdMatrix.pdIdnot,pdIdnot,
pdConstruct.pdTens,pdFactor.pdTens,pdMatrix.pdTens,pdTens,
pdIdnot,pdTens,
place.knots, plot.gam, print.anova.gam,
print.gam,print.summary.gam,predict.gam,
PredictMat,Predict.matrix,Predict.matrix2,
......@@ -38,20 +35,19 @@ anova.gam,coef.pdIdnot,coef.pdTens,
smooth.construct.ts.smooth.spec,
smooth.construct.ps.smooth.spec,
smooth.construct.ad.smooth.spec,
summary.gam,
solve.pdIdnot,sp.vcov,
summary.pdIdnot,summary.pdTens,te,
tensor.prod.model.matrix,tensor.prod.penalties,
summary.gam,sp.vcov,
te,tensor.prod.model.matrix,tensor.prod.penalties,
Tweedie,uniquecombs, vcov.gam, vis.gam)
importFrom(grDevices,cm.colors,gray,heat.colors,terrain.colors,topo.colors)
importFrom(graphics,axis,box,contour,hist,lines,mtext, par, persp,plot,points,polygon,strheight,strwidth,text)
importFrom(stats,.checkMFClasses,.getXlevels, as.formula, anova,anova.glmlist,coef,cooks.distance,cor,delete.response,family,fitted,formula,
importFrom(stats,.checkMFClasses,.getXlevels, as.formula, anova,anova.glmlist,coef,cooks.distance,cor,
delete.response,family,fitted,formula,
gaussian,glm,influence,lm,logLik,median,model.frame,model.matrix,model.offset,na.pass,napredict,naresid,nlm,optim,
pchisq,pf,pnorm,pt,
predict,printCoefmat ,quantile,qqnorm, reformulate,residuals,rnorm,runif,termplot,terms,terms.formula, uniroot,
var,vcov)
importFrom(nlme,Dim,corMatrix,logDet,pdConstruct,pdFactor,pdMatrix)
S3method(anova, gam)
S3method(influence, gam)
S3method(cooks.distance, gam)
......@@ -65,16 +61,40 @@ S3method(print, gam)
S3method(print, summary.gam)
S3method(residuals, gam)
S3method(summary, gam)
S3method(summary, pdTens)
S3method(summary, pdIdnot)
S3method(vcov,gam)
S3method(coef,pdTens)
S3method(pdConstruct,pdTens)
S3method(pdFactor,pdTens)
S3method(pdMatrix,pdTens)
S3method(summary,pdTens)
S3method(Dim,pdIdnot)
S3method(coef,pdIdnot)
S3method(corMatrix,pdIdnot)
S3method(logDet,pdIdnot)
S3method(pdConstruct,pdIdnot)
S3method(pdFactor,pdIdnot)
S3method(pdMatrix,pdIdnot)
S3method(solve,pdIdnot)
S3method(summary,pdIdnot)
S3method(smooth.construct,ad.smooth.spec)
S3method(smooth.construct,ps.smooth.spec)
S3method(smooth.construct,cp.smooth.spec)
S3method(smooth.construct, cc.smooth.spec)
S3method(smooth.construct, cr.smooth.spec)
S3method(smooth.construct, tp.smooth.spec)
S3method(smooth.construct, tensor.smooth.spec)
S3method(smooth.construct, cs.smooth.spec)
S3method(smooth.construct, ts.smooth.spec)
S3method(Predict.matrix,cs.smooth)
S3method(Predict.matrix,ts.smooth)
S3method(Predict.matrix,pspline.smooth)
S3method(Predict.matrix,cr.smooth)
S3method(Predict.matrix,cyclic.smooth)
S3method(Predict.matrix,tensor.smooth)
......
......@@ -1140,6 +1140,15 @@ gamm <- function(formula,random=NULL,correlation=NULL,family=gaussian(),data=lis
if (nrow(mf)<2) stop("Not enough (non-NA) data to do anything meaningful")
Terms <- attr(mf,"terms")
## summarize the *raw* input variables
## note can't use get_all_vars here -- buggy with matrices
vars <- all.vars(gp$fake.formula[-2]) ## drop response here
inp <- parse(text = paste("list(", paste(vars, collapse = ","),")"))
dl <- eval(inp, data, parent.frame())
names(dl) <- vars ## list of all variables needed
var.summary <- variable.summary(gp$pf,dl,nrow(mf)) ## summarize the input data
rm(dl) ## save space
pmf$formula <- gp$pf
pmf <- eval(pmf, parent.frame()) # pmf contains all data for parametric part
......@@ -1152,6 +1161,7 @@ gamm <- function(formula,random=NULL,correlation=NULL,family=gaussian(),data=lis
# now call gamm.setup
G<-gamm.setup(gp,pterms=pTerms,data=mf,knots=knots,parametric.only=FALSE,absorb.cons=TRUE)
G$var.summary <- var.summary
n.sr <- length(G$random) # number of random smooths (i.e. s(...,fx=FALSE,...) terms)
......@@ -1240,7 +1250,7 @@ gamm <- function(formula,random=NULL,correlation=NULL,family=gaussian(),data=lis
object<-list(model=mf,formula=formula,smooth=G$smooth,nsdf=G$nsdf,family=family,
df.null=nrow(G$X),y=G$y,terms=Terms,pterms=pTerms,xlevels=G$xlevels,
contrasts=G$contrasts,assign=G$assign,na.action=attr(mf,"na.action"),
cmX=G$cmX)
cmX=G$cmX,var.summary=G$var.summary)
# Transform parameters back to the original space....
bf<-as.numeric(ret$lme$coefficients$fixed)
br<-as.numeric(unlist(ret$lme$coefficients$random))
......
This diff is collapsed.
......@@ -5,6 +5,26 @@ ISSUES
------
[none known]
1.5-2
* Several exported functions had no usage entries in the help files.
Everything exported does now.
* `vis.gam' had a bunch of bugs (which could make it fail altogether)
as a result of trying to set default conditioning values from the gam
object model frame. `gam' and `gamm' now obtain summary statistics of
the predictor variables, stored in `var.summary' in the gam object,
which `vis.gam' now uses. As a result `vis.gam' `view' and `cond'
arguments should now contain original variable names, not model frame
term names.
* `data' argument of `gam' no longer stored in the `gam' object, by
default to save memory (can restore this --- see `gam.control').
* `summary.gam' failed under na.exclude. Fixed.
* `mroot' failed on 1 by 1 matrices, Fixed.
1.5-1
* The stability of the fitting methods had become substantially greater
......@@ -25,7 +45,7 @@ ISSUES
* The summation convention code could be *very* memory intensive for cases
in which the matrix arguments of a smooth feature many repeated values.
Code now fixed to make much more efficient use of any repeated rows in
matrix arguments. This enables muc larger signal regression problems to
matrix arguments. This enables much larger signal regression problems to
be tackled.
* Some help file fixes.
......
\name{Predict.matrix}
\alias{Predict.matrix}
\alias{Predict.matrix2}
\alias{Predict.matrix.tprs.smooth}
\alias{Predict.matrix.cr.smooth}
\alias{Predict.matrix.ts.smooth}
\alias{Predict.matrix.cs.smooth}
\alias{Predict.matrix.cyclic.smooth}
\alias{Predict.matrix.tensor.smooth}
\alias{Predict.matrix.pspline.smooth}
\alias{Predict.matrix.cpspline.smooth}
%- Also NEED an `\alias' for EACH other topic documented here.
\title{Prediction methods for smooth terms in a GAM}
\description{ Takes \code{smooth} objects produced by \code{smooth.construct} methods and obtains the matrix mapping
......
\name{Predict.matrix.cr.smooth}
\alias{Predict.matrix.cr.smooth}
\alias{Predict.matrix.cs.smooth}
\alias{Predict.matrix.cyclic.smooth}
\alias{Predict.matrix.pspline.smooth}
\alias{Predict.matrix.tensor.smooth}
\alias{Predict.matrix.tprs.smooth}
\alias{Predict.matrix.ts.smooth}
%- Also NEED an `\alias' for EACH other topic documented here.
\title{Predict matrix method functions}
\description{The various built in smooth classes for use with \code{\link{gam}} have associate \code{\link{Predict.matrix}}
method functions to enable prediction from the fitted model. }
\usage{
\method{Predict.matrix}{cr.smooth}(object, data)
\method{Predict.matrix}{cs.smooth}(object, data)
\method{Predict.matrix}{cyclic.smooth}(object, data)
\method{Predict.matrix}{pspline.smooth}(object, data)
\method{Predict.matrix}{tensor.smooth}(object, data)
\method{Predict.matrix}{tprs.smooth}(object, data)
\method{Predict.matrix}{ts.smooth}(object, data)
}
\arguments{
\item{object}{a smooth object, usually generated by a \code{\link{smooth.construct}} method having
processed a smooth specification object generated by an \code{\link{s}} or \code{\link{te}} term in a
\code{\link{gam}} formula.}
\item{data}{ A data frame containing the values of the (named) covariates at which the smooth term is to be
evaluated. Exact requirements are as for \code{\link{smooth.construct}} and \code{smooth.construct2}}.
}
\value{ A matrix mapping the coeffients for the smooth term to its values at the supplied data values.
}
\details{
The Predict matrix function is not normally called directly, but is rather used internally by \code{\link{predict.gam}} etc.
to predict from a fitted \code{\link{gam}} model. See \code{\link{Predict.matrix}} for more details, or the specific
\code{smooth.construct} pages for details on a particular smooth class.
}
\references{
Wood S.N. (2006) Generalized Additive Models: An Introduction with R. Chapman
and Hall/CRC Press.
}
\author{ Simon N. Wood \email{simon.wood@r-project.org}}
\examples{
## see smooth.construct
}
\keyword{models} \keyword{regression}%-- one or more ..
......@@ -18,7 +18,7 @@ full.score(sp,G,family,control,gamma,...)
\arguments{
\item{sp}{The logs of the smoothing parameters}
\item{G}{a list returned by \code{\link{gam.setup}}}
\item{G}{a list returned by \code{mgcv:::gam.setup}}
\item{family}{The family object for the GAM.}
......
......@@ -14,7 +14,8 @@ gam.control(irls.reg=0.0,epsilon = 1e-06, maxit = 100,
mgcv.tol=1e-7,mgcv.half=15, trace = FALSE,
rank.tol=.Machine$double.eps^0.5,
nlm=list(),optim=list(),newton=list(),
outerPIsteps=1,idLinksBases=TRUE,scalePenalty=TRUE)
outerPIsteps=1,idLinksBases=TRUE,scalePenalty=TRUE,
keepData=FALSE)
}
\arguments{
......@@ -70,6 +71,10 @@ case).}
of the penalty matrices of a smooth relative to its model matrix. This option rescales
the penalty matrices to accomodate this problem. Probably should be set to \code{FALSE}
if you are linking smoothing parameters but have set \code{idLinkBases} to \code{FALSE}.}
\item{keepData}{Should a copy of the original \code{data} argument be kept in the \code{gam}
object? Strict compatibility with class \code{glm} would keep it, but it wastes space to
do so. }
}
\details{
......
......@@ -17,6 +17,36 @@ The basic idea of estimating smoothing parameters at each step of the P-IRLS
is due to Gu (1992), and is termed `performance iteration' or `performance
oriented iteration'.
}
\usage{
gam.fit(G, start = NULL, etastart = NULL,
mustart = NULL, family = gaussian(),
control = gam.control(),gamma=1,
fixedSteps=(control$maxit+1),...)
}
\arguments{
\item{G}{An object of the type returned by \code{\link{gam}} when \code{fit=FALSE}.}
\item{start}{Initial values for the model coefficients.}
\item{etastart}{Initial values for the linear predictor.}
\item{mustart}{Initial values for the expected response.}
\item{family}{The family object, specifying the distribution and link to use.}
\item{control}{Control option list as returned by \code{\link{gam.control}}.}
\item{gamma}{Parameter which can be increased to up the cost of each effective degree of freedom in the
GCV or AIC/UBRE objective.}
\item{fixedSteps}{How many steps to take: useful when only using this routine to get rough starting values for other methods.}
\item{...}{Other arguments: ignored.}
}
\value{A list of fit information.}
\references{
......@@ -36,6 +66,6 @@ generalized additive models. J. Amer. Statist. Ass. 99:637-686
\author{ Simon N. Wood \email{simon.wood@r-project.org}}
\seealso{ \code{\link{gam.fit3}}, \code{\link{gam}}, \code{\link{mgcv}}, \code{\link{magic}}}
\seealso{ \code{\link{gam.fit3}}, \code{\link{gam}}, \code{\link{magic}}}
\keyword{models} \keyword{smooth} \keyword{regression}%-- one or more ..
......@@ -45,7 +45,7 @@ finite differencing is being used.}
\item{gamma}{ The degree of freedom inflation factor for the GCV/UBRE/AIC score.}
\item{G}{List produced by \code{\link{gam.setup}}, containing most of what's
\item{G}{List produced by \code{mgcv:::gam.setup}, containing most of what's
needed to actually fit a GAM.}
\item{...}{other arguments, typically for passing on to \code{gam.fit3} (ultimately).}
......
\name{gam.setup}
\alias{gam.setup}
%- Also NEED an `\alias' for EACH other topic documented here.
\title{Generalized additive model set up}
\description{ This is an internal function of package \code{mgcv}. It is called
by \code{gam} to obtain the design matrix and penalty matrices for a GAM
set up using penalized regression splines. This is done by calling a mixture of
R routines and compiled C code. For further information on usuage see code for \code{gam}.
}
\references{
Wood S.N. (2006) Generalized Additive Models: An Introduction with R. Chapman
and Hall/CRC Press.
}
\author{ Simon N. Wood \email{simon.wood@r-project.org}}
\seealso{ \code{\link{gam}}, \code{\link{gamm}}, \code{\link{magic}}, \code{\link{mgcv}}}
\keyword{models} \keyword{smooth} \keyword{regression}%-- one or more ..
......@@ -5,7 +5,7 @@
\description{ GAM formulae with repeated variables only correspond to
identifiable models given some side conditions. This routine works
out appropriate side conditions, based on zeroing redundant parameters.
It is called from \code{\link{gam.setup}} and is not intended to be called by users.
It is called from \code{mgcv:::gam.setup} and is not intended to be called by users.
The method identifies nested and repeated variables by their names, but
numerically evaluates which constraints need to be imposed. Constraints are always
......
......@@ -38,7 +38,9 @@ cases, not at the MLE.}
\item{converged}{indicates whether or not the iterative fitting method converged.}
\item{data}{the original supplied data argument (for class \code{"glm"} compatibility).}
\item{data}{the original supplied data argument (for class \code{"glm"} compatibility).
Only included if \code{\link{gam}} \code{control} argument element
\code{keepData} is set to \code{TRUE} (default is \code{FALSE}).}
\item{deviance}{model deviance (not penalized deviance).}
......@@ -137,14 +139,24 @@ improve conditioning.}
\item{terms}{\code{terms} object of \code{model} model frame.}
\item{var.summary}{A named list of summary information on the predictor variables. If
a parametric variable is a matrix, then the summary is a one row matrix, containing the
observed data value closest to the column median, for each matrix column. If the variable
is a factor the then summary is the modal factor level, returned as a factor, with levels
corresponding to those of the data. For numerics and matrix arguments of smooths, the summary
is the mean, nearest observed value to median and maximum, as a numeric vector. Used by
\code{\link{vis.gam}}, in particular. }
\item{Ve}{frequentist estimated covariance matrix for the parameter
estimators. Particularly useful for testing whether terms are zero. Not so
useful for CI's as smooths are usually biased.}
\item{Vp}{estimated covariance matrix for the parameters. This is a Bayesian
posterior covariance matrix that results from adopting a particular Bayesian
model of the smoothing process. Paricularly useful for creating
credible/confidence intervals.}
\item{Ve}{frequentist estimated covariance matrix for the parameter
estimators. Particularly useful for testing whether terms are zero. Not so
useful for CI's as smooths are usually biased.}
\item{weights}{final weights used in IRLS iteration.}
......
......@@ -225,7 +225,7 @@ Linked smoothing parameters and adaptive smoothing are not supported.
\code{\link{te}}, \code{\link{s}},
\code{\link{predict.gam}},
\code{\link{plot.gam}}, \code{\link{summary.gam}}, \code{\link{negbin}},
\code{\link{vis.gam}},\code{\link{pdTens}},\code{\link{gamm.setup}}
\code{\link{vis.gam}},\code{\link{pdTens}}
}
\examples{
......
\name{gamm.setup}
\alias{gamm.setup}
%- Also NEED an `\alias' for EACH other topic documented here.
\title{Generalized additive mixed model set up}
\description{ This is an internal function of package \code{mgcv}. It is called
by \code{gamm} to set up a generalized additive mixed model in a form suitable for fitting by calls to
\code{gammPQL} or \code{lme} from the \code{nlme} library. The main task is the representation
of the smooth terms as random effects. The routine first calls \code{\link{gam.setup}}, then checks that
a model estimable by \code{\link{gamm}} has been specified in the model formula, and then transforms the
problem to a form suitable for mixed model estimation.
}
\references{
Wood, S.N. (2004) Stable and efficient multiple smoothing parameter estimation for
generalized additive models. Journal of the American Statistical Association. 99:673-686
Wood, S.N. (2006a) Low rank scale invariant tensor product smooths for
generalized additive mixed models. Biometrics 62(4):1025-1036
Wood S.N. (2006b) Generalized Additive Models: An Introduction with R. Chapman
and Hall/CRC Press.
\url{http://www.maths.bath.ac.uk/~sw283/}
}
\author{ Simon N. Wood \email{simon.wood@r-project.org}}
\seealso{ \code{\link{gamm}}}
\keyword{models} \keyword{smooth} \keyword{regression}%-- one or more ..
......@@ -39,6 +39,10 @@ pdIdnot(value = numeric(0), form = NULL,
\item{data}{data frame in which to evaluate formula.}
}
\details{
The following functions are provided: \code{Dim.pdIndot}, \code{coef.pdIdnot}, \code{corMatrix.pdIdnot},
\code{logDet.pdIdnot}, \code{pdConstruct.pdIdnot}, \code{pdFactor.pdIdnot}, \code{pdMatrix.pdIdnot},
\code{solve.pdIdnot}, \code{summary.pdIdnot}. (e.g. \code{mgcv:::coef.pdIdnot} to access.)
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 initialised with estimates of the
scaled covariance matrix itself.
......
......@@ -12,8 +12,7 @@ tensor product smooths to be estimated by \code{lme} as called by \code{gamm}. T
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
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{\link{notLog2}} parameterization ensures that
the parameters are positive.
......
\name{print.gam}
\alias{print.gam}
%- Also NEED an `\alias' for EACH other topic documented here.
\title{Generalized Additive Model default print statement}
\description{ This is the default print statement for a GAM object. If you need a list of everything
that is part of a gam object see \code{\link{gam}}, or use \code{names()}. The family (including link),
model formula, and estimated degrees of freedom for each model term (plus total) are printed, as
well as the minimized GCV or UBRE/AIC score, depending on which was used.
\title{Print a Generalized Additive Model object.}
\description{ The default print method for a \code{gam} object.
}
\usage{
\method{print}{gam}(x, ...)
}
%- maybe also `usage' for other objects documented here.
\arguments{
\item{x, ...}{ fitted model objects of class \code{gam} as produced by \code{gam()}.}
}
\details{ Prints out the family, model formula, effective degrees of freedom for each smooth term, and optimized
value of the smoothness selection criterion used. See \code{\link{gamObject}} (or \code{names(x)}) for a listing
of what the object contains. \code{\link{summary.gam}} provides more detail.
}
\references{
......@@ -20,7 +30,7 @@ Chapmand and Hall, Boca Raton, Florida.
\seealso{ \code{\link{gam}},\code{\link{mgcv}}}
\seealso{ \code{\link{gam}}, \code{\link{summary.gam}}}
\keyword{models} \keyword{smooth} \keyword{regression}%-- one or more ..
......
......@@ -3,7 +3,6 @@
\alias{smooth.construct}
\alias{smooth.construct2}
\alias{user.defined.smooth}
\alias{smooth.construct.tensor.smooth.spec}
%- Also NEED an `\alias' for EACH other topic documented here.
\title{Constructor functions for smooth terms in a GAM}
\description{Smooth terms in a GAM formula are turned into smooth specification objects of
......
\name{smooth.construct.tensor.smooth.spec}
\alias{smooth.construct.tensor.smooth.spec}
%- Also NEED an `\alias' for EACH other topic documented here.
\title{Tensor product smoothing constructor}
\description{A special \code{smooth.construct} method function for creating tensor product smooths from any
combination of single penalty marginal smooths.
}
\usage{
\method{smooth.construct}{tensor.smooth.spec}(object, data, knots)
}
\arguments{
\item{object}{a smooth specification object of class \code{tensor.smooth.spec},
usually generated by a term like \code{te(x,z)} in a \code{\link{gam}} model formula}
\item{data}{a list containing just the data (including any \code{by} variable) required by this term,
with names corresponding to \code{object$term} (and \code{object$by}). The \code{by} variable
is the last element.}
\item{knots}{a list containing any knots supplied for basis setup --- in same order and with same names as \code{data}.
Can be \code{NULL}. See details for further information.}
}
\value{ An object of class \code{"tensor.smooth"}. See \code{\link{smooth.construct}},
for the elements that this object will contain.
}
\details{Tensor product smooths are smooths of several variables which allow the degree of smoothing to be different with respect
to different variables. They are useful as smooth interaction terms, as they are invariant to linear rescaling of the covariates,
which means, for example, that they are insensitive to the measurement units of the different covariates. They are also useful
whenever isotropic smoothing is inappropriate. See \code{\link{te}}, \code{\link{smooth.construct}} and
\code{\link{smooth.terms}}.
}
\references{
Wood, S.N. (2006) Low rank scale invariant tensor product smooths for
generalized additive mixed models. Biometrics 62(4):1025-1036
}
\author{ Simon N. Wood \email{simon.wood@r-project.org}}
\seealso{\code{\link{cSplineDes}}}
\examples{
## see ?gam
}
\keyword{models} \keyword{regression}%-- one or more ..
......@@ -13,14 +13,14 @@ vis.gam(x,view=NULL,cond=list(),n.grid=30,too.far=0,col=NA,
\item{view}{an array containing the names of the two main effect terms to be displayed on the
x and y dimensions of the plot. If omitted the first two suitable terms
will be used. Names must be names from
\code{names(x$model)}. i.e. \code{terms} are used, rather than \code{variables}.
will be used. Note that variables coerced to factors in the model formula won't work
as view variables, and \code{vis.gam} can not detect that this has happened when setting defaults.
}
\item{cond}{a named list of the values to use for the other predictor terms
(not in \code{view}). Terms omitted from
this list will have their values set to their mean for continuous variables,
or first level for factors. Names must correspond to \code{names(x$model)}.
(not in \code{view}). Variables omitted from this list will have the closest observed value to the median
for continuous variables, or the most commonly occuring level for factors. Parametric matrix variables have
all the entries in each column set to the observed column entry closest to the column median.
}
\item{n.grid}{The number of grid nodes in each direction used for calculating the
plotted surface.}
......@@ -68,6 +68,13 @@ default values used by \code{vis.gam}.
Based on an original idea and design by Mike Lonergan.}
\section{WARNINGS}{
The routine can not detect that a variable has been coerced to factor within a model formula,
and will therefore fail if such a variable is used as a \code{view} variable. When setting
default \code{view} variables it can not detect this situation either, which can cause failures
if the coerced variables are the first, otherwise suitable, variables encountered.
}
\seealso{
\code{\link{persp}} and \code{\link{gam}}.
}
......@@ -86,13 +93,15 @@ vis.gam(g,se=2,theta=-35) # with twice standard error surfaces
vis.gam(g, view=c("x1","x2"),cond=list(x0=0.75)) # different view
vis.gam(g, view=c("x1","x2"),cond=list(x0=.75),theta=210,phi=40,
too.far=.07)
# ..... areas where there is no data are not plotted
# contour examples....
vis.gam(g, view=c("x1","x2"),plot.type="contour",color="heat")
vis.gam(g, view=c("x1","x2"),plot.type="contour",color="terrain")
vis.gam(g, view=c("x1","x2"),plot.type="contour",color="topo")
vis.gam(g, view=c("x1","x2"),plot.type="contour",color="cm")
# ..... areas where there is no data are not plotted
par(old.par)
# Examples with factor and "by" variables
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment