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

> ### Name: simData
> ### Title: Simulation tool
> ### Aliases: simData
> 
> ### ** Examples
> 
> # 1. Pass a fitted model to simulate from
> # (m is a momentuHMM object - as returned by fitHMM - automatically loaded with the package)
> # We keep the default nbAnimals=1.
> m <- example$m
> obsPerAnimal=c(50,100)
> data <- simData(model=m,obsPerAnimal=obsPerAnimal)
=======================================================================
Simulating HMM with 2 states and 2 data streams
-----------------------------------------------------------------------

 step ~ gamma(mean=~1, sd=~1)
 angle ~ vm(mean=~1, concentration=~1)

 Transition probability matrix formula: ~cov1 + cos(cov2)

 Initial distribution formula: ~1
=======================================================================
DONE
> 
> # 2. Pass the parameters of the model to simulate from
> stepPar <- c(1,10,1,5,0.2,0.3) # mean_1, mean_2, sd_1, sd_2, zeromass_1, zeromass_2
> anglePar <- c(pi,0,0.5,2) # mean_1, mean_2, concentration_1, concentration_2
> omegaPar <- c(1,10,10,1) # shape1_1, shape1_2, shape2_1, shape2_2
> stepDist <- "gamma"
> angleDist <- "vm"
> omegaDist <- "beta"
> data <- simData(nbAnimals=4,nbStates=2,dist=list(step=stepDist,angle=angleDist,omega=omegaDist),
+                 Par=list(step=stepPar,angle=anglePar,omega=omegaPar),nbCovs=2,
+                 zeroInflation=list(step=TRUE),
+                 obsPerAnimal=obsPerAnimal)
=======================================================================
Simulating HMM with 2 states and 3 data streams
-----------------------------------------------------------------------

 step ~ gamma(mean=~1, sd=~1, zeromass=~1)
 angle ~ vm(mean=~1, concentration=~1)
 omega ~ beta(shape1=~1, shape2=~1)

 Transition probability matrix formula: ~1

 Initial distribution formula: ~1
=======================================================================
DONE
> 
> # 3. Include covariates
> # (note that it is useless to specify "nbCovs", which are overruled
> # by the number of columns of "cov")
> cov <- data.frame(temp=log(rnorm(500,20,5)))
> stepPar <- c(log(10),0.1,log(100),-0.1,log(5),log(25)) # working scale parameters for step DM
> anglePar <- c(pi,0,0.5,2) # mean_1, mean_2, concentration_1, concentration_2
> stepDist <- "gamma"
> angleDist <- "vm"
> data <- simData(nbAnimals=2,nbStates=2,dist=list(step=stepDist,angle=angleDist),
+                 Par=list(step=stepPar,angle=anglePar),
+                 DM=list(step=list(mean=~temp,sd=~1)),
+                 covs=cov,
+                 obsPerAnimal=obsPerAnimal)
=======================================================================
Simulating HMM with 2 states and 2 data streams
-----------------------------------------------------------------------

 step ~ gamma(mean=~temp, sd=~1)
 angle ~ vm(mean=~1, concentration=~1)

 Transition probability matrix formula: ~1

 Initial distribution formula: ~1
=======================================================================
DONE
>                 
> # 4. Include example 'forest' spatial covariate raster layer
> # nbAnimals and obsPerAnimal kept small to reduce example run time
> spatialCov<-list(forest=forest)
> data <- simData(nbAnimals=1,nbStates=2,dist=list(step=stepDist,angle=angleDist),
+                 Par=list(step=c(100,1000,50,100),angle=c(0,0,0.1,5)),
+                 beta=matrix(c(5,-10,-25,50),nrow=2,ncol=2,byrow=TRUE),
+                 formula=~forest,spatialCovs=spatialCov,
+                 obsPerAnimal=250,states=TRUE,
+                 retrySims=100)
=======================================================================
Simulating HMM with 2 states and 2 data streams
-----------------------------------------------------------------------

 step ~ gamma(mean=~1, sd=~1)
 angle ~ vm(mean=~1, concentration=~1)

 Transition probability matrix formula: ~forest

 Initial distribution formula: ~1
=======================================================================
Attempting to simulate tracks within spatial extent(s) of raster layers(s). Press 'esc' to force exit from 'simData'

    Attempt 1 of 100...DONE
