Running examples in ‘RCPmod-Ex.R’ failed
The error most likely occurred in:

> ### Name: cooks.distance.regimix
> ### Title: Calculates leave-some-out statistics for a regimix object,
> ###   principally a version of Cook's distance and cross-validated
> ###   predictive logl
> ### Aliases: cooks.distance.regimix
> ### Keywords: misc
> 
> ### ** Examples
> 
> ## Not run: 
> ##D #not run as R CMD check complains about the time taken.
> ##D #This code will take a little while to run (about 0.5 minutes on my computer)
> ##D #For leave-one-out cooks distance, use oosSize=1
> ##D #for serious use times will need to be larger.
> ##D system.time({
> ##D example( regimix);
> ##D cooksD <- cooks.distance( fm, oosSize=10, times=25)
> ##D })
> ## End(Not run)
> example( regimix)  #will fit a model and store in fm

regimx> #simulate data
regimx> example( simRCPdata)  #generates Negative Binomial data

smRCPd> #generates synthetic data
smRCPd> set.seed( 151)

smRCPd> n <- 100

smRCPd> S <- 10

smRCPd> nRCP <- 3

smRCPd> my.dist <- "NegBin"

smRCPd> X <- as.data.frame( cbind( x1=runif( n, min=-10, max=10), x2=runif( n, min=-10, max=10)))

smRCPd> Offy <- log( runif( n, min=30, max=60))

smRCPd> pols <- list()

smRCPd> pols[[1]] <- poly( X$x1, degree=3)

smRCPd> #important to scale covariates so that regimix can get half-way decent starting values
smRCPd> pols[[2]] <- poly( X$x2, degree=3)

smRCPd> X <- as.matrix( cbind( 1, X, pols[[1]], pols[[2]]))

smRCPd> colnames( X) <- c("const", 'x1', 'x2', paste( "x1",1:3,sep='.'), paste( "x2",1:3,sep='.'))

smRCPd> p.x <- ncol( X[,-(2:3)])

smRCPd> p.w <- 3

smRCPd> W <- matrix(sample( c(0,1), size=(n*p.w), replace=TRUE), nrow=n, ncol=p.w)

smRCPd> colnames( W) <- paste( "w",1:3,sep=".")

smRCPd> alpha <- rnorm( S)

smRCPd> tau.var <- 0.5

smRCPd> b <- sqrt( tau.var/2)

smRCPd> #a double exponential for RCP effects
smRCPd> tau <- matrix( rexp( n=(nRCP-1)*S, rate=1/b) - rexp( n=(nRCP-1)*S, rate=1/b), nrow=nRCP-1, ncol=S)

smRCPd> beta <- 0.2 * matrix( c(-1.2, -2.6, 0.2, -23.4, -16.7, -18.7, -59.2, -76.0, -14.2, -28.3,
smRCPd+   -36.8, -17.8, -92.9,-2.7), nrow=nRCP-1, ncol=p.x)

smRCPd> gamma <- matrix( rnorm( S*p.w), ncol=p.w, nrow=S)

smRCPd> logDisp <- log( rexp( S, 1))

smRCPd> set.seed(121)

smRCPd> simDat <- simRCPdata( nRCP=nRCP, S=S, p.x=p.x, p.w=p.w, n=n, alpha=alpha, tau=tau,
smRCPd+   beta=beta, gamma=gamma, X=X[,-(2:3)], W=W, dist=my.dist, logDisp=logDisp, offset=Offy)

regimx> #fit the model
regimx> my.form.RCP <- paste( paste( paste(
regimx+   'cbind(', paste( paste( 'spp', 1:S, sep=''), collapse=','), sep=''),
regimx+     ')',sep=''),
regimx+        '~x1.1+x1.2+x1.3+x2.1+x2.2+x2.3',sep='')

regimx> my.form.spp <- ~w.1+w.2+w.3

regimx> fm <- regimix( form.RCP = my.form.RCP, form.spp=my.form.spp, data = simDat,
regimx+                   dist="NegBin", nRCP = 3, inits = "random2", offset=offset)
RCP modelling
There are: 3RCPs to group the sites into
There are 100 fully present observations and 100 observations in total
There are 10 species
The model for the (latent) RCP classes is: ~x1.1 + x1.2 + x1.3 + x2.1 + x2.2 + x2.3
The model for each species is: ~w.1 + w.2 + w.3
The error distribution is: NegBin
Obtaining starting values...
Error: No newoffset provided for prediction, yet offset used in fit of glmnet
Execution halted