w2nHSMM {PHSMM} | R Documentation |
Transforms unconstraint HSMM working parameters back into (constraint) natural parameters. Not intended to be run by the user (internal function, called by the functions pmleHSMM
and npllHSMM
).
w2nHSMM(N, parvect, R_vec, y_dist=c("norm","gamma","pois","bern"),
stationary=TRUE, p_ref=2)
N |
number of states of the HSMM, integer greater than 1. |
parvect |
vector of unconstraint working parameter as obtained by the function |
R_vec |
vector of length |
y_dist |
character determining the class of state-dependent distributions used to model the observations. Supported values are |
stationary |
Logical, if |
p_ref |
positive integer determining the reference dwell-time probability used for the multinomial logit parameter transformation. Default value is 2. Only needs to be changed if the dwell-time probability for dwell time r=2 is estimated very close to zero in order to avoid numerical problems. |
The function reverses the transformation of the function n2wHSMM
and back-transforms the unconstraint parameters into the constraint natural parameters. Note that if y_dist="gamma"
, mu
and sigma
do not include the mean values and standard deviations, but the shape and rate parameters as required by the density functions dgamma
and pgamma
. The mean and standard deviations are then assigned to mu2
and sigma2
.
A list containing the natural parameters
p_list |
list containing the dwell-time distribution vectors for each state. Each of the |
mu |
vector of length |
sigma |
vector of length |
omega |
conditional transition probability matrix of the HSMM. |
delta |
equilibrium distribution if |
d_r |
list containing the dwell-time probabilities of the unstructured starts. |
Gamma |
transition probability matrix of the HMM which represents the HSMM. |
# natural parameters for 2-state HSMM with state-dependent normal distributions
p_list0<-list() # list of dwell-time distribution vectors,
# vector elements must sum to one
p_list0[[1]]<-c(dgeom(0:9,0.2),1-pgeom(9,0.2))
p_list0[[2]]<-c(dgeom(0:9,0.1),1-pgeom(9,0.1))
mu0<-c(-10,10) # mean values
sigma0<-c(3,5) # standard deviations
# parameter transformation:
parvect<-n2wHSMM(N=2,p_list=p_list0,mu=mu0,sigma=sigma0,y_dist='norm',stationary=TRUE)
# back-transformation:
npar<-w2nHSMM(N=2,parvect=parvect,R_vec=sapply(p_list0,length)-1,y_dist='norm')