getParDM {momentuHMM} | R Documentation |
Get starting values on working scale based on design matrix and other parameter constraints
Description
Convert starting values on the natural scale of data stream probability distributions to a feasible set of working scale parameters based on a design matrix and other parameter constraints.
Usage
getParDM(data, ...)
## Default S3 method:
getParDM(
data = data.frame(),
nbStates,
dist,
Par,
zeroInflation = NULL,
oneInflation = NULL,
estAngleMean = NULL,
circularAngleMean = NULL,
DM = NULL,
userBounds = NULL,
workBounds = NULL,
...
)
## S3 method for class 'hierarchical'
getParDM(
data = data.frame(),
hierStates,
hierDist,
Par,
zeroInflation = NULL,
oneInflation = NULL,
estAngleMean = NULL,
circularAngleMean = NULL,
DM = NULL,
userBounds = NULL,
workBounds = NULL,
...
)
Arguments
data |
Optional If a data frame is provided, then either |
... |
further arguments passed to or from other methods |
nbStates |
Number of states of the HMM. |
dist |
A named list indicating the probability distributions of the data streams. Currently
supported distributions are 'bern', 'beta', 'exp', 'gamma', 'lnorm', 'norm', 'mvnorm2' (bivariate normal distribution), 'mvnorm3' (trivariate normal distribution),
'pois', 'rw_norm' (normal random walk), 'rw_mvnorm2' (bivariate normal random walk), 'rw_mvnorm3' (trivariate normal random walk), 'vm', 'vmConsensus', 'weibull', and 'wrpcauchy'. For example,
|
Par |
A named list containing vectors of state-dependent probability distribution parameters for
each data stream specified in |
zeroInflation |
A named list of logicals indicating whether the probability distributions of the data streams should be zero-inflated. If |
oneInflation |
Named list of logicals indicating whether the probability distributions of the data streams are one-inflated. If |
estAngleMean |
An optional named list indicating whether or not to estimate the angle mean for data streams with angular
distributions ('vm' and 'wrpcauchy'). Any |
circularAngleMean |
An optional named list indicating whether to use circular-linear or circular-circular
regression on the mean of circular distributions ('vm' and 'wrpcauchy') for turning angles. See |
DM |
A named list indicating the design matrices to be used for the probability distribution parameters of each data
stream. Each element of |
userBounds |
An optional named list of 2-column matrices specifying bounds on the natural (i.e, real) scale of the probability
distribution parameters for each data stream. For example, for a 2-state model using the wrapped Cauchy ('wrpcauchy') distribution for
a data stream named 'angle' with |
workBounds |
An optional named list of 2-column matrices specifying bounds on the working scale of the probability distribution, transition probability, and initial distribution parameters. For each matrix, the first column pertains to the lower bound and the second column the upper bound.
For data streams, each element of |
hierStates |
A hierarchical model structure |
hierDist |
A hierarchical data structure |
Details
If design matrix includes non-factor covariates, then natural scale parameters are assumed to correspond to the
mean value(s) for the covariate(s) (if nrow(data)>1
) and getParDM
simply returns one possible solution to the
system of linear equations defined by Par
, DM
, and any other constraints using singular value decomposition.
This can be helpful for exploring relationships between the natural and working scale parameters when covariates are included, but getParDM
will not necessarily return “good” starting values (i.e., Par0
) for fitHMM
or MIfitHMM
.
Value
A list of parameter values that can be used as starting values (Par0
) in fitHMM
or MIfitHMM
See Also
getPar
, getPar0
, fitHMM
, MIfitHMM
Examples
# data is a momentuHMMData object, automatically loaded with the package
data <- example$m$data
stepDist <- "gamma"
angleDist <- "vm"
nbStates <- 2
stepPar0 <- c(15,50,10,20) # natural scale mean_1, mean_2, sd_1, sd_2
anglePar0 <- c(0.7,1.5) # natural scale conentration_1, concentration_2
# get working parameters for 'DM' that constrains step length mean_1 < mean_2
stepDM <- matrix(c(1,1,0,0,0,1,0,0,0,0,1,0,0,0,0,1),4,4,
dimnames=list(NULL,c("mean:(Intercept)","mean_2",
"sd_1:(Intercept)","sd_2:(Intercept)")))
stepworkBounds <- matrix(c(-Inf,Inf),4,2,byrow=TRUE,
dimnames=list(colnames(stepDM),c("lower","upper")))
stepworkBounds["mean_2","lower"] <- 0 #coefficient for 'mean_2' constrained to be positive
wPar0 <- getParDM(nbStates=2,dist=list(step=stepDist),
Par=list(step=stepPar0),
DM=list(step=stepDM),workBounds=list(step=stepworkBounds))
## Not run:
# Fit HMM using wPar0 as initial values for the step data stream
mPar <- fitHMM(data,nbStates=2,dist=list(step=stepDist,angle=angleDist),
Par0=list(step=wPar0$step,angle=anglePar0),
DM=list(step=stepDM),workBounds=list(step=stepworkBounds))
## End(Not run)
# get working parameters for 'DM' using 'cov1' and 'cov2' covariates
stepDM2 <- list(mean=~cov1,sd=~cov2)
wPar20 <- getParDM(data,nbStates=2,dist=list(step=stepDist),
Par=list(step=stepPar0),
DM=list(step=stepDM2))
## Not run:
# Fit HMM using wPar20 as initial values for the step data stream
mPar2 <- fitHMM(data,nbStates=2,dist=list(step=stepDist,angle=angleDist),
Par0=list(step=wPar20$step,angle=anglePar0),
DM=list(step=stepDM2))
## End(Not run)