getPar0 {momentuHMM} | R Documentation |
Get starting values for new model from existing momentuHMM
or momentuHierHMM
model fit
Description
For nested models, this function will extract starting parameter values (i.e., Par0
in fitHMM
or MIfitHMM
) from an existing momentuHMM
or momentuHierHMM
model fit based on the provided arguments for the new model.
Any parameters that are not in common between model
and the new model (as specified by the arguments) are set to 0
. This function is intended to help users incrementally build and fit more complicated models from simpler nested models (and vice versa).
Usage
getPar0(model, ...)
## Default S3 method:
getPar0(
model,
nbStates = length(model$stateNames),
estAngleMean = model$conditions$estAngleMean,
circularAngleMean = model$conditions$circularAngleMean,
formula = model$conditions$formula,
formulaDelta = model$conditions$formulaDelta,
stationary = model$conditions$stationary,
mixtures = model$conditions$mixtures,
formulaPi = model$conditions$formulaPi,
DM = model$conditions$DM,
betaRef = model$conditions$betaRef,
stateNames = model$stateNames,
...
)
## S3 method for class 'hierarchical'
getPar0(
model,
hierStates = model$conditions$hierStates,
estAngleMean = model$conditions$estAngleMean,
circularAngleMean = model$conditions$circularAngleMean,
hierFormula = model$conditions$hierFormula,
hierFormulaDelta = model$conditions$hierFormulaDelta,
mixtures = model$conditions$mixtures,
formulaPi = model$conditions$formulaPi,
DM = model$conditions$DM,
...
)
Arguments
model |
A |
... |
further arguments passed to or from other methods |
nbStates |
Number of states in the new model. Default: |
estAngleMean |
Named list indicating whether or not the angle mean for data streams with angular
distributions ('vm' and 'wrpcauchy') are to be estimated in the new model. Default: |
circularAngleMean |
Named list indicating whether circular-linear or circular-circular
regression on the mean of circular distributions ('vm' and 'wrpcauchy') for turning angles are to be used in the new model. See |
formula |
Regression formula for the transition probability covariates of the new model (see |
formulaDelta |
Regression formula for the initial distribution covariates of the new model (see |
stationary |
|
mixtures |
Number of mixtures for the state transition probabilities (see |
formulaPi |
Regression formula for the mixture distribution probabilities (see |
DM |
Named list indicating the design matrices to be used for the probability distribution parameters of each data stream in the new model (see |
betaRef |
Numeric vector of length |
stateNames |
Character vector of length |
hierStates |
A hierarchical model structure |
hierFormula |
A hierarchical formula structure for the transition probability covariates for each level of the hierarchy (see |
hierFormulaDelta |
A hierarchical formula structure for the initial distribution covariates for each level of the hierarchy ('formulaDelta'). Default: |
Details
All other fitHMM
(or MIfitHMM
) model specifications (e.g., dist
, hierDist
, userBounds
, workBounds
, etc.) and data
are assumed to be the same
for model
and the new model (as specified by nbStates
, hierStates
, estAngleMean
, circularAngleMean
, formula
, hierFormula
, formulaDelta
, hierFormulaDelta
, DM
, etc.).
Note that for hierarchical models, getPar0
will return hierarchical data.tree objects (hierBeta
and hierDelta
) with the default values for fixPar
, betaCons
, and deltaCons
;
if hierarchical t.p.m. or initial distribution parameters are subject to constraints, then these must be set manually on the list object returned by getPar0
.
Value
A named list containing starting values suitable for Par0
and beta0
arguments in fitHMM
or MIfitHMM
:
Par |
A list of vectors of state-dependent probability distribution parameters for
each data stream specified in |
beta |
Matrix of regression coefficients for the transition probabilities |
delta |
Initial distribution of the HMM. Only returned if |
See Also
getPar
, getParDM
, fitHMM
, MIfitHMM
Examples
# model is a momentuHMM object, automatically loaded with the package
model <- example$m
data <- model$data
dist <- model$conditions$dist
nbStates <- length(model$stateNames)
estAngleMean <- model$conditions$estAngleMean
newformula <- ~cov1+cov2
Par0 <- getPar0(model,formula=newformula)
## Not run:
newModel <- fitHMM(model$data,dist=dist,nbStates=nbStates,
Par0=Par0$Par,beta0=Par0$beta,
formula=newformula,
estAngleMean=estAngleMean)
## End(Not run)
newDM1 <- list(step=list(mean=~cov1,sd=~cov1))
Par0 <- getPar0(model,DM=newDM1)
## Not run:
newModel1 <- fitHMM(model$data,dist=dist,nbStates=nbStates,
Par0=Par0$Par,beta0=Par0$beta,
formula=model$conditions$formula,
estAngleMean=estAngleMean,
DM=newDM1)
## End(Not run)
# same model but specify DM for step using matrices
newDM2 <- list(step=matrix(c(1,0,0,0,
"cov1",0,0,0,
0,1,0,0,
0,"cov1",0,0,
0,0,1,0,
0,0,"cov1",0,
0,0,0,1,
0,0,0,"cov1"),nrow=nbStates*2))
# to be extracted, new design matrix column names must match
# column names of model$conditions$fullDM
colnames(newDM2$step)<-paste0(rep(c("mean_","sd_"),each=2*nbStates),
rep(1:nbStates,each=2),
rep(c(":(Intercept)",":cov1"),2*nbStates))
Par0 <- getPar0(model,DM=newDM2)
## Not run:
newModel2 <- fitHMM(model$data,dist=dist,nbStates=nbStates,
Par0=Par0$Par,beta0=Par0$beta,
formula=model$conditions$formula,
estAngleMean=estAngleMean,
DM=newDM2)
## End(Not run)