Learn R Programming

gsg (version 2.0)

gppr: Generalised projection pursuit regression

Description

Performs generalized projection pursuit regression for binary and Poisson response variables. Wraps ppr from package stats in an iterative re-weighting algorithm. Included in package gsg to support inference of the form of natural selection, and for inference of selection gradients from projection pursuit regression-based inference of fitness functions.

Usage

gppr(y, xterms, data, nterms = 1, tol = 0.001, gcvpen = 1, maxit = 50, family = 'binomial', max.terms = 2)

Arguments

y
response variable, e.g., absolute fitness
xterms
names of predictor variables in data
data
a data frame containing columns with names matching xterms
nterms
number of terms to include in the final model
tol
maximum sum of relative changes in linear predictors between iterations
gcvpen
penalty used for each degree of freedom in GCV selection for spline ridge functions
maxit
maximum number if iterations of the iterative re-weighting procedure
family
distribution of the response variable, currently 'binomial' and 'Poisson' are supported
max.terms
the maximum number of terms to choose from when building the model
...
other parameters passed to ppr

Value

A gppr object, which contains a ppr object, plus information information pertaining to the iterative re-weighting procedure. Most of these repeat arguments passed to gppr(), also included are:
iterations
the number of iterations of the iterative re-weighting procedure that were performed
f
the formula passed to ppr, constructed from xterms

References

M.B. Morrissey. in prep.

See Also

predict.gppr, ppr,gppr.gradients

Examples

Run this code
# simulated data (two traits, stabilizing selection on trait 1)
n<-250
z<-cbind(rnorm(n,0,1),rnorm(n,0,1))
W<-rpois(n,exp(2-0.6*z[,1]^2))
d<-as.data.frame(cbind(W,z))
names(d)<-c("W","z1","z2")

fit.func<-gppr(y="W",xterms=c("z1","z2"),data=d,family="poisson",
   nterms=2,max.terms=2)

# direction of axes, and their loadings
fit.func$alpha
fit.func$beta

## not run - plot ridge functions (linear predictor scale)
# par(mfrow=c(1,2))
# plot(fit.func)

Run the code above in your browser using DataLab