>                 
> # 5. Specify design matrix for 'omega' data stream
> # natural scale parameters for step and angle
> stepPar <- c(1,10,1,5) # shape_1, shape_2, scale_1, scale_2
> anglePar <- c(pi,0,0.5,0.7) # mean_1, mean_2, concentration_1, concentration_2
> 
> # working scale parameters for omega DM
> omegaPar <- c(log(1),0.1,log(10),-0.1,log(10),-0.1,log(1),0.1)
> 
> stepDist <- "weibull"
> angleDist <- "wrpcauchy"
> omegaDist <- "beta"
> 
> data <- simData(nbStates=2,dist=list(step=stepDist,angle=angleDist,omega=omegaDist),
+                 Par=list(step=stepPar,angle=anglePar,omega=omegaPar),nbCovs=2,
+                 DM=list(omega=list(shape1=~cov1,shape2=~cov2)),
+                 obsPerAnimal=obsPerAnimal,states=TRUE)
=======================================================================
Simulating HMM with 2 states and 3 data streams
-----------------------------------------------------------------------

 step ~ weibull(shape=~1, scale=~1)
 angle ~ wrpcauchy(mean=~1, concentration=~1)
 omega ~ beta(shape1=~cov1, shape2=~cov2)

 Transition probability matrix formula: ~1

 Initial distribution formula: ~1
=======================================================================
DONE
>                 
> # 6. Include temporal irregularity and location measurement error
> lambda <- 2 # expect 2 observations per time step
> errorEllipse <- list(M=50,m=25,r=180)
> obsData <- simData(model=m,obsPerAnimal=obsPerAnimal,
+                    lambda=lambda, errorEllipse=errorEllipse)
=======================================================================
Simulating HMM with 2 states and 2 data streams
-----------------------------------------------------------------------

 step ~ gamma(mean=~1, sd=~1)
 angle ~ vm(mean=~1, concentration=~1)

 Transition probability matrix formula: ~cov1 + cos(cov2)

 Initial distribution formula: ~1
=======================================================================
DONE
>                    
> # 7. Cosinor and state-dependent formulas
> nbStates<-2
> dist<-list(step="gamma")
> Par<-list(step=c(100,1000,50,100))
> 
> # include 24-hour cycle on all transition probabilities
> # include 12-hour cycle on transitions from state 2
> formula=~cosinor(hour24,24)+state2(cosinor(hour12,12))
> 
> # specify appropriate covariates
> covs<-data.frame(hour24=0:23,hour12=0:11)
> 
> beta<-matrix(c(-1.5,1,1,NA,NA,-1.5,-1,-1,1,1),5,2)
> # row names for beta not required but can be helpful
> rownames(beta)<-c("(Intercept)",
+                   "cosinorCos(hour24, 24)",
+                   "cosinorSin(hour24, 24)",
+                   "cosinorCos(hour12, 12)",
+                   "cosinorSin(hour12, 12)")
> data.cos<-simData(nbStates=nbStates,dist=dist,Par=Par,
+                   beta=beta,formula=formula,covs=covs)     
=======================================================================
Simulating HMM with 2 states and 1 data streams
-----------------------------------------------------------------------

 step ~ gamma(mean=~1, sd=~1)

 Transition probability matrix formula: ~cosinor(hour24, 24) + state2(cosinor(hour12, 12))

 Initial distribution formula: ~1
=======================================================================
DONE
>                   
> # 8. Piecewise constant B-spline on step length mean and angle concentration
> library(splines2)
> nObs <- 1000 # length of simulated track
> cov <- data.frame(time=1:nObs) # time covariate for splines
> dist <- list(step="gamma",angle="vm")
> stepDM <- list(mean=~bSpline(time,df=3,degree=0),sd=~1)
> angleDM <- list(mean=~1,concentration=~bSpline(time,df=3,degree=0))
> DM <- list(step=stepDM,angle=angleDM)
> Par <- list(step=c(log(1000),1,-1,log(100)),angle=c(0,log(10),2,-5))
> 
> data.spline<-simData(obsPerAnimal=nObs,nbStates=1,dist=dist,Par=Par,DM=DM,covs=cov)        
=======================================================================
Simulating HMM with 1 states and 2 data streams
-----------------------------------------------------------------------

 step ~ gamma(mean=~bSpline(time, df = 3, degree = 0), sd=~1)
 angle ~ vm(mean=~1, concentration=~bSpline(time, df = 3, degree = 0))

 Transition probability matrix formula: ~1

 Initial distribution formula: ~1
=======================================================================
Error in getDM(subCovs, inputs$DM, inputs$dist, nbStates, p$parNames,  : 
  Dimension mismatch between Par and DM for: step, angle
Calls: simData -> getDM
Execution halted