Commit 73ecf595 authored by Dirk Eddelbuettel's avatar Dirk Eddelbuettel

Import Debian changes 1.8-10-1

mgcv (1.8-10-1) unstable; urgency=low

  * New upstream release
  
  * debian/control: Set Build-Depends: to current R version 
parents 59a47911 9aadc879
** denotes quite substantial/important changes
*** denotes really big changes
1.8-10
** 'multinom' family implemented for multinomial logistic regression.
* predict.bam now defaults to using efficient discrete prediction methods
for models fit using discrete covariate methods (bam(...,discrete=TRUE)).
* with bam(...,discrete=TRUE) terms like s(a,b,bs="re") had wrong p-value
computation applied, as a result of being treated as tensor product terms.
Fixed.
* minor tweak to soap basis setup to avoid rounding error leading to 'approx'
occasionally producing NA's with fixed boundaries.
* misc.c:rwMatrix made thread safe (had been using R_chk_calloc, which isn't).
* some upgrading for 64bit addressing.
* uniquecombs now preserves contrasts on factors.
* variable summary tweak so that 1 column matrices in parametric model are
treated as regular numeric variables.
1.8-9
* C level fix in bam(...,discrete=TRUE) code. Some memory was mistakenly
......@@ -119,7 +142,7 @@
* New German translation thanks to Detlef Steuer.
* plot.gam now silently returns a list of plotting data, to help advanced
users (Fabian Scheipl) to produce custimized plot.
users (Fabian Scheipl) to produce customized plot.
* bam can now set up an object suitable for fitting, but not actually do
the fit, following a suggestion by Fabian Scheipl. See arguments 'fit'
......
Package: mgcv
Version: 1.8-9
Version: 1.8-10
Author: Simon Wood <simon.wood@r-project.org>
Maintainer: Simon Wood <simon.wood@r-project.org>
Title: Mixed GAM Computation Vehicle with GCV/AIC/REML Smoothness
......@@ -16,6 +16,6 @@ LazyLoad: yes
ByteCompile: yes
License: GPL (>= 2)
NeedsCompilation: yes
Packaged: 2015-10-30 09:42:04 UTC; sw283
Packaged: 2015-12-12 07:33:02 UTC; sw283
Repository: CRAN
Date/Publication: 2015-10-30 10:53:27
Date/Publication: 2015-12-12 18:49:20
This diff is collapsed.
......@@ -15,7 +15,7 @@ export(anova.gam, bam, bam.update, betar, cox.ph,concurvity, cSplineDes,
ldTweedie,
logLik.gam,ls.size,
magic, magic.post.proc, model.matrix.gam,
mono.con, mroot, mvn, nb, negbin, new.name,
mono.con, mroot, multinom, mvn, nb, negbin, new.name,
notExp,notExp2,notLog,notLog2,pcls,null.space.dimension,
ocat,
pen.edf,pdIdnot,pdTens,
......@@ -73,7 +73,7 @@ importFrom(graphics,abline,axis,axTicks,box,contour,hist,image,lines,
polygon,rect,strheight,strwidth,text,title)
importFrom(stats,.checkMFClasses,.getXlevels,anova,approx,as.formula,
binomial,coef,cooks.distance,cor,cov,
binomial,coef,contrasts,"contrasts<-",cooks.distance,cor,cov,
delete.response,dbeta,dgamma,dnorm,dpois,fitted,formula,gaussian,glm,
influence,logLik,lm,mad,
make.link,median,model.frame,model.offset,model.matrix,nlm,
......
This diff is collapsed.
......@@ -207,7 +207,7 @@ ocat <- function(theta=NULL,link="identity",R=NULL) {
## a1 <- f1^2 - f1;a0 <- f0^2 - f0;
a <- a1 - a0
al1al0 <- (al1-al0)/2; al0al1 <- (al0-al1)/2
#!al1al0 <- (al1-al0)/2; #! al0al1 <- (al0-al1)/2
##g1 <- F(al1al0);g0 <- F(al0al1)
##A <- pmax(g1 - g0,.Machine$double.eps)
#! A <- Fdiff(al0al1,al1al0)
......
This diff is collapsed.
......@@ -771,7 +771,7 @@ gam.setup.list <- function(formula,pterms,
pof <- ncol(G$X) ## counts the model matrix columns produced so far
pstart <- rep(0,d) ## indexes where parameteric columns start in each formula block of X
pstart[1] <- 1
for (i in 2:d) {
if (d>1) for (i in 2:d) {
if (is.null(formula[[i]]$response)) { ## keep gam.setup happy
formula[[i]]$response <- formula$response
mv.response <- FALSE
......@@ -1889,7 +1889,7 @@ variable.summary <- function(pf,dl,n) {
if (v.n>0) for (i in 1:v.n) {
if (v.name[i]%in%p.name) para <- TRUE else para <- FALSE ## is variable in the parametric part?
if (para&&is.matrix(dl[[v.name[i]]])) { ## parametric matrix --- a special case
if (para&&is.matrix(dl[[v.name[i]]])&&ncol(dl[[v.name[i]]])>1) { ## parametric matrix --- a special case
x <- matrix(apply(dl[[v.name[i]]],2,quantile,probs=0.5,type=3,na.rm=TRUE),1,ncol(dl[[v.name[i]]])) ## nearest to median entries
} else { ## anything else
x <- dl[[v.name[i]]]
......@@ -2524,6 +2524,7 @@ predict.gam <- function(object,newdata,type="link",se.fit=FALSE,terms=NULL,exclu
# == "terms" - for individual terms on scale of linear predictor
# == "iterms" - exactly as "terms" except that se's include uncertainty about mean
# == "lpmatrix" - for matrix mapping parameters to l.p. - has "lpi" attribute if multiple l.p.s
# == "newdata" - returns newdata after pre-processing
# Steps are:
# 1. Set newdata to object$model if no newdata supplied
# 2. split up newdata into manageable blocks if too large
......@@ -2549,12 +2550,16 @@ predict.gam <- function(object,newdata,type="link",se.fit=FALSE,terms=NULL,exclu
# dropping
# if GC is TRUE then gc() is called after each block is processed
## para acts by adding all smooths to the exclude list.
## it also causes any lp matrix to be smaller than it would otherwise have been.
#if (para) exclude <- c(exclude,unlist(lapply(object$smooth,function(x) x$label)))
if (unconditional) {
if (is.null(object$Vc)) warning("Smoothness uncertainty corrected covariance not available") else
object$Vp <- object$Vc
}
if (type!="link"&&type!="terms"&&type!="iterms"&&type!="response"&&type!="lpmatrix") {
if (type!="link"&&type!="terms"&&type!="iterms"&&type!="response"&&type!="lpmatrix"&&type!="newdata") {
warning("Unknown type, reset to terms.")
type<-"terms"
}
......@@ -2655,6 +2660,7 @@ predict.gam <- function(object,newdata,type="link",se.fit=FALSE,terms=NULL,exclu
}
newdata[[i]] <- factor(newdata[[i]],levels=levm) # set prediction levels to fit levels
}
if (type=="newdata") return(newdata)
# split prediction into blocks, to avoid running out of memory
if (length(newdata)==1) newdata[[2]] <- newdata[[1]] # avoids data frame losing its labels and dimensions below!
......@@ -2702,9 +2708,9 @@ predict.gam <- function(object,newdata,type="link",se.fit=FALSE,terms=NULL,exclu
} else { ## "response" or "link"
## get number of linear predictors, in case it's more than 1...
if (is.list(object$formula)) {
nf <- length(object$formula) ## number of model formulae
# nf <- length(object$formula) ## number of model formulae
nlp <- length(lpi) ## number of linear predictors
} else nlp <- nf <- 1
} else nlp <- 1 ## nf <- 1
# nlp <- if (is.list(object$formula)) length(object$formula) else 1
fit <- if (nlp>1) matrix(0,np,nlp) else array(0,np)
if (se.fit) se <- fit
......@@ -2888,6 +2894,9 @@ predict.gam <- function(object,newdata,type="link",se.fit=FALSE,terms=NULL,exclu
if (is.matrix(fit)&&!is.matrix(ffv[[1]])) {
fit <- fit[,1]; if (se.fit) se <- se[,1]
}
if (is.matrix(ffv[[1]])&&(!is.matrix(fit)||ncol(ffv[[1]])!=ncol(fit))) {
fit <- matrix(0,np,ncol(ffv[[1]])); if (se.fit) se <- fit
}
if (is.matrix(fit)) {
fit[start:stop,] <- ffv[[1]]
if (se.fit) se[start:stop,] <- ffv[[2]]
......@@ -2961,7 +2970,10 @@ predict.gam <- function(object,newdata,type="link",se.fit=FALSE,terms=NULL,exclu
colnames(H) <- names(object$coefficients);rownames(H)<-rn
if (!is.null(s.offset)) {
s.offset <- napredict(na.act,s.offset)
attr(H,"offset") <- s.offset
attr(H,"offset") <- s.offset ## term specific offsets...
}
if (!is.null(attr(attr(object$model,"terms"),"offset"))) {
attr(H,"model.offset") <- napredict(na.act,model.offset(mf))
}
H <- napredict(na.act,H)
if (length(object$nsdf)>1) { ## add "lpi" attribute if more than one l.p.
......@@ -3667,7 +3679,8 @@ summary.gam <- function (object, dispersion = NULL, freq = FALSE, p.type=0, ...)
df[i] <- attr(V, "rank")
} else { ## Better founded alternatives...
Xt <- X[,start:stop,drop=FALSE]
fx <- if (inherits(object$smooth[[i]],"tensor.smooth")) all(object$smooth[[i]]$fx) else object$smooth[[i]]$fixed
fx <- if (inherits(object$smooth[[i]],"tensor.smooth")&&
!is.null(object$smooth[[i]]$fx)) all(object$smooth[[i]]$fx) else object$smooth[[i]]$fixed
if (!fx&&object$smooth[[i]]$null.space.dim==0&&!is.null(object$R)) { ## random effect or fully penalized term
res <- reTest(object,i)
} else { ## Inverted Nychka interval statistics
......
......@@ -91,19 +91,38 @@ XWyd <- function(X,w,y,k,ts,dt,v,qc,drop=NULL,ar.stop=-1,ar.row=-1,ar.w=-1) {
Xbd <- function(X,beta,k,ts,dt,v,qc,drop=NULL) {
## note that drop may contain the index of columns of X to drop before multiplying by beta.
## equivalently we can insert zero elements into beta in the appropriate places.
n <- nrow(k);m <- unlist(lapply(X,nrow));p <- unlist(lapply(X,ncol))
n <- if (is.matrix(k)) nrow(k) else length(k)
m <- unlist(lapply(X,nrow));p <- unlist(lapply(X,ncol))
nx <- length(X);nt <- length(ts)
if (!is.null(drop)) {
b <- rep(0,length(beta)+length(drop))
b[-drop] <- beta
b <- if (is.matrix(beta)) matrix(0,nrow(beta)+length(drop),ncol(beta)) else rep(0,length(beta)+length(drop))
if (is.matrix(beta)) b[-drop,] <- beta else b[-drop] <- beta
beta <- b
}
oo <- .C(C_Xbd,f=as.double(rep(0,n)),beta=as.double(beta),X=as.double(unlist(X)),k=as.integer(k-1),
bc <- if (is.matrix(beta)) ncol(beta) else 1
oo <- .C(C_Xbd,f=as.double(rep(0,n*bc)),beta=as.double(beta),X=as.double(unlist(X)),k=as.integer(k-1),
m=as.integer(m),p=as.integer(p), n=as.integer(n), nx=as.integer(nx), ts=as.integer(ts-1),
as.integer(dt), as.integer(nt),as.double(unlist(v)),as.integer(qc))
oo$f
as.integer(dt), as.integer(nt),as.double(unlist(v)),as.integer(qc),as.integer(bc))
if (is.matrix(beta)) matrix(oo$f,n,bc) else oo$f
} ## Xbd
diagXVXd <- function(X,V,k,ts,dt,v,qc,drop=NULL,n.threads=1) {
## discrete computation of diag(XVX')
n <- if (is.matrix(k)) nrow(k) else length(k)
m <- unlist(lapply(X,nrow));p <- unlist(lapply(X,ncol))
nx <- length(X);nt <- length(ts)
if (!is.null(drop)) {
pv <- ncol(V)+length(drop)
V0 <- matrix(0,pv,pv)
V0[-drop,-drop] <- V
V <- V0;rm(V0)
} else pv <- ncol(V)
oo <- .C(C_diagXVXt,diag=as.double(rep(0,n)),V=as.double(V),X=as.double(unlist(X)),k=as.integer(k-1),
m=as.integer(m),p=as.integer(p), n=as.integer(n), nx=as.integer(nx), ts=as.integer(ts-1),
as.integer(dt), as.integer(nt),as.double(unlist(v)),as.integer(qc),as.integer(pv),as.integer(n.threads))
oo$diag
} ## diagXVXd
dchol <- function(dA,R) {
## if dA contains matrix dA/dx where R is chol factor s.t. R'R = A
## then this routine returns dR/dx...
......
......@@ -172,8 +172,10 @@ uniquecombs <- function(x) {
x <- as.data.frame(x)
names(x) <- names(xo)
for (i in 1:ncol(xo)) if (is.factor(xo[,i])) { ## may need to reset factors to factors
x[,i] <- if (is.ordered(xo[,i])) as.ordered(x[,i]) else as.factor(x[,i])
levels(x[,i]) <- levels(xo[,i])
xoi <- levels(xo[,i])
x[,i] <- if (is.ordered(xo[,i])) ordered(x[,i],levels=1:length(xoi),labels=xoi) else
factor(x[,i],levels=1:length(xoi),labels=xoi)
contrasts(x[,i]) <- contrasts(xo[,i])
}
}
attr(x,"index") <- res$ind+1 ## C to R index gotcha
......@@ -3546,7 +3548,7 @@ PredictMat <- function(object,data,n=nrow(data))
X <- matrix(0,n,ncol(pm$X))
for (i in 1:n) { ## in this case have to work down the rows
ind <- ind + 1
X[i,] <- colSums(by[ind]*pm$X[pm$ind[ind],])
X[i,] <- colSums(by[ind]*pm$X[pm$ind[ind],,drop=FALSE])
if (!is.null(offs)) {
offX[i] <- sum(offs[pm$ind[ind]]*by[ind])
}
......@@ -3555,7 +3557,7 @@ PredictMat <- function(object,data,n=nrow(data))
} else { ## regular case
offset <- attr(pm$X,"offset")
if (!is.null(pm$ind)) { ## X needs to be unpacked
X <- pm$X[pm$ind,]
X <- pm$X[pm$ind,,drop=FALSE]
if (!is.null(offset)) offset <- offset[pm$ind]
} else X <- pm$X
......@@ -3588,7 +3590,7 @@ PredictMat <- function(object,data,n=nrow(data))
} else { get.off <- FALSE;offs <- NULL}
for (i in 2:q) {
ind <- ind + n
Xs <- Xs + X[ind,]
Xs <- Xs + X[ind,,drop=FALSE]
if (get.off) offs <- offs + offset[ind]
}
offset <- offs
......@@ -3645,7 +3647,7 @@ PredictMat <- function(object,data,n=nrow(data))
## drop columns eliminated by side-conditions...
del.index <- attr(object,"del.index")
if (!is.null(del.index)) X <- X[,-del.index]
if (!is.null(del.index)) X <- X[,-del.index,drop=FALSE]
attr(X,"offset") <- offset
X
} ## end of PredictMat
......
......@@ -254,7 +254,8 @@ setup.soap <- function(bnd,knots,nmax=100,k=10,bndSpec=NULL) {
}
bc[[i]] <- list(bsm=bsm,X=bsm$X[1:ret$nb[i],],S=bsm$S[[1]],free.bound=TRUE)
} else { ## boundary is fixed
d <- ret$d[start:stop]
## pmax/pmin needed to avoid rounding error induced NA's
d <- pmax(pmin(ret$d[start:stop],max(bnd[[i]]$d)),min(bnd[[i]]$d))
ui <- !duplicated(bnd[[i]]$d)
ff <- approx(bnd[[i]]$d[ui],bnd[[i]]$f[ui],d)$y ## fixed values for BC
bc[[i]] <- list(f=ff,free.bound=FALSE)
......
mgcv (1.8-10-1) unstable; urgency=low
* New upstream release
* debian/control: Set Build-Depends: to current R version
-- Dirk Eddelbuettel <edd@debian.org> Sat, 12 Dec 2015 12:29:27 -0600
mgcv (1.8-9-1) unstable; urgency=low
* New upstream release
......
......@@ -2,7 +2,7 @@ Source: mgcv
Section: gnu-r
Priority: optional
Maintainer: Dirk Eddelbuettel <edd@debian.org>
Build-Depends: debhelper (>= 7.0.0), r-base-dev (>= 3.2.2), r-cran-nlme, r-cran-matrix, cdbs
Build-Depends: debhelper (>= 7.0.0), r-base-dev (>= 3.2.3), r-cran-nlme, r-cran-matrix, cdbs
Standards-Version: 3.9.6
Package: r-cran-mgcv
......
......@@ -37,7 +37,7 @@ the contribution from any known boundary conditions on the smooth.
}
\references{
\url{http://www.maths.bath.ac.uk/~sw283/}
\url{http://www.maths.bris.ac.uk/~sw15190/}
}
\author{ Simon N. Wood \email{s.wood@bath.ac.uk}}
......
......@@ -73,6 +73,8 @@ Tweedie, M. C. K. (1984). An index which distinguishes between
New Directions. Proceedings of the Indian Statistical Institute
Golden Jubilee International Conference (Eds. J. K. Ghosh and J.
Roy), pp. 579-604. Calcutta: Indian Statistical Institute.
Wood, S.N., N. Pya and B. Saefken (2015), Smoothing parameter and model selection for general smooth models. \url{http://arxiv.org/abs/1511.03864}
}
\seealso{\code{\link{ldTweedie}}, \code{\link{rTweedie}}}
......
......@@ -166,7 +166,7 @@ An object of class \code{"gam"} as described in \code{\link{gamObject}}.
}
\details{ \code{bam} operates by first setting up the basis characteristics for the smooths, using a representative subsample
\details{ When \code{discrete=FALSE}, \code{bam} operates by first setting up the basis characteristics for the smooths, using a representative subsample
of the data. Then the model matrix is constructed in blocks using \code{\link{predict.gam}}. For each block the factor R,
from the QR decomposition of the whole model matrix is updated, along with Q'y. and the sum of squares of y. At the end of
block processing, fitting takes place, without the need to ever form the whole model matrix.
......@@ -186,6 +186,8 @@ can be used in the 1D case, and tensor product smooths (\code{te}) are typically
If \code{cluster} is provided as a cluster set up using \code{\link[parallel]{makeCluster}} (or \code{\link[parallel]{makeForkCluster}}) from the \code{parallel} package, then the rate limiting QR decomposition of the model matrix is performed in parallel using this cluster. Note that the speed ups are often not that great. On a multi-core machine it is usually best to set the cluster size to the number of physical cores, which is often less than what is reported by \code{\link[parallel]{detectCores}}. Using more than the number of physical cores can result in no speed up at all (or even a slow down). Note that a highly parallel BLAS may negate all advantage from using a cluster of cores. Computing in parallel of course requires more memory than computing in series. See examples.
When \code{discrete=TRUE} the covariate data are first discretized. Discretization takes place on a smooth by smooth basis, or in the case of tensor product smooths (or any smooth that can be represented as such, such as random effects), separately for each marginal smooth. The required spline bases are then evaluated at the discrete values, and stored, along with index vectors indicating which original observation they relate to. Fitting is by a version of performance oriented iteration/PQL using REML smoothing parameter selection on each iterative working model (as for the default method). The iteration is based on the derivatives of the REML score, without computing the score itself, allowing the expensive computations to be reduced to one parallel block Cholesky decomposition per iteration (plus two basic operations of equal cost, but easily parallelized). Unlike standard POI/PQL, only one step of the smoothing parameter update for the working model is taken at each step (rather than iterating to the optimal set of smoothing parameters for each working model). At each step a weighted model matrix crossproduct of the model matrix is required - this is efficiently computed from the pre-computed basis functions evaluated at the discretized covariate values. Efficient computation with tensor product terms means that some terms within a tensor product may be re-ordered for maximum efficiency. Parallel computation is controlled using the \code{nthreads} argument. For this method no cluster computation is used, and the \code{parallel} package is not required.
If the deprecated argument \code{sparse=TRUE} then QR updating is replaced by an alternative scheme, in which the model matrix is stored whole
as a sparse matrix. This only makes sense if all smooths are P-splines and all tensor products are of the
form \code{te(...,bs="ps",np=FALSE)}, but no check is made. The computations are then based on the Choleski decomposition of
......
......@@ -42,7 +42,7 @@ to the data (e.g. default knot locations).
\references{
\url{http://www.maths.bath.ac.uk/~sw283/}
\url{http://www.maths.bris.ac.uk/~sw15190/}
}
\author{ Simon N. Wood \email{simon.wood@r-project.org}
......
......@@ -66,7 +66,7 @@ conclusions to be drawn from a model fit, however.
Wood, S.N. (2006) Generalized Additive Models: An Introduction with R. CRC.
\url{http://www.maths.bath.ac.uk/~sw283/}
\url{http://www.maths.bris.ac.uk/~sw15190/}
}
\examples{
......
......@@ -59,7 +59,7 @@ over-optimism of the previous two measures, but is less easy to understand.}
\references{
\url{http://www.maths.bath.ac.uk/~sw283/}
\url{http://www.maths.bris.ac.uk/~sw15190/}
}
\author{ Simon N. Wood \email{simon.wood@r-project.org}
......
......@@ -43,6 +43,8 @@ Hastie and Tibshirani (1990) Generalized Additive Models, Chapman and Hall.
Klein, J.P and Moeschberger, M.L. (2003) Survival Analysis: Techniques for
Censored and Truncated Data (2nd ed.) Springer.
Wood, S.N., N. Pya and B. Saefken (2015), Smoothing parameter and model selection for general smooth models. \url{http://arxiv.org/abs/1511.03864}
}
......
......@@ -32,7 +32,7 @@ is `too far' from any datum.
}
\references{
\url{http://www.maths.bath.ac.uk/~sw283/}
\url{http://www.maths.bris.ac.uk/~sw15190/}
}
\author{ Simon N. Wood \email{simon.wood@r-project.org}}
......
......@@ -77,7 +77,7 @@ or
Wood S.N. (2006) Generalized Additive Models: An Introduction with R. Chapman
and Hall/CRC Press.
\url{http://www.maths.bath.ac.uk/~sw283/}
\url{http://www.maths.bris.ac.uk/~sw15190/}
}
\author{ Simon N. Wood \email{simon.wood@r-project.org}}
......
......@@ -33,7 +33,8 @@ The following families implement more general model classes. Usable only with \c
\item \code{\link{gaulss}} a Gaussian location-scale model where the mean and the standard deviation are both modelled using smooth linear predictors.
\item \code{\link{ziplss}} a `two-stage' zero inflated Poisson model, in which 'potential-presence' is modelled with one linear predictor, and Poisson mean abundance
given potential presence is modelled with a second linear predictor.
\item \code{\link{mvn}} multivariate normal additive models.
\item \code{\link{mvn}}: multivariate normal additive models.
\item \code{\link{multinom}}: multinomial logistic regression, for unordered categorical responses.
} %% end itemize
}
......@@ -41,6 +42,9 @@ given potential presence is modelled with a second linear predictor.
\author{ Simon N. Wood (s.wood@r-project.org) & Natalya Pya
}
\references{
Wood, S.N., N. Pya and B. Saefken (2015), Smoothing parameter and model selection for general smooth models. \url{http://arxiv.org/abs/1511.03864}
}
\keyword{models} \keyword{regression}%-- one or more ..
......
......@@ -41,7 +41,7 @@ For details of how GAMMs are set up for estimation using \code{lme} see:
Wood, S.N. (2006) Low rank scale invariant tensor product smooths for
Generalized Additive Mixed Models. Biometrics 62(4):1025-1036
\url{http://www.maths.bath.ac.uk/~sw283/}
\url{http://www.maths.bris.ac.uk/~sw15190/}
}
\author{ Simon N. Wood \email{simon.wood@r-project.org}}
......
......@@ -21,7 +21,7 @@ print an appropriate description of the model.
Other \code{mgcv} modelling functions will not accept a list. The list form provides a mechanism for
specifying several linear predictors, and allows these to share terms: see below.
The formulae supplied to \code{\link{gam}} are exactly like that supplied to
The formulae supplied to \code{\link{gam}} are exactly like those supplied to
\code{\link{glm}} except that smooth terms, \code{\link{s}}, \code{\link{te}}, \code{\link{ti}} and \code{\link{t2}} can
be added to the right hand side (and \code{.} is not supported in \code{gam} formulae).
......
......@@ -329,7 +329,7 @@ Wood (2001) mgcv:GAMs and Generalized Ridge Regression for R. R News 1(2):20-25
Wood and Augustin (2002) GAMs with integrated model selection using penalized regression splines and applications
to environmental modelling. Ecological Modelling 157:157-177
\url{http://www.maths.bath.ac.uk/~sw283/}
\url{http://www.maths.bris.ac.uk/~sw15190/}
}
\author{ Simon N. Wood \email{simon.wood@r-project.org}
......
......@@ -61,7 +61,7 @@ Wood S.N. (2006) Generalized Additive Models: An Introduction with R. Chapman
and Hall/CRC Press.
\url{http://www.maths.bath.ac.uk/~sw283/}
\url{http://www.maths.bris.ac.uk/~sw15190/}
}
\author{ Simon N. Wood \email{simon.wood@r-project.org}}
......
......@@ -121,7 +121,7 @@ Wood, S.N. (2004) Stable and efficient multiple smoothing parameter estimation f
generalized additive models. J. Amer. Statist. Ass.99:673-686.
\url{http://www.maths.bath.ac.uk/~sw283/}
\url{http://www.maths.bris.ac.uk/~sw15190/}
}
......
......@@ -3,7 +3,7 @@
%- Also NEED an `\alias' for EACH other topic documented here.
\title{GAM P-IRLS estimation with GCV/UBRE smoothness estimation}
\description{ This is an internal function of package \code{mgcv}. It is a modification
of the function \code{glm.fit}, designed to be called from \code{gam}. The major
of the function \code{glm.fit}, designed to be called from \code{gam} when perfomance iteration is selected (not the default). The major
modification is that rather than solving a weighted least squares problem at each IRLS step,
a weighted, penalized least squares problem
is solved at each IRLS step with smoothing parameters associated with each penalty chosen by GCV or UBRE,
......
......@@ -127,7 +127,7 @@ models. Journal of the Royal Statistical Society (B) 73(1):3-36
O 'Sullivan, Yandall & Raynor (1986) Automatic smoothing of regression
functions in generalized linear models. J. Amer. Statist. Assoc. 81:96-103.
\url{http://www.maths.bath.ac.uk/~sw283/}
\url{http://www.maths.bris.ac.uk/~sw15190/}
}
\author{ Simon N. Wood \email{simon.wood@r-project.org}
......
......@@ -59,7 +59,7 @@ Wood, S.N. (2011) Fast stable restricted maximum likelihood
and marginal likelihood estimation of semiparametric generalized linear
models. Journal of the Royal Statistical Society (B) 73(1):3-36
\url{http://www.maths.bath.ac.uk/~sw283/}
\url{http://www.maths.bris.ac.uk/~sw15190/}
}
\author{ Simon N. Wood \email{simon.wood@r-project.org}}
......
......@@ -150,7 +150,7 @@ models. Journal of the Royal Statistical Society (B) 73(1):3-36
\url{http://www.maths.bath.ac.uk/~sw283/}
\url{http://www.maths.bris.ac.uk/~sw15190/}
}
......
......@@ -52,6 +52,14 @@ prediction matrices for the term.
\author{ Simon N. Wood \email{simon.wood@r-project.org}}
\section{WARNINGS }{
Much better statistical stability will be obtained by using models like
\code{y~s(x)+s(z)+ti(x,z)} or \code{y~ti(x)+ti(z)+ti(x,z)} rather than
\code{y~s(x)+s(z)+s(x,z)}, since the former are designed not to require
further constraint.
}
\seealso{\code{\link{ti}}, \code{\link{gam.models}}}
\examples{
## The first two examples here iluustrate models that cause
......
......@@ -47,7 +47,7 @@ functions in generalized linear models. J. Amer. Statist. Assoc. 81:96-103.
Wood, S.N. (2008) Fast stable direct fitting and smoothness selection for generalized
additive models. J.R.Statist.Soc.B 70(3):495-518
\url{http://www.maths.bath.ac.uk/~sw283/}
\url{http://www.maths.bris.ac.uk/~sw15190/}
}
\author{ Simon N. Wood \email{simon.wood@r-project.org}}
......
......@@ -188,7 +188,7 @@ and Hall/CRC Press.
Wang, Y. (1998) Mixed effects smoothing spline analysis of variance. J.R. Statist. Soc. B 60, 159-174
\url{http://www.maths.bath.ac.uk/~sw283/}
\url{http://www.maths.bris.ac.uk/~sw15190/}
}
\author{ Simon N. Wood \email{simon.wood@r-project.org}}
......
......@@ -31,6 +31,10 @@ The null deviance reported for this family is the sum of squares of the differen
}
\references{
Wood, S.N., N. Pya and B. Saefken (2015), Smoothing parameter and model selection for general smooth models. \url{http://arxiv.org/abs/1511.03864}
}
......
......@@ -22,7 +22,7 @@ function returns \code{NULL}.}
\value{The evaluated variable or \code{NULL}. May be coerced to a numeric vector if it's a matrix.}
\references{
\url{http://www.maths.bath.ac.uk/~sw283/}
\url{http://www.maths.bris.ac.uk/~sw15190/}
}
\author{ Simon N. Wood \email{simon.wood@r-project.org} }
......
......@@ -30,7 +30,7 @@ the boundary and \code{FALSE} otherwise.
\references{
\url{http://www.maths.bath.ac.uk/~sw283/}
\url{http://www.maths.bris.ac.uk/~sw15190/}
}
\author{ Simon N. Wood \email{simon.wood@r-project.org}
......
......@@ -48,7 +48,7 @@ inside the boundary.
\references{
\url{http://www.maths.bath.ac.uk/~sw283/}
\url{http://www.maths.bris.ac.uk/~sw15190/}
}
\author{ Simon N. Wood \email{simon.wood@r-project.org}}
......
......@@ -36,7 +36,7 @@ the options do not depend on variables which might not be available later.}
\references{
\url{http://www.maths.bath.ac.uk/~sw283/}
\url{http://www.maths.bris.ac.uk/~sw15190/}
}
\author{ Simon N. Wood \email{simon.wood@r-project.org}}
......
......@@ -114,6 +114,8 @@ The \code{sim2jam} function takes the partial \code{gam} object (\code{pregam})
\references{
Wood, S.N. (in press) Just Another Gibbs Additive Modeller: Interfacing JAGS and mgcv. Journal of Statistical Software
Marra, G. and S.N. Wood (2011) Practical variable selection for generalized additive models.
Computational Statistics & Data Analysis 55(7): 2372-2387
......
......@@ -23,7 +23,7 @@ same names as the elements of the list. If \code{x} is not a list then its size
\references{
\url{http://www.maths.bath.ac.uk/~sw283/}
\url{http://www.maths.bris.ac.uk/~sw15190/}
}
\author{ Simon N. Wood \email{simon.wood@r-project.org}
......
......@@ -198,7 +198,7 @@ Note that some further useful quantities can be obtained using \code{\link{magic
Wood, S.N. (2004) Stable and efficient multiple smoothing parameter estimation for
generalized additive models. J. Amer. Statist. Ass. 99:673-686
\url{http://www.maths.bath.ac.uk/~sw283/}
\url{http://www.maths.bris.ac.uk/~sw15190/}
}
\author{ Simon N. Wood \email{simon.wood@r-project.org}}
......
......@@ -29,7 +29,7 @@ SEs etc to be calculated).
REML estimation of smoothing parameters in versions 1.5, some changes had to be made to the syntax. In particular the
function \code{gam.method} no longer exists. The smoothness selection method (GCV, REML etc) is now controlled by the
\code{method} argument to \code{gam} while the optimizer is selected using the \code{optimizer} argument.
See \code{\link{gam}} and \url{http://www.maths.bath.ac.uk/~sw283/igam/index.html} for details.
See \code{\link{gam}} and \url{http://www.maths.bris.ac.uk/~sw15190/igam/index.html} for details.
\item \bold{Why is a model object saved under a previous mgcv version not usable with the current mgcv version?}
I'm sorry about this issue, I know it's really annoying. Here's my defence.
......
......@@ -85,6 +85,7 @@ French Translation - Philippe Grosjean
Maintainer: Simon Wood <simon.wood@r-project.org>
Part funded by EPSRC: EP/K005251/1
}
\references{
These provide details for the underlying mgcv methods, and fuller
......
......@@ -39,7 +39,7 @@ mono.con(x,up=TRUE,lower=NA,upper=NA)
Wood, S.N. (1994) Monotonic smoothing splines fitted by cross validation.
\emph{SIAM Journal on Scientific Computing} \bold{15}(5), 1126--1133.
\url{http://www.maths.bath.ac.uk/~sw283/}
\url{http://www.maths.bris.ac.uk/~sw15190/}
}
\author{ Simon N. Wood \email{simon.wood@r-project.org} }
......
\name{multinom}
\alias{multinom}
%- Also NEED an `\alias' for EACH other topic documented here.
\title{GAM multinomial logistic regression}
\description{Family for use with \code{\link{gam}}, implementing regression for categorical response data. Categories must be coded 0 to K, where K is a positive integer. \code{\link{gam}} should be called with a list of K formulae, one for each category except category zero (extra formulae for shared terms may also be supplied). The first formula also specifies the response variable.
}
\usage{
multinom(K=1)
}
\arguments{
\item{K}{There are K+1 categories and K linear predictors. }
}
\value{
An object of class \code{general.family}.
}
\details{
The model has K linear predictors, \eqn{\eta_j}{h_j}, each dependent on smooth functions of predictor variables, in the usual way. If response variable, y, contains the class labels 0,...,K then the likelihood for y>0 is \eqn{\exp(\eta_y)/\{1+\sum_j \exp(\eta_j) \}}{exp(h_y)/(1 + sum_j exp(h_j) )}. If y=0 the likelihood is \eqn{1/\{1+\sum_j \exp(\eta_j) \}}{1/(1 + sum_j exp(h_j) )}. In the two class case this is just a binary logistic regression model. The implementation uses the approach to GAMLSS models described in Wood, Pya and Saefken (2015).
The residuals returned for this model are simply the square root of -2 times the deviance for each observation, with a positive sign if the observed y is the most probable class for this observation, and a negative sign otherwise.
Use \code{predict} with \code{type="response"} to get the predicted probabilities in each category.
Note that the model is not completely invariant to category relabelling, even if all linear predictors have the same form. Realistically this model is unlikely to be suitable for problems with large numbers of categories. Missing categories are not supported.
}
%- maybe also `usage' for other objects documented here.
\author{ Simon N. Wood \email{simon.wood@r-project.org}
}
\references{
Wood, S.N., N. Pya and B. Saefken (2015), Smoothing parameter and model selection for general smooth models. \url{http://arxiv.org/abs/1511.03864}
}
\seealso{\code{\link{ocat}}}
\examples{
library(mgcv)
set.seed(6)
## simulate some data from a three class model
n <- 1000
f1 <- function(x) sin(3*pi*x)*exp(-x)
f2 <- function(x) x^3
f3 <- function(x) .5*exp(-x^2)-.2
f4 <- function(x) 1
x1 <- runif(n);x2 <- runif(n)
eta1 <- 2*(f1(x1) + f2(x2))-.5