# n2wHSMM: Parameter transformation from natural to working parameters In PHSMM: Penalised Maximum Likelihood Estimation for Hidden Semi-Markov Models

## Description

Parameter transformation from the natural (constraint) HSMM parameters into unconstraint working parameters which are used in the numerical maximum likelihood estimation. Not intended to be run by the user (internal function, called by the function `pmleHSMM`).

## Usage

 ```1 2``` ```n2wHSMM(N, p_list, mu, sigma=NULL, omega=NULL, delta=NULL, y_dist=c("norm","gamma","pois","bern"), stationary=TRUE, p_ref=2) ```

## Arguments

 `N` number of states of the HSMM, integer greater than 1. `p_list` list containing the parameters of the states' dwell-time distributions. The list consists of `N` probability vectors, i.e. one vector for each state. Each probability vector 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 must sum to one and automatically determines the length of the unstructured start of the according state dwell-time distribution. `mu` vector of length `N` containing the state-dependent mean values if gamma, normal or Poisson distributions are chosen and the state-dependent probabilities if the Bernoulli distribution is chosen. The values must be sorted in an ascending order. `sigma` vector of length `N` containing the state-dependent standard deviations if gamma or normal distributions are chosen. `NULL` (default) otherwise. `omega` conditional transition probability matrix of the underlying semi-Markov chain. Only needed if the number of states is greater than 2, `NULL` (default) otherwise. In the former case, `omega` is a matrix with `N` rows and `N` columns, its diagonal elements must be zero and its rows must sum to one. `delta` vector of length N containing the initial distribution. Only needed if `stationary=FALSE`, otherwise delta is ignored and can be set to `NULL` (default). `y_dist` character determining the class of state-dependent distributions. 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 and it is necessary to define the initial distribution `delta`. `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 transformation from natural to working parameters is needed to carry out an unconstraint optimisation. The function includes log-transformations for positive parameters and (multinomial) logit-transformations for probabilities, probability vectors and matrices.

## Value

A vector of unconstraint working parameters characterising the HSMM.

## Examples

 ```1 2 3 4 5 6 7 8 9``` ```# 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[]<-c(dgeom(0:9,0.2),1-pgeom(9,0.2)) p_list0[]<-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: n2wHSMM(N=2,p_list=p_list0,mu=mu0,sigma=sigma0,y_dist='norm',stationary=TRUE) ```

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