w2nHSMM: Parameter transformation from working to natural parameters

Description Usage Arguments Details Value Examples

View source: R/w2nHSMM.R

Description

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).

Usage

1
2
w2nHSMM(N, parvect, R_vec, y_dist=c("norm","gamma","pois","bern"),
      stationary=TRUE, p_ref=2)

Arguments

N

number of states of the HSMM, integer greater than 1.

parvect

vector of unconstraint working parameter as obtained by the function n2wHSMM.

R_vec

vector of length N containing the lengths of the unstructured starts of the dwell-time distributions.

y_dist

character determining the class of state-dependent distributions used to model the observations. Supported values are "norm" (normal distribution), "gamma" (gamma distribution), "pois" (Poisson distribution) and "bern" (Bernoulli distribution).

stationary

Logical, if TRUE (default), stationarity is assumed, if FALSE, the underlying state-sequence is assumed to enter a new state at time t=1.

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.

Details

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.

Value

A list containing the natural parameters

p_list

list containing the dwell-time distribution vectors for each state. Each of the N vectors contains the state dwell-time probabilities for the unstructured start and, as last element, the probability mass captured in the geometric tail. Thus, each vector sums to one.

mu

vector of length N. For y_dist="norm" and y_dist="pois", it contains the state-dependent mean values, for y_dist="gamma", it contains the state-dependent shape parameters, and for y_dist="bern", it contains the state-dependent probabilities.

sigma

vector of length N containing the state-dependent standard deviations if y_dist="norm" and the state-dependent rates if y_dist="gamma". NULL otherwise.

omega

conditional transition probability matrix of the HSMM.

delta

equilibrium distribution if stationary=TRUE, initial distribution of length N if stationary=FALSE.

d_r

list containing the dwell-time probabilities of the unstructured starts.

Gamma

transition probability matrix of the HMM which represents the HSMM.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# 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')

PHSMM documentation built on Feb. 9, 2021, 5:07 p.m.

Related to w2nHSMM in PHSMM...