TheoMichelot / moveHMM

R package - Animal movement modelling using hidden Markov models
https://cran.r-project.org/package=moveHMM
38 stars 11 forks source link

`fitHMM()` documentation incorrectly describes `moveHMM` elements #28

Closed FlukeAndFeather closed 3 years ago

FlukeAndFeather commented 3 years ago

The documentation for fitHMM() says it returns a moveHMM object with elements stepDist and angleDist, but neither of these are present.

library(moveHMM)
#> Loading required package: CircStats
#> Loading required package: MASS
#> Loading required package: boot
### 1. simulate data
# define all the arguments of simData
nbAnimals <- 2
nbStates <- 2
nbCovs <- 2
mu<-c(15,50)
sigma<-c(10,20)
angleMean <- c(pi,0)
kappa <- c(0.7,1.5)
stepPar <- c(mu,sigma)
anglePar <- c(angleMean,kappa)
stepDist <- "gamma"
angleDist <- "vm"
zeroInflation <- FALSE
obsPerAnimal <- c(50,100)

data <- simData(nbAnimals=nbAnimals,nbStates=nbStates,stepDist=stepDist,angleDist=angleDist,
                stepPar=stepPar,anglePar=anglePar,nbCovs=nbCovs,zeroInflation=zeroInflation,
                obsPerAnimal=obsPerAnimal)

### 2. fit the model to the simulated data
# define initial values for the parameters
mu0 <- c(20,70)
sigma0 <- c(10,30)
kappa0 <- c(1,1)
stepPar0 <- c(mu0,sigma0) # no zero-inflation, so no zero-mass included
anglePar0 <- kappa0 # the angle mean is not estimated, so only the concentration parameter is needed
formula <- ~cov1+cos(cov2)

m <- fitHMM(data=data,nbStates=nbStates,stepPar0=stepPar0,anglePar0=anglePar0,formula=formula,
            stepDist=stepDist,angleDist=angleDist,angleMean=angleMean)
names(m)
#> [1] "data"        "mle"         "mod"         "conditions"  "rawCovs"    
#> [6] "knownStates"

Created on 2021-11-09 by the reprex package (v2.0.0)

TheoMichelot commented 3 years ago

You're right, stepDist and angleDist are now accessible as m$conditions$stepDist and m$conditions$angleDist. Thanks for pointing this out.