Commit 5e419731 authored by Dirk Eddelbuettel's avatar Dirk Eddelbuettel

Import Upstream version 1.3-29

parent ea0e2b60
Package: mgcv
Version: 1.3-28
Version: 1.3-29
Author: Simon Wood <simon.wood@r-project.org>
Maintainer: Simon Wood <simon.wood@r-project.org>
Title: GAMs with GCV smoothness estimation and GAMMs by REML/PQL
......@@ -13,4 +13,4 @@ Imports: graphics, stats
Suggests: nlme (>= 3.1-64), MASS (>= 7.2-2)
LazyLoad: yes
License: GPL version 2 or later
Packaged: Wed Oct 10 10:43:12 2007; simon
Packaged: Wed Nov 14 10:04:15 2007; simon
......@@ -485,7 +485,7 @@ gamm.setup<-function(formula,pterms,data=stop("No data supplied to gam.setup"),k
"Tensor product penalty rank appears to be too low: please email Simon.Wood@R-project.org with details.")
D<-1/sqrt(D)
XZU<-XZ%*%U
if (p.rank<k-j) Xf<-as.matrix(XZU[,(p.rank+1):(k-j)])
if (p.rank<k-j) Xf<-XZU[,(p.rank+1):(k-j),drop=FALSE]
else Xf<-matrix(0,nrow(sm$X),0) # no fixed terms left
if (mult.pen)
{ Xr <- XZU[,1:p.rank] # tensor product case
......@@ -709,7 +709,7 @@ extract.lme.cov2<-function(b,data,start.level=1)
X[[1]] <- model.matrix(~b$groups[[n.levels-i+1]]-1,
contrasts.arg=c("contr.treatment","contr.treatment")) }
# Get `model matrix' columns relevant to current grouping level...
X[[2]] <- as.matrix(Zt[,i.col:(i.col+grp.dims[i]-1)])
X[[2]] <- Zt[,i.col:(i.col+grp.dims[i]-1),drop=FALSE]
i.col <- i.col+grp.dims[i]
# tensor product the X[[1]] and X[[2]] rows...
Z <- cbind(Z,tensor.prod.model.matrix(X))
......@@ -740,7 +740,7 @@ extract.lme.cov2<-function(b,data,start.level=1)
Vz <- list()
for (i in 1:n.cg) {
j1 <- size.cg[i] + j0 -1
if (j0==j1) Zi <- t(as.matrix(Z[j0,])) else Zi <- Z[j0:j1,]
Zi <- Z[j0:j1,,drop=FALSE]
Vz[[i]] <- Zi %*% Vr %*% t(Zi)
j0 <- j1+1
}
......@@ -823,7 +823,7 @@ extract.lme.cov<-function(b,data,start.level=1)
X[[1]] <- model.matrix(~b$groups[[n.levels-i+1]]-1,
contrasts.arg=c("contr.treatment","contr.treatment")) }
# Get `model matrix' columns relevant to current grouping level...
X[[2]] <- as.matrix(Zt[,i.col:(i.col+grp.dims[i]-1)])
X[[2]] <- Zt[,i.col:(i.col+grp.dims[i]-1),drop=FALSE]
i.col <- i.col+grp.dims[i]
# tensor product the X[[1]] and X[[2]] rows...
Z <- cbind(Z,tensor.prod.model.matrix(X))
......@@ -1049,8 +1049,13 @@ gamm <- function(formula,random=NULL,correlation=NULL,family=gaussian(),data=lis
{ # first get the existing grouping structure ....
corGroup <- paste(names(rand),collapse="/")
groupForm<-nlme::getGroupsFormula(correlation)
if (!is.null(groupForm))
corGroup <- paste(corGroup,paste(all.vars(nlme::getGroupsFormula(correlation)),collapse="/"),sep="/")
if (!is.null(groupForm)) {
groupFormNames <- all.vars(groupForm)
exind <- groupFormNames %in% names(rand)
groupFormNames <- groupFormNames[!exind] ## dumping duplicates
if (length(groupFormNames)) corGroup <-
paste(corGroup,paste(groupFormNames,collapse="/"),sep="/")
}
# now make a new formula for the correlation structure including these groups
corForm <- as.formula(paste(deparse(nlme::getCovariateFormula(correlation)),"|",corGroup))
attr(correlation,"formula") <- corForm
......
......@@ -2856,7 +2856,13 @@ magic <- function(y,X,sp,S,off,rank=NULL,H=NULL,C=NULL,w=NULL,gamma=1,scale=1,gc
ns.qr<-qr(t(C)) # last n.b-n.con columns of Q are the null space of C
X<-t(qr.qty(ns.qr,t(X)))[,(n.con+1):n.b] # last n.b-n.con cols of XQ (=(Q'X')')
# need to work through penalties forming Z'S_i^0.5 's
if (n.p>0) for (i in 1:n.p) S[[i]]<-qr.qty(ns.qr,S[[i]])[(n.con+1):n.b,,drop=FALSE]
if (n.p>0) for (i in 1:n.p) {
S[[i]]<-qr.qty(ns.qr,S[[i]])[(n.con+1):n.b,,drop=FALSE]
## following essential given assumptions of the C code...
if (ncol(S[[i]])>nrow(S[[i]])) { ## no longer have a min col square root.
S[[i]] <- t(qr.R(qr(t(S[[i]])))) ## better!
}
}
# and Z'HZ too
if (!is.null(H))
{ H<-qr.qty(ns.qr,H)[(n.con+1):n.b,] # Z'H
......
This diff is collapsed.
citHeader("2000 for basics set up and old smoothness selection method;
2003 for thin plate regression splines etc; 2004 for newer, default,
methods and basics of gamm; 2006 for overview.")
citEntry(
entry="Article",
title="Modelling and smoothing parameter estimation with
multiple quadratic penalties",
journal="Journal of the Royal Statistical Society (B)",
volume= "62",
number="2",
pages="413-428",
year="2000",
author="S. N. Wood",
textVersion="Wood, S.N. (2000) Modelling and smoothing parameter
estimation with multiple quadratic penalties. Journal of the Royal
Statistical Society (B) 62(2):413-428. " )
citEntry(
entry="Article",
title="Thin-plate regression splines",
journal="Journal of the Royal Statistical Society (B)",
volume= "65",
number="1",
pages="95-114",
year="2003",
author="S. N. Wood",
textVersion="Wood, S.N. (2003) Thin-plate regression splines.
Journal of the Royal Statistical Society (B) 65(1):95-114." )
citHeader("2004 for additive model method and basics of gamm; 2008 for
generalized additive model method; 2006 for overview; 2003 for thin plate
regression splines; 2000 is the original method, but no longer the default.")
citEntry(
......@@ -45,6 +18,21 @@ citEntry(
American Statistical Association. 99:673-686."
)
citEntry(
entry="Article",
title="Fast stable direct fitting and smoothness selection for generalized
additive models",
journal="Journal of the Royal Statistical Society (B)",
volume= "70",
number="2",
pages="-",
year="2008",
author="S. N. Wood",
textVersion="Wood, S.N. (2008) Fast stable direct fitting and smoothness
selection for generalized additive models. Journal of the Royal
Statistical Society (B) 70(2): - . " )
citEntry(
entry="Book",
title="Generalized Additive Models: An Introduction with R",
......@@ -55,3 +43,29 @@ textVersion="Wood, S.N. (2006) Generalized Additive Models: An
Introduction with R. Chapman and Hall/CRC. "
)
citEntry(
entry="Article",
title="Thin-plate regression splines",
journal="Journal of the Royal Statistical Society (B)",
volume= "65",
number="1",
pages="95-114",
year="2003",
author="S. N. Wood",
textVersion="Wood, S.N. (2003) Thin-plate regression splines.
Journal of the Royal Statistical Society (B) 65(1):95-114." )
citEntry(
entry="Article",
title="Modelling and smoothing parameter estimation with
multiple quadratic penalties",
journal="Journal of the Royal Statistical Society (B)",
volume= "62",
number="2",
pages="413-428",
year="2000",
author="S. N. Wood",
textVersion="Wood, S.N. (2000) Modelling and smoothing parameter
estimation with multiple quadratic penalties. Journal of the Royal
Statistical Society (B) 62(2):413-428. " )
......@@ -167,8 +167,8 @@ on checking the basis dimension choise.
interpretability.
Details of some underlying fitting methods are given in Wood (2000, 2004,
2006b).
Details of the default underlying fitting methods are given in Wood (2004
and 2008). Some alternative methods are discussed in Wood (2000 and 2006).
}
......@@ -328,13 +328,15 @@ Otherwise the function returns an object of class \code{"gam"} as described in \
Key References on this implementation:
Wood, S.N. (2000) Modelling and Smoothing Parameter Estimation
with Multiple Quadratic Penalties. J.R.Statist.Soc.B 62(2):413-428
Wood, S.N. (2004) Stable and efficient multiple smoothing parameter estimation for
generalized additive models. J. Amer. Statist. Ass. 99:673-686. [Default
method for additive case (but no longer for generalized)]
Wood, S.N. (2003) Thin plate regression splines. J.R.Statist.Soc.B 65(1):95-114
Wood, S.N. (2008) Fast stable direct fitting and smoothness selection for generalized
additive models. J.R.Statist.Soc.B 70(2): --- [Default method for generalized
additive model case]
Wood, S.N. (2004) Stable and efficient multiple smoothing parameter estimation for
generalized additive models. J. Amer. Statist. Ass. 99:673-686
Wood, S.N. (2003) Thin plate regression splines. J.R.Statist.Soc.B 65(1):95-114
Wood, S.N. (2006a) Low rank scale invariant tensor product smooths for
generalized additive mixed models. Biometrics 62(4):1025-1036
......@@ -344,6 +346,9 @@ and Hall/CRC Press.
Wood, S.N. (2006c) On confidence intervals for generalized additive models based on penalized regression splines. Australian and New Zealand Journal of Statistics. 48(4): 445-464.
Wood, S.N. (2000) Modelling and Smoothing Parameter Estimation
with Multiple Quadratic Penalties. J.R.Statist.Soc.B 62(2):413-428 [The original
paper, but no longer the default methods.]
Key Reference on GAMs and related models:
......
......@@ -2140,6 +2140,7 @@ long alias(X,aliased,tol) matrix X;long *aliased;double tol;
{ matrix F,x,xp,p,w;
double e,x2,y;
long i,j,k,n;
w=initmat(1L,1L); /* keep gcc -Wall happy */
w.r=0L;
F=initmat(X.r,X.c);x=initmat(X.r,1L);p=initmat(X.c,1L);
xp=initmat(x.r,1L);
......@@ -2161,6 +2162,7 @@ long alias(X,aliased,tol) matrix X;long *aliased;double tol;
{ aliased[n]=i;n++;}
}
freemat(F);freemat(xp);freemat(x);freemat(p);
w.r=1L;freemat(w);
return(n);
}
......
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