Commit 8608e588 authored by Dirk Eddelbuettel's avatar Dirk Eddelbuettel

Import Upstream version 1.4-0

parent e615362d
Package: mgcv
Version: 1.3-31
Version: 1.4-0
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
......@@ -10,7 +10,7 @@ Description: Routines for GAMs and other generalized ridge regression
Priority: recommended
Depends: R (>= 2.3.0)
Imports: graphics, stats
Suggests: nlme (>= 3.1-64), MASS (>= 7.2-2)
Suggests: nlme (>= 3.1-64), splines
LazyLoad: yes
License: GPL (>=2)
Packaged: Tue Apr 29 14:19:05 2008; simon
Packaged: Thu Jun 5 20:34:47 2008; simon
......@@ -2,19 +2,18 @@ useDynLib(mgcv, .registration = TRUE, .fixes = "C_")
export(
anova.gam,coef.pdIdnot,coef.pdTens,
corMatrix.pdIdnot,Dim.pdIdnot,
corMatrix.pdIdnot,cSplineDes,Dim.pdIdnot,
exclude.too.far,extract.lme.cov, extract.lme.cov2,
formXtViX, full.score, formula.gam,fixDependence,fix.family.link,
fix.family.var, gam, gam2derivative, gam2objective,
gam3objective, gamm, gam.check, gam.control, gam.fit2,gam.fit3,
gam.fit, gam.outer, gamm.setup , influence.gam, interpret.gam,
gam.setup,
gamm, gam.check, gam.control,gam.fit3,
gam.fit, gam.outer, gamm.setup, gamSim , influence.gam,
interpret.gam, gam.setup,
gam.side,gam.method,
get.var,
logDet.pdIdnot,
get.var,logDet.pdIdnot,
initial.sp,logLik.gam,
magic, magic.post.proc, mgcv, mgcv.control, mgcv.find.theta,
mgcv.get.scale, model.matrix.gam, mono.con, mroot, new.name,
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,
......@@ -27,14 +26,17 @@ anova.gam,coef.pdIdnot,coef.pdTens,
Predict.matrix.tensor.smooth,
Predict.matrix.tprs.smooth,
Predict.matrix.ts.smooth,
Predict.matrix.pspline.smooth,
residuals.gam, s,
smoothCon,smooth.construct,
smoothCon,smooth.construct,smooth.construct2,
smooth.construct.cc.smooth.spec,
smooth.construct.cr.smooth.spec,
smooth.construct.cs.smooth.spec,
smooth.construct.tensor.smooth.spec,
smooth.construct.tp.smooth.spec,
smooth.construct.ts.smooth.spec,
smooth.construct.ps.smooth.spec,
smooth.construct.ad.smooth.spec,
summary.gam,
solve.pdIdnot,
summary.pdIdnot,summary.pdTens,te,
......
This diff is collapsed.
This diff is collapsed.
## Example simulated data for gam.models (c) Simon N. Wood 2008
gamSim <- function(eg=1,n=400,dist="normal",scale=2) {
if (eg==1||eg==7) { ## 4 term Gu and Wahba example
if (eg==1) cat("Gu & Wahba 4 term additive model\n")
else cat("Gu & Wahba 4 term additive model, correlated predictors\n")
x0 <- runif(n, 0, 1)
if (eg==7) x1 <- x0*.7 + runif(n, 0, .3) else
x1 <- runif(n,0,1)
x2 <- runif(n, 0, 1)
if (eg==7) x3 <- x2*.9 + runif(n,0,.1) else
x3 <- runif(n, 0, 1)
f0 <- function(x) 2 * sin(pi * x)
f1 <- function(x) exp(2 * x)
f2 <- function(x) 0.2*x^11*(10*(1-x))^6+10*(10*x)^3*(1-x)^10
f3 <- function(x) 0*x
f <- f0(x0) + f1(x1) + f2(x2)
if (dist=="normal") {
e <- rnorm(n, 0, scale)
y <- f + e
} else if (dist=="poisson") {
g<-exp(f*scale)
y<-rpois(rep(1,n),g)
} else if (dist=="binary") {
g <- (f-5)*scale
g <- binomial()$linkinv(g)
y <- rbinom(g,1,g)
} else stop("dist not recognised")
data <- data.frame(y=y,x0=x0,x1=x1,x2=x2,x3=x3,f=f,f0=f0(x0),f1=f1(x1),f2=f2(x2),f3=x3*0)
return(data)
} else if (eg==2) { ## Simple 2D smoothing example
cat("Bivariate smoothing example\n")
test1<-function(x,z,sx=0.3,sz=0.4)
{ (pi**sx*sz)*(1.2*exp(-(x-0.2)^2/sx^2-(z-0.3)^2/sz^2)+
0.8*exp(-(x-0.7)^2/sx^2-(z-0.8)^2/sz^2))
}
x <- runif(n);z <- runif(n);
xs<-seq(0,1,length=40);zs<-seq(0,1,length=40)
pr <- data.frame(x=rep(xs,40),z=rep(zs,rep(40,40)))
truth <- matrix(test1(pr$x,pr$z),40,40)
f <- test1(x,z)
y <- f + rnorm(n)*scale
data <- data.frame(y=y,x=x,z=z,f=f)
truth <- list(x=xs,z=zs,f=truth)
return(list(data=data,truth=truth,pr=pr))
} else if (eg==3) { ## continuous `by' variable
cat("Continuous `by' variable example\n")
x1 <- runif(n, 0, 1)
x2 <- sort(runif(n, 0, 1))
f <- 0.2 * x2^11 * (10 * (1 - x2))^6 +
10 * (10 * x2)^3 * (1 - x2)^10
e <- rnorm(n, 0, scale)
# A continuous `by' variable example....
y <- f*x1 + e
return(data.frame(y=y,x1=x1,x2=x2,f=f))
} else if (eg==4) { ## factor `by' variable
cat("Factor `by' variable example\n")
n <- 400
x0 <- runif(n, 0, 1)
x1 <- runif(n, 0, 1)
x2 <- runif(n, 0, 1)
f1 <- 2 * sin(pi * x2)
f2 <- exp(2 * x2) - 3.75887
f3 <- 0.2 * x2^11 * (10 * (1 - x2))^6 +
10 * (10 * x2)^3 * (1 - x2)^10
e <- rnorm(n, 0, scale)
fac<-as.factor(c(rep(1,100),rep(2,100),rep(3,200)))
fac.1<-as.numeric(fac==1);fac.2<-as.numeric(fac==2);
fac.3<-as.numeric(fac==3)
y<-f1*fac.1+f2*fac.2+f3*fac.3+ e
return(data.frame(y=y,x0=x0,x1=x1,x2=x2,fac=fac,f1=f1,f2=f2,f3=f3))
} else if (eg==5) { ## additive + factor
cat("Additive model + factor\n")
x0 <- rep(1:4,50)
x1 <- runif(n, 0, 1)
x2 <- runif(n, 0, 1)
x3 <- runif(n, 0, 1)
y <- 2 * x0
y <- y + exp(2 * x1)
y <- y + 0.2 * x2^11 * (10 * (1 - x2))^6 + 10 * (10 * x2)^3 * (1 - x2)^10
e <- rnorm(n, 0, scale)
y <- y + e
x0<-as.factor(x0)
return(data.frame(y=y,x0=x0,x1=x1,x2=x2,x3=x3))
} else if (eg==6) { ## Gu and Wahba + a random ractor
cat("4 term additive + random effect")
dat <- gamSim(1,n=n,scale=0)
fac <- rep(1:4,n/4)
dat$f <- dat$f + fac*3
dat$fac<-as.factor(fac)
if (dist=="normal") {
dat$y <- dat$f + rnorm(n)*scale
} else if (dist=="poisson") {
g <- exp(dat$f*scale)
dat$y <- rpois(rep(1,n),g)
} else if (dist=="binary") {
g <- (dat$f-5)*scale
g <- binomial()$linkinv(g)
dat$y <- rbinom(g,1,g)
}
return(dat)
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -24,8 +24,8 @@ citEntry(
additive models",
journal="Journal of the Royal Statistical Society (B)",
volume= "70",
number="2",
pages="-",
number="3",
pages="495-518",
year="2008",
author="S. N. Wood",
textVersion="Wood, S.N. (2008) Fast stable direct fitting and smoothness
......
\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
......@@ -16,6 +19,7 @@ In practice this method is often called via the wrapper function \code{\link{Pre
\usage{
Predict.matrix(object,data)
Predict.matrix2(object,data)
}
%- maybe also `usage' for other objects documented here.
\arguments{
......@@ -23,8 +27,9 @@ Predict.matrix(object,data)
contains all the information required to specify the basis for a term of its class, and this information is
used by the appropriate \code{Predict.matrix} function to produce a prediction matrix for new covariate values.
Further details are given in \code{\link{smooth.construct}}.}
\item{data}{A data frame containing the values of the (named) covariates at which the smooth term is to be
evaluated.}
evaluated. Exact requirements are as for \code{\link{smooth.construct}} and \code{smooth.construct2}}.
}
\value{ A matrix which will map the parameters associated with the smooth to the vector of values of the smooth
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -16,7 +16,7 @@ extract.lme.cov2(b,data,start.level=1)
%- maybe also `usage' for other objects documented here.
\arguments{
\item{b}{ A fitted model object returned by a call to \code{\link[nlme]{lme}}}
\item{b}{ A fitted model object returned by a call to \code{\link[nlme]{lme}}}.
\item{data}{ The data frame/ model frame that was supplied to
\code{\link[nlme]{lme}}.}
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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