Use slice samplingbased Markov chain Monte Carlo to fit a generalized additive mixed model.
1 
formula 
Formula describing the generalized additive mixed model. 
data 
Data frame containing the input data. 
random 
List describing random effects structure. This argument is optional. 
family 
Distribution family of the response variable. Options are "binomial" and "poisson". 
control 
Control options specified by gSlc.control. 
A Bayesian generalized additive mixed model is fitted to the input data according to specified formula. Such models are special cases of the general design generalized linear mixed models of Zhao, Staudenmayer, Coull and Wand (2003). Markov chain Monte Carlo, with slice sampling for the fixed and random effects, is used to obtain samples from the posterior distributions of the model parameters. Full details of the sampling scheme are in the appendix of Pham and Wand (2012).
nu 
Matrix containing the MCMC samples for the combined fixed
effects and random effects vectors. Each column of 
beta 
Matrix containing the MCMC samples for the fixed effects vector. 
u 
Matrix containing the MCMC samples for the random effects
vector. If the model contains smooth function components then

sigmaSquared 
Matrix contain of variances. 
scaledData 
The scaled data set was used to fit in. 
formulaInfor 
Information obtained from the formula. 
timeTaken 
Time in seconds taken by the MCMC sampling. 
Xmin 
The minimum values of each predictor variable. 
Xmax 
The maximum values of each predictor variable. 
Xrange 
The difference between Xmax and Xmin. 
Tung Pham tung.pham@epfl.ch and Matt Wand matt.wand@uts.edu.au
Neal, R.M. (2003).
Slice sampling (with discussion).
The Annals of Statistics, 31, 705767.
Pham, T. and Wand, M.P. (2012).
Generalized additive mixed model analysis via gammSlice
.
Submitted.
Zhao, Y., Staudenmayer, J., Coull, B.A. and Wand, M.P. (2003).
General design Bayesian generalized linear mixed models.
Statistical Science, 21, 3551.
gSlc.control
, plot.gSlc
, summary.gSlc
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43  ## Not run:
library(mgcv)
dat0 < gamSim(eg=1, n=500, scale = 0.2, dist = "poisson")
fit0 < gSlc( y~s(x0) + s(x1) + s(x2) + s(x3), family = "poisson", data = dat0)
plot(fit0,pages = 1)
summary(fit0)
dat1 < gamSim(eg=6, n = 400,scale = 0.1, dist = "poisson")
fit1 < gSlc(y ~ s(x0) + s(x1) + s(x2) + s(x3), family = "poisson",
data = dat1, random = list(fac=~1))
plot(fit1,pages=2)
summary(fit1)
dat2 < gSlcSim(eg = 2, numGrp = 200, family = "poisson",
randomFactor = FALSE)
fit2 < gSlc(y~x1 + x2, family = "poisson", data = dat2)
summary(fit2)
dat3 < gSlcSim(eg = 3,numGrp = 1000, family = "binomial",
randomFactor = FALSE)
fit3 < gSlc(y~s(x1),family = "binomial", data = dat3)
plot(fit3)
summary(fit3)
fit3a < gSlc(y~s(x1,nBasis=10),family = "binomial",
data = dat3)
plot(fit3a)
summary(fit3a)
dat4 < gSlcSim(eg = 4, numGrp = 400, family = "poisson",
randomFactor = FALSE)
fit4 < gSlc(y~x1 + s(x2), family = "poisson", data = dat4)
plot(fit4)
summary(fit4)
dat5 < gSlcSim(eg=6,family = "poisson", randomFactor = TRUE)
fit5 < gSlc(y~x1 + x2 + s(x3) + s(x4), random = list(idnum=~1),
family = "poisson", data = dat5)
plot(fit5)
summary(fit5)
## End(Not run)

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
Please suggest features or report bugs with the GitHub issue tracker.
All documentation is copyright its authors; we didn't write any of that.