<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Publishing DTD v1.2 20190208//EN" "http://jats.nlm.nih.gov/publishing/1.2/JATS-journalpublishing1.dtd"><article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" article-type="research-article" dtd-version="1.2" xml:lang="en">
    <front>
        <journal-meta>
            <journal-id journal-id-type="pmc">F1000Research</journal-id>
            <journal-title-group>
                <journal-title>F1000Research</journal-title>
            </journal-title-group>
            <issn pub-type="epub">2046-1402</issn>
            <publisher>
                <publisher-name>F1000 Research Limited</publisher-name>
                <publisher-loc>London, UK</publisher-loc>
            </publisher>
        </journal-meta>
        <article-meta>
            <article-id pub-id-type="doi">10.12688/f1000research.9746.1</article-id>
            <article-categories>
                <subj-group subj-group-type="heading">
                    <subject>Research Article</subject>
                </subj-group>
                <subj-group>
                    <subject>Articles</subject>
                    <subj-group>
                        <subject>Epilepsy</subject>
                    </subj-group>
                    <subj-group>
                        <subject>Methods of Clinical Decision-Making</subject>
                    </subj-group>
                </subj-group>
            </article-categories>
            <title-group>
                <article-title>A hidden Markov model analysis of subject-specific seizure time-series data as a potential aid to clinical decision making</article-title>
                <fn-group content-type="pub-status">
                    <fn>
                        <p>[version 1; peer review: peer review discontinued]</p>
                    </fn>
                </fn-group>
            </title-group>
            <contrib-group>
                <contrib contrib-type="author" corresp="yes">
                    <name>
                        <surname>King</surname>
                        <given-names>Martin D.</given-names>
                    </name>
                    <xref ref-type="corresp" rid="c1">a</xref>
                    <xref ref-type="aff" rid="a1">1</xref>
                </contrib>
                <contrib contrib-type="author" corresp="no">
                    <name>
                        <surname>Pujar</surname>
                        <given-names>Suresh</given-names>
                    </name>
                    <xref ref-type="aff" rid="a2">2</xref>
                    <xref ref-type="aff" rid="a3">3</xref>
                </contrib>
                <contrib contrib-type="author" corresp="no">
                    <name>
                        <surname>Scott</surname>
                        <given-names>Rod C.</given-names>
                    </name>
                    <xref ref-type="aff" rid="a2">2</xref>
                    <xref ref-type="aff" rid="a3">3</xref>
                    <xref ref-type="aff" rid="a4">4</xref>
                </contrib>
                <aff id="a1">
                    <label>1</label>Developmental Imaging and Biophysics, UCL Great Ormond Street Institute of Child Health, London, UK</aff>
                <aff id="a2">
                    <label>2</label>Developmental Neurosciences Unit, UCL Great Ormond Street Institute of Child Health, London, UK</aff>
                <aff id="a3">
                    <label>3</label>Great Ormond Street Hospital for Children National Health Service Trust, London, UK</aff>
                <aff id="a4">
                    <label>4</label>College of Medicine, University of Vermont, Burlington, USA</aff>
            </contrib-group>
            <author-notes>
                <corresp id="c1">
                    <label>a</label>
                    <email xlink:href="mailto:martin.king@ucl.ac.uk">martin.king@ucl.ac.uk</email>
                </corresp>
                <fn fn-type="con">
                    <p>MDK conceived, designed and performed the analyses, in addition to writing the statistical modelling parts of the manuscript. RS formulated the clinical application and wrote the clinical parts of the manuscript. SP collected the clinical data, compiled the seizure diaries and approved the manuscript.</p>
                </fn>
                <fn fn-type="conflict">
                    <p>
                        <bold>Competing interests: </bold>No competing interests were disclosed.</p>
                </fn>
            </author-notes>
            <pub-date pub-type="epub">
                <day>28</day>
                <month>10</month>
                <year>2016</year>
            </pub-date>
            <pub-date pub-type="collection">
                <year>2016</year>
            </pub-date>
            <volume>5</volume>
            <elocation-id>2592</elocation-id>
            <history>
                <date date-type="accepted">
                    <day>17</day>
                    <month>10</month>
                    <year>2016</year>
                </date>
            </history>
            <permissions>
                <copyright-statement>Copyright: &#x00a9; 2016 King MD et al.</copyright-statement>
                <copyright-year>2016</copyright-year>
                <license xlink:href="https://creativecommons.org/licenses/by/4.0/">
                    <license-p>This is an open access article distributed under the terms of the Creative Commons Attribution Licence, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.</license-p>
                </license>
            </permissions>
            <self-uri content-type="pdf" xlink:href="https://f1000research.com/articles/5-2592/pdf"/>
            <abstract>
                <p>
                    <bold>Background</bold> The seizure-count time series data acquired from three children with refractory epilepsy were used in a statistical modelling analysis designed to provide an explanation for the marked variation in seizure frequency that often occurs over time (over-dispersed Poisson behaviour). This was motivated by an expectation that a better understanding of the spontaneous shifts in seizure-activity that are observed in some cases should reduce the risk of over-treatment caused by inappropriate changes in medication.</p>
                <p>
                    <bold>Methods</bold> The analyses were performed using Poisson hidden Markov models (HMMs), both Bayesian and non-Bayesian, implemented using Markov chain Monte Carlo and the expectation-maximisation algorithm, respectively. A defining feature of the models, as applied to epilepsy, is the assumed existence of two or more pathological states, with state-specific Poisson rates, and random transitions between the states. Posterior predictive simulation was used to assess the validity of the Bayesian HMMs.</p>
                <p>
                    <bold>Results</bold> The results are presented in the form of state transition probability and Poisson rate estimates (i.e., the primary HMM parameters), together with information derived from these primary parameters. State-specific mean-duration (sojourn time) estimates and sojourn-time complementary cumulative probability distributions are the main focus. HMM analyses are presented for three children that differed markedly in their seizure behaviour. The first is characterised by an extreme seizure count on one occasion; the second underwent a spontaneous decrease in seizure activity during the observation period; the third seizure-count time trajectory is characterised by a gradual change in mean seizure activity. We show that, despite their considerable differences, each of the observed seizure-count trajectories can be treated adequately using an HMM.</p>
                <p>
                    <bold>Conclusions</bold> The study demonstrates that clinically relevant information can be obtained using HM modelling in three cases with markedly different seizure behaviour. The resulting subject-specific statistics provide useful clinical insights which should aid those engaged in clinical decision making.</p>
            </abstract>
            <kwd-group kwd-group-type="author">
                <kwd>Refractory epilepsy</kwd>
                <kwd>seizure-count time series</kwd>
                <kwd>Hidden Markov model (HMM)</kwd>
                <kwd>Bayesian analysis</kwd>
                <kwd>Markov chain Monte Carlo (MCMC)</kwd>
                <kwd>Poisson rates</kwd>
                <kwd>transition probabilities</kwd>
                <kwd>sojourn-time cumulative distributions</kwd>
                <kwd>Prediction</kwd>
            </kwd-group>
            <funding-group>
                <funding-statement>The author(s) declared that no grants were involved in supporting this work.</funding-statement>
            </funding-group>
        </article-meta>
    </front>
    <body>
        <sec sec-type="intro">
            <title>Introduction</title>
            <p>Epilepsy is the most common severe neurological disorder in children. Treatment with antiepileptic medication is effective in rendering approximately 70% of children seizure free. The remaining 30% often have multiple therapeutic trials and frequently are managed with multiple drugs simultaneously, increasing the likelihood of side-effects. The failure to become seizure free after 3&#x2013;4 antiepileptic drug trials reduces the likelihood of an individual becoming seizure free with any subsequent trial to less than 5%
                <sup>
                    <xref ref-type="bibr" rid="ref-1">1</xref>
                </sup>. As a consequence, the treatment goal usually changes at this stage to modification of seizure frequency rather than seizure freedom. It can be difficult to determine whether a change in seizure frequency has occurred following a change in medication, given the acceptance that these children have periods of better seizure control and worse seizure control which are not a function of medical intervention. An understanding of the natural fluctuations of a seizure disorder in an individual would enable physicians to manage therapeutic trials more effectively and allow a more precise assessment of whether a therapeutic intervention has caused an altered seizure pattern in a way that could lead to improvements in quality of life
                <sup>
                    <xref ref-type="bibr" rid="ref-2">2</xref>
                </sup>.</p>
            <p>Statistical process control has been used for seizure frequency monitoring
                <sup>
                    <xref ref-type="bibr" rid="ref-3">3</xref>
                </sup>, but this approach does not enable the physician to predict future patterns. Predictive information would allow the patient and family to recognise seizure patterns that are unexpected, and suggest when medical intervention could be warranted. Patients differ enormously in their individual seizure patterns and a reliable statistical tool that can be applied to different seizure patterns is critical for the development of appropriate treatment strategies.</p>
            <p>Hidden Markov models (HMMs) provide an approach to seizure-count time-series analysis and seizure prediction (see, for example, 
                <xref ref-type="bibr" rid="ref-4">4</xref>&#x2013;
                <xref ref-type="bibr" rid="ref-7">7</xref>). The key idea is the assumed existence of two or more disease states, with random transitions between them. These disease states are hidden, but the observed data (seizure counts) provide an indicator of these hidden states. Between-state switches occur according to a probabilistic rule. The transition probabilities and state-specific Poisson seizure rates constitute the model parameters, which are estimated by fitting the observed data. A more complete but informal description of the HMM approach to modelling seizure count data is given below, together with the more formal treatment provided in 
                <xref ref-type="sec" rid="N1">Note S1</xref>. A hidden Markov model schematic is provided in 
                <xref ref-type="fig" rid="f1">Figure 1</xref>.</p>
            <fig fig-type="figure" id="f1" orientation="portrait" position="float">
                <label>Figure 1. </label>
                <caption>
                    <title>A schematic illustrating a hidden Markov model.</title>
                    <p>The model consists of two time series, the first of which is an unobserved Markov chain, 
                        <italic toggle="yes">Z
                            <sub>t</sub>
                        </italic>, while the second is the state-dependent observed process, 
                        <italic toggle="yes">y
                            <sub>t</sub>
                        </italic>. Given an m-state hidden Markov model, on each occasion 
                        <italic toggle="yes">Z
                            <sub>t</sub>
                        </italic> takes on a value 
                        <italic toggle="yes">i</italic>, 
                        <italic toggle="yes">i</italic> = 1, &#x2026;, 
                        <italic toggle="yes">m</italic>, where 
                        <italic toggle="yes">i</italic> is a state label.</p>
                </caption>
                <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/10507/5b001739-d79d-4ffb-ab46-190631b22c0a_figure1.gif"/>
            </fig>
            <p>In this study we describe the application of HMMs, both Bayesian and non-Bayesian, to the analysis of seizure count data acquired from children with severe epilepsy. The Bayesian analyses were implemented using Markov chain Monte Carlo (MCMC) while the non-Bayesian HMM analyses were performed using the expectation-maximisation (EM) algorithm. Posterior predictive simulation was used to assess the validity of the Bayesian models.</p>
            <p>We show the results obtained from a detailed analysis of the seizure data collected from three children that differed markedly in their time-dependent seizure activity. In addition to their marked dissimilarity in seizure behaviour, these children were selected because no change in medication occurred during the observation period. The model parameter estimates, taken together with the other information derived from the model, are shown to be clinically informative.</p>
            <sec>
                <title>Hidden Markov models</title>
                <p>The analyses outlined in this study were undertaken using so-called discrete-time Poisson hidden-state Markov models. The basic notion is that the observations are a discrete time-series consisting of seizure counts, observed on a number of consecutive occasions. The central premise is that the observations emanate from an underlying system that switches between states, as illustrated in 
                    <xref ref-type="fig" rid="f1">Figure 1</xref>. In some applications this assumption might be based on established theory. An alternative motivation for adopting an HM model for count data is as an empirical approach to dealing with overdispersion, i.e., the condition where the count data has a variance that is greater than the expected variance under the Poisson model. Although the present application belongs to the latter category, the possibility remains that an HM process is a realistic representation of the underlying physiological process that gives rise to the observed seizure behaviour. The key idea is that the observed counts are all that is available in terms of observable data and that the underlying process is hidden.</p>
                <p>The HMM assumes that the hidden state switches (transitions) occur according to a probabilistic rule. More specifically it is assumed that the hidden states behave as a discrete-time Markov process. A Poisson HMM assigns differing Poisson rates to each of the underlying hidden states. Thus, as the system switches between states, the rates at which the observed events occur (seizures in the present application) are altered, hence the overdispersion. The challenge is to extract information about the hidden Markov process given the observed counts. Additional information is given in 
                    <xref ref-type="sec" rid="N1">Note S1</xref>, which provides a more formal description.</p>
            </sec>
            <sec>
                <title>Local and global decoding; seizure-state duration/sojourn time</title>
                <p>An important feature of epilepsy seizure-count HM modelling is the potential to provide information regarding the state of the subject on a given occasion. In speech recognition and other applications this is referred to as decoding. Two types of decoding algorithms are available, namely local and global. Local decoding provides state probabilities at each occasion, while global decoding determines the sequence of states that is most likely, given the observations. This paper includes decoding results based on the so-called expectation-maximisation (EM) algorithm
                    <sup>
                        <xref ref-type="bibr" rid="ref-8">8</xref>
                    </sup>, together with posterior seizure-state probabilities provided by Bayesian HMM analyses. The resulting seizure-state time series data were used to generate seizure-state duration (sojourn time) probability densities and associated cumulative distributions.</p>
            </sec>
            <sec>
                <title>Parameter estimation as the main objective</title>
                <p>The primary objective for this study is the development of statistical models that provide information that is useful from a clinical perspective. Thus the main focus is a characterisation of the seizure states that, according to the model, underlie the observed seizure behaviour. This is motivated by the belief that a model-based description of the process will provide a clue to future behaviour. From a patient management perspective seizure-state duration (sojourn time) prediction is especially relevant, prompting us to focus on sojourn-time cumulative probability distribution results. Thus the main objective is the provision of model parameter estimates. These take the form of a point estimate, usually a median or mode, together with some measure of uncertainty.</p>
                <p>Two alternative kinds of HMM analyses have been used in this work, namely traditional likelihood analyses performed using the EM algorithm, and Bayesian analyses implemented using MCMC
                    <sup>
                        <xref ref-type="bibr" rid="ref-9">9</xref>,
                        <xref ref-type="bibr" rid="ref-10">10</xref>
                    </sup>. The main reason for using these two rather different approaches was to assess robustness. Each of the seizure time series reported in this study is relatively short in duration. Parameter estimation is, therefore, compromised because a short time series will include relatively few state transitions, rendering it difficult to obtain the HMM transition probability estimates with good precision. In clinical practice, decisions must sometimes be taken within a short time frame and our approach reflects this clinical reality. By comparing the results provided by two or more differing models/analyses, an indication of robustness is obtained. We stress that, in contrast to traditional model comparison analyses, where the aim is to find the best model, the objective in this study is different. Rather than declaring a given model as being &#x2019;best&#x2019;, the objective is to determine whether related models yield similar parameter estimates. Agreement is taken as an indication of robustness. Sampling methods were used extensively, particularly as a mechanism for obtaining measures of uncertainty. In addition to using MCMC to perform the Bayesian analyses and thus obtain the required Bayesian credible intervals, parametric simulation
                    <sup>
                        <xref ref-type="bibr" rid="ref-11">11</xref>
                    </sup> was used to generate confidence intervals associated with various EM estimates.</p>
            </sec>
            <sec>
                <title>Bayesian analysis, Markov chain Monte Carlo simulation and posterior predictive simulation</title>
                <p>In the Bayesian context MCMC is, in effect, a random sampling procedure for evaluating complicated integrals in high dimensional space, as required to calculate various summary statistics. It is widely used in Bayesian analysis, the Gibbs sampler being particularly prominent among the available methods. Several software packages have been developed for performing Gibbs sampling, including WinBUGS
                    <sup>
                        <xref ref-type="bibr" rid="ref-12">12</xref>
                    </sup>, which was used in the present work (version 1.4.3). Presented with the data, a &#x2018;measurement model&#x2019; (likelihood) and prior distributions, WinBUGS constructs the samplers required to generate the MCMC output. In order to avoid confusion we should emphasise that the decision to use MCMC to perform the analyses is entirely unrelated to the fact that the statistical model is based on a Markov process. MCMC is just one of several methods that might be used for HMM parameter estimation, the EM algorithm providing an alternative.</p>
                <p>A particular concern in the present study is the adoption of meaningful HMMs. Reasonable care must be taken to ensure the validity/adequacy of these models. Posterior predictive simulation is a Bayesian model checking procedure which is especially useful in modelling applications in which standard model checking methods, based on residuals analysis for example, are problematic. Discrete-data (counts, etc.) regression modelling is an obvious example
                    <sup>
                        <xref ref-type="bibr" rid="ref-13">13</xref>
                    </sup>. The method is particularly useful for exploring potential model failure specific to the key research questions. The basic idea underlying posterior predictive simulation is the generation of replicate datasets which, in the MCMC setting, is achieved by using the posterior sample generated under the model in question. One or more key features of the observed data are compared with the replicate datasets. If these features are not seen in a majority of the replicates, this is taken as an indication of model failure. The comparison between the simulated and observed data can be performed using some discrepancy measure or can be undertaken using graphical methods. The latter approach has been suggested as particularly useful in practice
                    <sup>
                        <xref ref-type="bibr" rid="ref-9">9</xref>,
                        <xref ref-type="bibr" rid="ref-14">14</xref>
                    </sup>. In the present epilepsy seizure study the occurrence of extreme counts (either low or high) is an obvious candidate for scrutiny. The model needs to capture these extremes. It is important to note that the replicate datasets incorporate both the uncertainty specified under the model (Poisson variation in the present context) and parameter uncertainty. It might also be noted that the replicate datasets fulfil a dual role in the present study. In addition to their model checking role they provide the clinician with an indication of what might be expected in terms of future seizure pattern in the patient under consideration, assuming no indication of model inadequacy. A key feature of the posterior predictive simulation assessment method is a probabilistic measure of model inadequacy. In this paper we use Bayesian p-values, which are a common choice. Additional information is provided in 
                    <xref ref-type="sec" rid="N2">Note S2</xref>.</p>
            </sec>
            <sec>
                <title>The EM algorithm and parametric simulation</title>
                <p>Hidden Markov models have a history going back to the 1960s, long before Bayesian statistics became accepted by mainstream data analysts. Although HMM parameter estimation can be tackled using standard minimisation (maximisation) methods, the EM algorithm is commonly adopted, based on well-established literature. The monograph by Zucchini and MacDonald (2009)
                    <sup>
                        <xref ref-type="bibr" rid="ref-8">8</xref>
                    </sup>, provides a detailed account, together with a set of routines for implementing an HMM analysis based on both minimisation and the EM algorithm. A number of R packages also provide tools for performing HMM analyses, including the R package 
                    <monospace>msm</monospace>
                    <sup>
                        <xref ref-type="bibr" rid="ref-15">15</xref>
                    </sup>.</p>
                <p>Although maximum likelihood estimation in HM modelling is well established, the traditional approach to confidence interval and standard error estimation is to resort to asymptotic (large sample) approximation. The resulting intervals/standard error estimates can be inaccurate, however, and an alternative strategy is to avoid asymptotic approximation by adopting a sampling method. Zucchini and MacDonald (2009) [
                    <xref ref-type="bibr" rid="ref-8">8</xref>, page 53], suggest the parametric bootstrap. In this study we have adopted a sampling approach referred to as parametric simulation [
                    <xref ref-type="bibr" rid="ref-11">11</xref>, Chapter 2].</p>
            </sec>
        </sec>
        <sec sec-type="methods">
            <title>Methods</title>
            <sec sec-type="subjects">
                <title>Subjects</title>
                <p>
                    <italic toggle="yes">Young Epilepsy</italic> is the United Kingdom&#x2019;s leading provider of education, treatment and residential care for children and young people with severe epilepsy. Located in Surrey just outside Lingfield, it has on-site 24-hour medical services. All young people have very close supervision by carers throughout the days and nights and these carers compile seizure diaries if seizures are observed. (Seizure diaries are used in similar organisations to 
                    <italic toggle="yes">Young Epilepsy</italic> and have been used in previous studies to monitor seizure frequency and severity
                    <sup>
                        <xref ref-type="bibr" rid="ref-16">16</xref>
                    </sup>.) Evaluation of the diaries plays a major role in carers and medical staff assessing whether there have been substantial changes in seizure frequency and or severity. Thus, much detail and attention is given to their completion and accuracy. Total weekly seizure frequencies over a period of 1 year (starting in September 2004) were ascertained from the diaries for all the participants.</p>
                <p>The project was registered at Young Epilepsy as a case note review. All applications for registration are reviewed by a formally constituted internal committee consisting of physicians, nurses and lay people. Questions related to ethics that are raised at that committee are referred to the East Surrey Ethics Committee. The local committee raised no ethical questions about our study. In addition the data collection was deemed to be audit and, under the charity&#x2019;s official rules, consent was not required. The data were not formally blinded because the study does not take the form of a clinical trial. Instead, the focus is the development of a statistical model, the objective being parameter estimation as an aid to clinical decision making. Thus the purpose is parameter estimation as distinct from hypothesis testing. That said, the analyses were performed by MDK after extracting the seizure time-series data from the original clinical records, thus removing all sources of identification. Prof Rod Scott and Dr Suresh Pujar had access to the clinical information as part of routine clinical care, but took no part in the development of the statistical models or data analysis.</p>
                <p>Three children with epilepsy were selected for this study based on an examination of seizure frequency charts, subject to the restriction that no change in medication had occurred during the observation period (inclusion criterion). The three cases were chosen because they differed markedly in their time-dependent seizure behaviour, each presenting a particular challenge from a statistical modelling perspective. The central point to note regarding the choice of patients is the focus of this paper, namely seizure-count time series modelling, aimed at the provision of individual-specific parameter estimates, as opposed to group-average estimation. Our premise is that the analytical procedure can be applied to any individual, recognising that the model details must be tailored to the individual under investigation. This premise is supported by the demonstration that the method yields useful statistical information when applied to patients with disparate clinical presentations.</p>
            </sec>
            <sec>
                <title>Bayesian models</title>
                <p>Two distinct Bayesian seizure-count time-series models were adopted in this study, namely a log-linear HMM and a Poisson-gamma HMM. The details are as follows. It might be noted that Congdon (2006)
                    <sup>
                        <xref ref-type="bibr" rid="ref-17">17</xref>
                    </sup> provides relevant information on Bayesian HMMs, including their implementation in WinBUGS. It might also be noted that HMMs are a class of mixture model, and that mixture model parameter estimation is not always straight-forward due to a phenomenon known as label switching. The label switching problem is discussed briefly in 
                    <xref ref-type="sec" rid="N3">Note S3</xref>.</p>
            </sec>
            <sec>
                <title>Log-linear HMM</title>
                <p>The following statistical model descriptions are given using an informal notation based on the WinBUGS distributions used in their implementation. This serves the dual purpose of providing a more intelligible outline for a non-mathematical readership and, at the same time, gives an outline of the key components of the WinBUGS code used to implement the models. The observed seizure counts (
                    <italic toggle="yes">y
                        <sub>t</sub>
                    </italic>), conditional on state (
                    <italic toggle="yes">Z
                        <sub>t</sub>
                    </italic> ), are assumed to have a Poisson distribution. In the J-state case and assuming time-independent state-specific Poisson rates (and noting that several model parameters are completely defined within the hierarchical set of equations that follow and do not require further definition)</p>
                <p>&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;
                    <italic toggle="yes">y
                        <sub>t</sub>
                    </italic>&#x00a0;&#x00a0;&#x00a0;&#x00a0;~&#x00a0;&#x00a0;&#x00a0;&#x00a0;
                    <monospace>Poisson</monospace>(
                    <italic toggle="yes">&#x03bb;
                        <sub>Z
                            <sub>t</sub>
                        </sub>
                    </italic>&#x00a0;), 
                    <italic toggle="yes">t</italic>&#x00a0;=&#x00a0;1,...,&#x00a0;
                    <italic toggle="yes">N</italic>&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;(1)</p>
                <p>&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;
                    <italic toggle="yes">log</italic>(
                    <italic toggle="yes">&#x03bb;</italic>
                    <sub>1</sub>&#x00a0;)&#x00a0;&#x00a0;&#x00a0;&#x00a0;~&#x00a0;&#x00a0;&#x00a0;&#x00a0;
                    <italic toggle="yes">N</italic>(0, 
                    <italic toggle="yes">&#x03f5;
                        <sub>p</sub>
                    </italic>), 
                    <italic toggle="yes">&#x00a0;l&#x00a0;</italic>&lt;&#x00a0;
                    <italic toggle="yes">&#x03bb;</italic>
                    <sub>1</sub>&#x00a0;&lt;&#x00a0;
                    <italic toggle="yes">u</italic>&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;(2)</p>
                <p>&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;
                    <italic toggle="yes">log</italic>(
                    <italic toggle="yes">&#x03bb;
                        <sub>j</sub>
                    </italic>&#x00a0;)&#x00a0;&#x00a0;&#x00a0;&#x00a0;~&#x00a0;&#x00a0;&#x00a0;&#x00a0;
                    <italic toggle="yes">N</italic>(0, 
                    <italic toggle="yes">&#x03f5;
                        <sub>p</sub>
                    </italic>),&#x00a0;
                    <italic toggle="yes">&#x03bb;</italic>
                    <sub>
                        <italic toggle="yes">j</italic>&#x2013;1</sub>&#x00a0;&lt;&#x00a0;
                    <italic toggle="yes">&#x03bb;
                        <sub>j</sub>
                    </italic>&#x00a0;&lt;&#x00a0;
                    <italic toggle="yes">u</italic>,&#x00a0;
                    <italic toggle="yes">j</italic> = 2,...,&#x00a0;
                    <italic toggle="yes">J</italic>&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;(3)</p>
                <p>&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;
                    <italic toggle="yes">Z
                        <sub>t</sub>
                    </italic>&#x00a0;&#x00a0;&#x00a0;&#x00a0;~&#x00a0;&#x00a0;&#x00a0;&#x00a0;
                    <monospace>Categorical</monospace>(
                    <italic toggle="yes">P</italic>
                    <sub>
                        <italic toggle="yes">Z</italic>
                        <sub>
                            <italic toggle="yes">t</italic>&#x2013;1</sub>,1:
                        <italic toggle="yes">J</italic>
                    </sub>), 
                    <italic toggle="yes">t</italic> = 2,...,&#x00a0;
                    <italic toggle="yes">N</italic>&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;(4)</p>
                <p>&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;
                    <italic toggle="yes">Z</italic>
                    <sub>1</sub>&#x00a0;&#x00a0;&#x00a0;&#x00a0;~&#x00a0;&#x00a0;&#x00a0;&#x00a0;
                    <monospace>Categorical</monospace>(
                    <italic toggle="yes">P</italic>
                    <sub>0,1:
                        <italic toggle="yes">J</italic>
                    </sub>)&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;(5)</p>
                <p>&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;
                    <italic toggle="yes">P</italic>
                    <sub>
                        <italic toggle="yes">i</italic>,1:
                        <italic toggle="yes">J</italic>
                    </sub>&#x00a0;&#x00a0;&#x00a0;&#x00a0;~&#x00a0;&#x00a0;&#x00a0;&#x00a0;
                    <monospace>Dirichlet</monospace>(&#x00a0;1&#x00a0;), 
                    <italic toggle="yes">i</italic> = 0,...,&#x00a0;
                    <italic toggle="yes">J</italic>&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;(6)</p>
                <p>where the symbol ~ indicates &#x2018;distributed as&#x2019;, 
                    <italic toggle="yes">N</italic> (., .) is the normal distribution with the specified mean and precision, 
                    <italic toggle="yes">t</italic> is an observation occasion label, 
                    <italic toggle="yes">N</italic> is the number of observations, 
                    <italic toggle="yes">&#x03f5;
                        <sub>p</sub>
                    </italic> is a small value, 
                    <italic toggle="yes">l</italic> and 
                    <italic toggle="yes">u</italic> are lower and upper constraints, 
                    <italic toggle="yes">P</italic>
                    <sub>
                        <italic toggle="yes">Z</italic>
                        <sub>
                            <italic toggle="yes">t</italic>&#x2212;1</sub>,1:
                        <italic toggle="yes">J</italic>
                    </sub> is a transition matrix row, 
                    <italic toggle="yes">P</italic>
                    <sub>0,1:
                        <italic toggle="yes">J</italic>
                    </sub> is a J-length vector of probabilities with sum equal to one, 
                    <italic toggle="yes">j</italic> is the state label, 
                    <italic toggle="yes">J</italic> the number of hidden states and 
                    <bold>1</bold> is a J-length vector of ones. 
                    <monospace>Categorical</monospace>(
                    <italic toggle="yes">p</italic>) is the distribution of the 
                    <italic toggle="yes">N</italic> mutually exclusive states, as determined by the class probability vector 
                    <italic toggle="yes">p</italic>. (It is implemented in WinBUGS by the 
                    <monospace>dcat</monospace> distribution (page 352 in 
                    <xref ref-type="bibr" rid="ref-18">18</xref>), which &#x2018;returns&#x2019; one of the 
                    <italic toggle="yes">J</italic> states at each MCMC iteration.) The transition matrix row priors are given as Dirichlet distributions mainly for clarity, although the majority of the simulations performed in this study adopted an equivalent 
                    <monospace>Gamma</monospace>(
                    <italic toggle="yes">alpha</italic>, 1) construction (pages 235 and 351 in 
                    <xref ref-type="bibr" rid="ref-18">18</xref>). In those cases where the state-specific Poisson rate parameters are a function of time the observation model becomes</p>
                <p>&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;
                    <italic toggle="yes">y
                        <sub>t</sub>
                    </italic> |
                    <italic toggle="yes">Z
                        <sub>t</sub>
                    </italic>, (
                    <italic toggle="yes">&#x03bb;</italic>
                    <sub>1
                        <italic toggle="yes">t</italic>
                    </sub> , . . .
                    <italic toggle="yes">&#x03bb;
                        <sub>J t</sub>
                    </italic> )&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;~&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;
                    <monospace>Poisson</monospace>(
                    <italic toggle="yes">y
                        <sub>t</sub>
                    </italic> | 
                    <italic toggle="yes">&#x03bb;
                        <sub>Z
                            <sub>t</sub> t</sub>
                    </italic>), 
                    <italic toggle="yes">t</italic> = 1,..., 
                    <italic toggle="yes">N</italic>&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;(7)</p>
                <p id="e8">&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;log(
                    <italic toggle="yes">&#x03bb;
                        <sub>jt</sub>
                    </italic>)&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;=&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;
                    <italic toggle="yes">&#x03bb;
                        <sup>&#x2032;</sup>
                        <sub>j</sub>
                    </italic> + 
                    <italic toggle="yes">f
                        <sub>t</sub>
                    </italic> , 
                    <italic toggle="yes">j</italic> = 1,..., 
                    <italic toggle="yes">J</italic>&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;(8)</p>
                <p>&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;
                    <italic toggle="yes">&#x03bb;
                        <sup>&#x2032;</sup>
                    </italic>
                    <sub>1</sub>&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;~&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;
                    <italic toggle="yes">N</italic>(0, 
                    <italic toggle="yes">&#x03f5;
                        <sub>p</sub>
                    </italic>), 
                    <italic toggle="yes">l</italic> &lt; 
                    <italic toggle="yes">&#x03bb;
                        <sup>'</sup>
                    </italic>
                    <sub>1</sub> &lt; 
                    <italic toggle="yes">u</italic>&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;(9)</p>
                <p>&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;
                    <italic toggle="yes">&#x03bb;
                        <sup>&#x2032;</sup>
                        <sub>j</sub>
                    </italic>&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;~&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;
                    <italic toggle="yes">N</italic>(0, 
                    <italic toggle="yes">&#x03f5;
                        <sub>p</sub>
                    </italic>), 
                    <italic toggle="yes">&#x03bb;
                        <sup>&#x2032;</sup>
                    </italic>
                    <sub>
                        <italic toggle="yes">j</italic>&#x2013;1</sub> &lt; 
                    <italic toggle="yes">&#x03bb;
                        <sup>&#x2032;</sup>
                        <sub>j</sub>
                    </italic> &lt; 
                    <italic toggle="yes">u</italic>, 
                    <italic toggle="yes">j</italic> = 2,..., 
                    <italic toggle="yes">J</italic>.&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;(10)</p>
                <p>Thus, 
                    <italic toggle="yes">f
                        <sub>t</sub>
                    </italic> adds a time-dependent offset to each of the Poisson rate parameters in the log domain.</p>
                <p>Among the approaches adopted for incorporating time dependence in the state-specific Poisson means is the introduction of quadratic dependence (
                    <italic toggle="yes">f
                        <sub>t</sub>
                    </italic> = 
                    <italic toggle="yes">&#x03b2;</italic>
                    <sub>1</sub>
                    <italic toggle="yes">t</italic> + 
                    <italic toggle="yes">&#x03b2;</italic>
                    <sub>2</sub>
                    <italic toggle="yes">t</italic>
                    <sup>2</sup>), the introduction of a temporal random effects term and the incorporation of a first order autoregressive term (abbreviated AR(1)). The AR(1) and random effect model details are given in 
                    <xref ref-type="sec" rid="N4">Note S4</xref>.</p>
            </sec>
            <sec>
                <title>Poisson gamma HMM</title>
                <p>The following Poisson-gamma model was adopted as an alternative to the log-linear model in those cases where the state-specific Poisson rates are time-independent. Using Poisson rate-parameter prior assignments based on George 
                    <italic toggle="yes">et al</italic>. (1993)
                    <sup>
                        <xref ref-type="bibr" rid="ref-19">19</xref>
                    </sup> and Gelfand and Smith (1990)
                    <sup>
                        <xref ref-type="bibr" rid="ref-20">20</xref>
                    </sup>, the observation model becomes</p>
                <p>&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;
                    <italic toggle="yes">y
                        <sub>t</sub>
                    </italic>&#x00a0;&#x00a0;&#x00a0;&#x00a0;~&#x00a0;&#x00a0;&#x00a0;&#x00a0;
                    <monospace>Poisson</monospace>(
                    <italic toggle="yes">&#x03bb;
                        <sub>z
                            <sub>t</sub>
                        </sub>
                    </italic>), 
                    <italic toggle="yes">t</italic> = 1,..., 
                    <italic toggle="yes">N</italic>&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;(11)</p>
                <p>&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;
                    <italic toggle="yes">&#x03bb;
                        <sub>j</sub>
                    </italic>&#x00a0;&#x00a0;&#x00a0;&#x00a0;~&#x00a0;&#x00a0;&#x00a0;&#x00a0;
                    <monospace>Gamma</monospace>(
                    <italic toggle="yes">&#x03b1;
                        <sub>j</sub>
                    </italic>, 
                    <italic toggle="yes">&#x03b2;
                        <sub>j</sub>
                    </italic>),&#x00a0;&#x00a0;
                    <italic toggle="yes">j</italic> = 1,..., 
                    <italic toggle="yes">J</italic>&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;(12)</p>
                <p>&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;
                    <italic toggle="yes">&#x03b1;
                        <sub>j</sub>
                    </italic>&#x00a0;&#x00a0;&#x00a0;&#x00a0;~&#x00a0;&#x00a0;&#x00a0;&#x00a0;
                    <monospace>Exp</monospace>(1.0), 
                    <italic toggle="yes">j</italic> = 1,..., 
                    <italic toggle="yes">J</italic>&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;(13)</p>
                <p>&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;
                    <italic toggle="yes">&#x03b2;
                        <sub>j</sub>
                    </italic>&#x00a0;&#x00a0;&#x00a0;&#x00a0;~&#x00a0;&#x00a0;&#x00a0;&#x00a0;
                    <monospace>Gamma</monospace>(0.1, 1.0), 
                    <italic toggle="yes">j</italic> = 1,..., 
                    <italic toggle="yes">J</italic>&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;(14)</p>
                <p>&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;
                    <italic toggle="yes">Z
                        <sub>t</sub>
                    </italic>&#x00a0;&#x00a0;&#x00a0;&#x00a0;~&#x00a0;&#x00a0;&#x00a0;&#x00a0;
                    <monospace>Categorical</monospace>(
                    <italic toggle="yes">P</italic>
                    <sub>
                        <italic toggle="yes">Z</italic>
                        <sub>
                            <italic toggle="yes">t</italic>&#x2013;1</sub>,1:
                        <italic toggle="yes">J</italic>
                    </sub>), 
                    <italic toggle="yes">t</italic> = 2,..., 
                    <italic toggle="yes">N</italic>&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;(15)</p>
                <p>&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;
                    <italic toggle="yes">Z</italic>
                    <sub>1</sub>&#x00a0;&#x00a0;&#x00a0;&#x00a0;~&#x00a0;&#x00a0;&#x00a0;&#x00a0;
                    <monospace>Categorical</monospace>(
                    <italic toggle="yes">P</italic>
                    <sub>0,1:
                        <italic toggle="yes">J</italic>
                    </sub>)&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;(16)</p>
                <p>&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;
                    <italic toggle="yes">P</italic>
                    <sub>
                        <italic toggle="yes">i</italic>,1:
                        <italic toggle="yes">J</italic>
                    </sub>&#x00a0;&#x00a0;&#x00a0;&#x00a0;~&#x00a0;&#x00a0;&#x00a0;&#x00a0;
                    <monospace>Dirichlet</monospace>(
                    <bold>1</bold>),&#x00a0;&#x00a0;
                    <italic toggle="yes">i</italic> = 0,..., 
                    <italic toggle="yes">J</italic>.&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;&#x00a0;(17)</p>
            </sec>
            <sec>
                <title>Sojourn-time statistics</title>
                <p>Hidden-state sojourn times (also referred to as dwell times) are key to the clinical problem. Many parents and patients recognise the fluctuating nature of epilepsy, but find it difficult to judge how long the child will be in any given state. Sojourn-time statistics enable the clinician to provide this important clinical information. The sojourn-time density for the 
                    <italic toggle="yes">jth</italic> state, 
                    <italic toggle="yes">j</italic> = 1, &#x2026;, 
                    <italic toggle="yes">J</italic> is given by
                    <sup>
                        <xref ref-type="bibr" rid="ref-21">21</xref>
                    </sup> 
                    <disp-formula>
                        <mml:math display="block" id="math1">
                            <mml:mrow>
                                <mml:msub>
                                    <mml:mi>d</mml:mi>
                                    <mml:mi>j</mml:mi>
                                </mml:msub>
                                <mml:mrow>
                                    <mml:mo>(</mml:mo>
                                    <mml:mi>s</mml:mi>
                                    <mml:mo>)</mml:mo>
                                </mml:mrow>
                                <mml:mo>=</mml:mo>
                                <mml:mi>P</mml:mi>
                                <mml:mrow>
                                    <mml:mo>(</mml:mo>
                                    <mml:mrow>
                                        <mml:msub>
                                            <mml:mi>Z</mml:mi>
                                            <mml:mrow>
                                                <mml:mi>t</mml:mi>
                                                <mml:mo>+</mml:mo>
                                                <mml:mi>s</mml:mi>
                                                <mml:mo>+</mml:mo>
                                                <mml:mn>1</mml:mn>
                                            </mml:mrow>
                                        </mml:msub>
                                        <mml:mo>&#x2260;</mml:mo>
                                        <mml:mi>j</mml:mi>
                                        <mml:mo>,</mml:mo>
                                        <mml:msub>
                                            <mml:mi>Z</mml:mi>
                                            <mml:mrow>
                                                <mml:mi>t</mml:mi>
                                                <mml:mo>+</mml:mo>
                                                <mml:mi>s</mml:mi>
                                                <mml:mo>&#x2212;</mml:mo>
                                                <mml:mi>v</mml:mi>
                                            </mml:mrow>
                                        </mml:msub>
                                        <mml:mo>=</mml:mo>
                                        <mml:mi>j</mml:mi>
                                        <mml:mo>,</mml:mo>
                                        <mml:mi>v</mml:mi>
                                        <mml:mo>=</mml:mo>
                                        <mml:mn>0</mml:mn>
                                        <mml:mo>,</mml:mo>
                                        <mml:mo>&#x2026;</mml:mo>
                                        <mml:mo>,</mml:mo>
                                        <mml:mi>s</mml:mi>
                                        <mml:mo>&#x2212;</mml:mo>
                                        <mml:mn>2</mml:mn>
                                        <mml:mo>|</mml:mo>
                                        <mml:msub>
                                            <mml:mi>Z</mml:mi>
                                            <mml:mrow>
                                                <mml:mi>t</mml:mi>
                                                <mml:mo>+</mml:mo>
                                                <mml:mn>1</mml:mn>
                                            </mml:mrow>
                                        </mml:msub>
                                        <mml:mo>=</mml:mo>
                                        <mml:mi>j</mml:mi>
                                        <mml:mo>,</mml:mo>
                                        <mml:msub>
                                            <mml:mi>Z</mml:mi>
                                            <mml:mi>t</mml:mi>
                                        </mml:msub>
                                        <mml:mo>&#x2260;</mml:mo>
                                        <mml:mi>j</mml:mi>
                                    </mml:mrow>
                                    <mml:mo>)</mml:mo>
                                </mml:mrow>
                            </mml:mrow>
                            <mml:mspace width="5em"/>
                            <mml:mo stretchy="false">(</mml:mo>
                            <mml:mn>18</mml:mn>
                            <mml:mo stretchy="false">)</mml:mo>
                        </mml:math>
                    </disp-formula> where 
                    <italic toggle="yes">J</italic> is the number of states, 
                    <italic toggle="yes">s &#x03f5;</italic> {1, &#x2026;, 
                    <italic toggle="yes">M
                        <sub>j</sub>
                    </italic>}, and 
                    <italic toggle="yes">M
                        <sub>j</sub>
                    </italic> is the 
                    <italic toggle="yes">jth</italic> state sojourn time upper limit. Thus the sojourn time, 
                    <italic toggle="yes">s</italic>, is the number of observation occasions 
                    <italic toggle="yes">t</italic> + 1, &#x2026;, 
                    <italic toggle="yes">t</italic> + 
                    <italic toggle="yes">s</italic>, during which the unobserved process remains in the 
                    <italic toggle="yes">j</italic>th state, conditional on being in some other state on occasions 
                    <italic toggle="yes">t</italic> and 
                    <italic toggle="yes">t</italic> + 
                    <italic toggle="yes">s</italic> + 1. Sojourn time probability distributions were derived from the MCMC output obtained for the transition matrix diagonal elements by substitution into the geometric distribution. Specifically, probability densities were generated using 
                    <inline-formula>
                        <mml:math display="inline" id="M1">
                            <mml:mrow>
                                <mml:mi>g</mml:mi>
                                <mml:mrow>
                                    <mml:mo>(</mml:mo>
                                    <mml:mrow>
                                        <mml:msubsup>
                                            <mml:mi>P</mml:mi>
                                            <mml:mrow>
                                                <mml:mi>i</mml:mi>
                                                <mml:mi>i</mml:mi>
                                            </mml:mrow>
                                            <mml:mrow>
                                                <mml:mrow>
                                                    <mml:mo>(</mml:mo>
                                                    <mml:mi>k</mml:mi>
                                                    <mml:mo>)</mml:mo>
                                                </mml:mrow>
                                            </mml:mrow>
                                        </mml:msubsup>
                                    </mml:mrow>
                                    <mml:mo>)</mml:mo>
                                </mml:mrow>
                                <mml:mo>,</mml:mo>
                                <mml:mi>k</mml:mi>
                                <mml:mo>=</mml:mo>
                                <mml:mn>1</mml:mn>
                                <mml:mo>,</mml:mo>
                                <mml:mo>&#x2026;</mml:mo>
                                <mml:mo>,</mml:mo>
                                <mml:mi>K</mml:mi>
                                <mml:mo>,</mml:mo>
                            </mml:mrow>
                        </mml:math>
                    </inline-formula> where 
                    <inline-formula>
                        <mml:math display="inline" id="M2">
                            <mml:mrow>
                                <mml:mi>g</mml:mi>
                                <mml:mrow>
                                    <mml:mo>(</mml:mo>
                                    <mml:mrow>
                                        <mml:msub>
                                            <mml:mi>P</mml:mi>
                                            <mml:mrow>
                                                <mml:mi>i</mml:mi>
                                                <mml:mi>i</mml:mi>
                                            </mml:mrow>
                                        </mml:msub>
                                    </mml:mrow>
                                    <mml:mo>)</mml:mo>
                                </mml:mrow>
                                <mml:mo>=</mml:mo>
                                <mml:msubsup>
                                    <mml:mi>P</mml:mi>
                                    <mml:mrow>
                                        <mml:mi>i</mml:mi>
                                        <mml:mi>i</mml:mi>
                                    </mml:mrow>
                                    <mml:mrow>
                                        <mml:mi>s</mml:mi>
                                        <mml:mo>&#x2212;</mml:mo>
                                        <mml:mn>1</mml:mn>
                                    </mml:mrow>
                                </mml:msubsup>
                                <mml:mrow>
                                    <mml:mo>(</mml:mo>
                                    <mml:mrow>
                                        <mml:mn>1</mml:mn>
                                        <mml:mo>&#x2212;</mml:mo>
                                        <mml:msub>
                                            <mml:mi>P</mml:mi>
                                            <mml:mrow>
                                                <mml:mi>i</mml:mi>
                                                <mml:mi>i</mml:mi>
                                            </mml:mrow>
                                        </mml:msub>
                                    </mml:mrow>
                                    <mml:mo>)</mml:mo>
                                </mml:mrow>
                                <mml:mspace width="0.3em"/>
                                <mml:mtext>and</mml:mtext>
                                <mml:mspace width="0.3em"/>
                                <mml:msubsup>
                                    <mml:mi>P</mml:mi>
                                    <mml:mrow>
                                        <mml:mi>i</mml:mi>
                                        <mml:mi>i</mml:mi>
                                    </mml:mrow>
                                    <mml:mrow>
                                        <mml:mrow>
                                            <mml:mo>(</mml:mo>
                                            <mml:mi>k</mml:mi>
                                            <mml:mo>)</mml:mo>
                                        </mml:mrow>
                                    </mml:mrow>
                                </mml:msubsup>
                                <mml:mo>,</mml:mo>
                                <mml:mi>k</mml:mi>
                                <mml:mo>=</mml:mo>
                                <mml:mn>1</mml:mn>
                                <mml:mo>,</mml:mo>
                                <mml:mo>&#x2026;</mml:mo>
                                <mml:mo>,</mml:mo>
                                <mml:mi>K</mml:mi>
                            </mml:mrow>
                        </mml:math>
                    </inline-formula> is the Gibbs marginal posterior sample obtained for the 
                    <italic toggle="yes">i</italic>th diagonal element of the transition matrix. (
                    <italic toggle="yes">K</italic> is the MCMC sample size and (
                    <italic toggle="yes">k</italic>) the iteration label. This is based on the standard approach to evaluating the marginal posterior distribution of a variable that is a function of the model parameters; see 
                    <xref ref-type="bibr" rid="ref-22">22</xref>, for example.) To provide the results in a form that will be more familiar and accessible to many clinicians, the duration probability statistics are given as complementary cumulative (probability) distributions, i.e., the probability that the sojourn time is greater than a given value. It might be noted that these complementary cumulative probabilities are equivalent to the survivor function that arises in survival analysis.</p>
            </sec>
            <sec>
                <title>Implementation</title>
                <p>
					
                    <italic toggle="yes">
						
                        <bold>Gibbs sampling, convergence analysis and posterior predictive simulation.</bold>
					</italic> Gibbs sampling was performed using WinBUGS/GeoBUGS
                    <sup>
                        <xref ref-type="bibr" rid="ref-12">12</xref>,
                        <xref ref-type="bibr" rid="ref-23">23</xref>,
                        <xref ref-type="bibr" rid="ref-24">24</xref>
                    </sup>, which was downloaded from 
                    <ext-link ext-link-type="uri" xlink:href="http://www.mrc-bsu.cam.ac.uk/bugs">http://www.mrc-bsu.cam.ac.uk/bugs</ext-link>. The 
                    <monospace>dcat</monospace> (categorical distribution) and 
                    <monospace>ddirch</monospace> (Dirichlet distribution) are among the WinBUGS distributions used to implement the statistical models outlined above. Truncated normal samples were generated using the WBDev function djl.dnorm.trunc
                    <sup>
                        <xref ref-type="bibr" rid="ref-25">25</xref>
                    </sup>. Three parallel chains were generated in each analysis, each chain consisting of 5000 samples after thinning. (Thinning is the name given to the common practice whereby a specified proportion of the MCMC output is discarded, the remaining samples being stored for subsequent processing. It has been discussed by a number of analysts, including Carlin and Louis (2009) (Section 3.4.5 in 
                    <xref ref-type="bibr" rid="ref-10">10</xref>). The reason for thinning the MCMC output is to produce a chain with reduced sample autocorrelation. The aim is to reduce both the storage and post-simulation CPU demands of an analysis without suffering much loss in precision. A thinning factor of 10 was used in the majority of the simulations. Thus, 1 in 10 samples was stored and used in subsequent calculations.) The first of each set of three chains was started at an arbitrary position in parameter space, while the other two were started at over-dispersed positions. A burn-in set of samples was acquired prior to storing each chain of 5000 samples. These burn-in samples were also discarded.</p>
                <p>Convergence tests are an essential part of any MCMC analysis. Nevertheless, given the exploratory nature of this study in which many models were investigated for each of the three cases, a complete set of convergence tests on all models and all parameters (i.e., both primary and derived parameters) was not undertaken. Instead, the convergence tests were restricted to the log-linear model MCMC output obtained for the primary parameters, i.e., the Poisson rates and transition matrix elements. This provides protection against a complete failure to achieve an adequate sampling of parameter space. With this safeguard in place, a comparison of the statistics provided by the alternative hidden Markov models adopted in each case, e.g. log-linear compared with Poisson-gamma, provides a mechanism for assessing the robustness of the results.</p>
                <p>Informal convergence assessment was performed by inspecting overlaid trace plots for visual signs of failure. This was followed by semi-formal analyses (see 
                    <xref ref-type="bibr" rid="ref-26">26</xref> for a review of methods), which were performed using three convergence test procedures, namely the Gelman-Rubin shrink factor diagnostic and associated shrink factor plots (which is based on an ANOVA-like assessment of the between-chain and within-chain variances), the Geweke Z-score diagnostic and Z-score plots (based on spectral density variance estimation and a Z-score comparison of chain segments), and the Raftery-Lewis diagnostic procedure (which provides a variety of data, including an estimate of the number of iterations required to obtain a given quantile to some specified accuracy, taking into account the correlation between samples). These convergence analyses were performed using the R CODA (Convergence Diagnosis and Output Analysis software) package
                    <sup>
                        <xref ref-type="bibr" rid="ref-27">27</xref>
                    </sup> (R version 2.15.2, CODA version 0.16&#x2013;1).</p>
                <p>As stated in the Introduction, posterior predictive simulation was used extensively to assess the capacity of the various Bayesian models to account for the observed seizure-count time-series data. Bayesian p-values were adopted as a measure of model inadequacy. The procedure was implemented as follows. At each MCMC iteration a simulated dataset (commonly referred to as a replicate dataset) was generated using the parameter values obtained at that iteration. The resulting replicate datasets and the observed data were used to generate a Bayesian p-value estimate, as given by the proportion of replicates satisfying 
                    <xref ref-type="other" rid="e19">equation 19</xref>, based on the chosen discrepancy measure. For example, among the tests that were performed is the capacity of a given model to capture the observed maximum seizure rate for the subject in question. In this case 
                    <italic toggle="yes">p
                        <sub>B</sub>
                    </italic> = #(
                    <italic toggle="yes">T</italic>(
                    <italic toggle="yes">y
                        <sup>rep</sup>
                    </italic>) &#x2265; 
                    <italic toggle="yes">T</italic>(
                    <italic toggle="yes">y</italic>))
                    <italic toggle="yes">/K</italic>, where K is the number of MCMC iterations and 
                    <italic toggle="yes">T</italic>(
                    <italic toggle="yes">y</italic>) is the number of occasions on which the observed maximum rate occurred. Additional information is given in 
                    <xref ref-type="sec" rid="N5">Note S5</xref>, 
                    <xref ref-type="sec" rid="N6">Note S6</xref> and 
                    <xref ref-type="sec" rid="N7">Note S7</xref>, while 
                    <xref ref-type="sec" rid="N2">Note S2</xref> provides a brief introduction to posterior predictive simulation.</p>
                <p>
					
                    <italic toggle="yes">
						
                        <bold>The EM algorithm and parametric simulation.</bold>
					</italic> The majority of the analyses undertaken in this study were performed using Bayesian statistical models, as outlined above. In some instances, however, traditional (non-Bayesian) HMM EM analyses were also undertaken for comparison, the results of which are shown for one of the three cases. These EM calculations, which were restricted to those analyses where the state-specific seizure rates (i.e., Poisson rates) are time invariant, were implemented using the R routines provided by Zucchini and MacDonald (2009)
                    <sup>
                        <xref ref-type="bibr" rid="ref-8">8</xref>
                    </sup>. Parametric simulation [
                    <sup>
                        <xref ref-type="bibr" rid="ref-11">11</xref>
                    </sup>, Chapter 2] was used to construct the associated confidence intervals. (Parametric simulation is a random sampling procedure in which simulated data are generated using the fitted model. Parameters of interest are recalculated from each simulated dataset. Confidence intervals and other statistics can be constructed using the resulting parameter sample distributions.)</p>
            </sec>
        </sec>
        <sec sec-type="results">
            <title>Results</title>
            <sec>
                <title>MCMC convergence</title>
                <p>All overlaid trace plots were effectively ideal in their visual appearance except for some Poisson rate-parameter plots which showed random and very short-lived excursions to high values. But these excursions were observed in all three chains when they did occur, suggesting satisfactory coverage of the posterior distribution. The Gelman-Rubin shrink factors and associated plots were mostly exemplary; the remainder were all satisfactory. The Geweke Z-scores were also satisfactory, although the Geweke Z-score plots invariably showed one or more scores greater than 2.</p>
                <p>The Raftery-Lewis analyses indicated that in two of the three cases, a sample of size 5000 (after thinning) was sufficient to provide the majority of 0.025 quantile estimates with an accuracy of &#x00b1;0.005, or better, with probability 0.95. Thus the resulting nominal 95% credible intervals have a true coverage of between 94% and 96%, with probability 0.95. In a few instances the accuracy was slightly less, but mostly better than &#x00b1;0.0055. In Case 1 this level of accuracy was not achieved for every parameter. Nevertheless the accuracy was at least &#x00b1;0.01, which provides nominal 95% intervals with a true coverage of between 93% and 97%, with probability 0.95.</p>
                <supplementary-material id="DS0" orientation="portrait" position="float" xlink:href="https://f1000researchdata.s3.amazonaws.com/datasets/9746/4953980f-cc84-4923-9392-890879bca303_seisureCounts.csv">
                    <label>Weekly seizure count data for each of the three cases presented in this report</label>
                    <caption/>
                </supplementary-material>
            </sec>
            <sec>
                <title>Case 1. No trend with an extreme seizure rate on a single occasion</title>
                <p>The seizure count time series observed in the first case is unremarkable except for a single occasion when the rate was close to double that observed on the majority of occasions (
                    <xref ref-type="fig" rid="f2">Figure 2</xref>). The observed variance suggests overdispersion while a comparison of a 2-state HMM and a standard Poisson model is ambiguous, AIC selecting the 2-state HMM, while BIC suggests that the standard Poisson model is adequate. We note, however, that under the Poisson distribution with the observed mean value, the probability of observing a seizure count of 13 or higher in a series of 53 observations is close to 0.05, providing justification for an examination of the 2-state HMM. Three separate 2-state HMM analyses were undertaken, the first using the EM algorithm combined with parametric simulation confidence interval estimation, the second and third using the MCMC implementation of the Bayesian log-linear and Poisson-gamma models, respectively.</p>
                <fig fig-type="figure" id="f2" orientation="portrait" position="float">
                    <label>Figure 2. </label>
                    <caption>
                        <title>Case 1. Observed seizure count time series.</title>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/10507/5b001739-d79d-4ffb-ab46-190631b22c0a_figure2.gif"/>
                </fig>
                <p>Posterior predictive simulation was performed as part of each MCMC analysis. This provides a powerful method for assessing the potential inadequacy of the model under consideration, as determined by a lack of capacity to capture key features of the data. Visual inspection of graphical displays and Bayesian p-values, both derived from the simulated data, are among the tools used for model evaluation. Similarly, parametric simulation was used to produce equivalent non-Bayesian p-values using the EM parameter estimates. As stated in the Introduction, and taken up in the Discussion, the aim of this exercise is not to compare the alternative models/analyses with a view to selecting one as being preferred. Instead, we have adopted 3 distinct analyses (the two Bayesian analyses and the non-Bayesian analysis using the EM algorithm) as a mechanism for assessing robustness. Broadly, the HMM parameter estimates and associated uncertainty intervals obtained from the three analyses should agree, and each should yield satisfactory predictive simulation results. The parameter estimates are examined in the next section. None of the posterior predictive simulation tests led to the suggestion that the Case 1 2-state HM models under consideration fail in their capacity to capture the observations. Similarly, a graphical inspection of the replicate time series generated from this model assessment exercise (
                    <xref ref-type="fig" rid="f3">Figure 3</xref>) gives no indication of serious model inadequacy. The conclusion is that it is reasonable to use these models as a basis for characterising the observed seizure behaviour. The details are given in 
                    <xref ref-type="sec" rid="N5">Note S5</xref>.</p>
                <fig fig-type="figure" id="f3" orientation="portrait" position="float">
                    <label>Figure 3. </label>
                    <caption>
                        <title>Posterior predictive simulated time series plots.</title>
                        <p>These posterior predictive time series were produced by sampling (evenly spaced samples) the posterior predictive (
                            <italic toggle="yes">y
                                <sup>rep</sup>
                            </italic>) output generated by the 2-state Poisson-gamma HMM. These can be interpreted as plausible clinical seizure patterns, and could be used during a clinical consultation to give a sense of what might be expect in the future. Isolated extreme values are observed in a few of the time series, suggesting that a single extreme observation should not necessarily lead to a change in treatment because this is an expected, albeit uncommon, event.</p>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/10507/5b001739-d79d-4ffb-ab46-190631b22c0a_figure3.gif"/>
                </fig>
            </sec>
            <sec>
                <title>Case 1. Primary parameter estimates</title>
                <p>The posterior marginal sample obtained for each parameter of interest provides an estimate of its value (e.g., median and mode) together with a measure of uncertainty. In this paper uncertainty in the primary parameter estimates is summarised using 95% posterior intervals. (Narrower intervals are given for some secondary parameters.) Similarly, parametric simulation was used to generate 95% confidence intervals for the EM parameter estimates. Three sets (EM and two Bayesian model sets) of 2-state HMM primary parameter median estimates (i.e., transition probabilities and Poisson rates) are listed in 
                    <xref ref-type="table" rid="T1">Table 1</xref>, together with their 0.025 and 0.975 quantiles. Unsurprisingly, given only 53 observations, the posterior/confidence intervals obtained for the transition probabilities are large. The Poisson rate-parameter estimates (
                    <italic toggle="yes">&#x03bb;</italic>
                    <sub>1</sub> and 
                    <italic toggle="yes">&#x03bb;</italic>
                    <sub>2</sub>) are similarly obtained with a relatively low precision but are, nevertheless, informative from the clinical perspective. The agreement between the three analyses is satisfactory, indicating a degree of robustness in the results. In particular, parametric simulation based on the EM solution is unrelated to MCMC parameter estimation based on a Bayesian model. Thus the level of agreement between the EM and MCMC results supports a claim of robustness.</p>
                <table-wrap id="T1" orientation="portrait" position="anchor">
                    <label>Table 1. </label>
                    <caption>
                        <title>Case 1.</title>
                        <p>2-state HMM parameter statistics.</p>
                    </caption>
                    <table content-type="article-table" frame="hsides">
                        <thead>
                            <tr>
                                <th align="left" colspan="1" rowspan="2">Parameter</th>
                                <th align="center" colspan="3" rowspan="1">Algorithm - Model</th>
                            </tr>
                            <tr>
                                <th align="center" colspan="1" rowspan="1">EM/par sim</th>
                                <th align="center" colspan="1" rowspan="1">Poi-gamma</th>
                                <th align="center" colspan="1" rowspan="1">log-linear</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td align="center" colspan="1" rowspan="1">
                                    <italic toggle="yes">&#x03bb;</italic>
                                    <sub>1</sub>
                                </td>
                                <td align="center" colspan="1" rowspan="1">1.0 (0.0, 2.87)</td>
                                <td align="center" colspan="1" rowspan="1">1.28 (0.31, 4.09)</td>
                                <td align="center" colspan="1" rowspan="1">1.28 (0.27, 3.95)</td>
                            </tr>
                            <tr>
                                <td align="center" colspan="1" rowspan="1">
                                    <italic toggle="yes">&#x03bb;</italic>
                                    <sub>2</sub>
                                </td>
                                <td align="center" colspan="1" rowspan="1">5.33 (4.48, 6.46)</td>
                                <td align="center" colspan="1" rowspan="1">5.31 (4.49, 6.48)</td>
                                <td align="center" colspan="1" rowspan="1">5.30 (4.49, 6.35)</td>
                            </tr>
                            <tr>
                                <td align="center" colspan="1" rowspan="1">
                                    <italic toggle="yes">P</italic>
                                    <sub>11</sub>
                                </td>
                                <td align="center" colspan="1" rowspan="1">0.031 (0.0, 0.61)</td>
                                <td align="center" colspan="1" rowspan="1">0.23 (0.01, 0.75)</td>
                                <td align="center" colspan="1" rowspan="1">0.23 (0.01, 0.70)</td>
                            </tr>
                            <tr>
                                <td align="center" colspan="1" rowspan="1">
                                    <italic toggle="yes">P</italic>
                                    <sub>12</sub>
                                </td>
                                <td align="center" colspan="1" rowspan="1">0.97 (0.39, 1.00)</td>
                                <td align="center" colspan="1" rowspan="1">0.77 (0.25, 0.99)</td>
                                <td align="center" colspan="1" rowspan="1">0.77 (0.31, 0.99)</td>
                            </tr>
                            <tr>
                                <td align="center" colspan="1" rowspan="1">
                                    <italic toggle="yes">P</italic>
                                    <sub>21</sub>
                                </td>
                                <td align="center" colspan="1" rowspan="1">0.15 (0.0, 0.56)</td>
                                <td align="center" colspan="1" rowspan="1">0.17 (0.04, 0.66)</td>
                                <td align="center" colspan="1" rowspan="1">0.17 (0.04, 0.59)</td>
                            </tr>
                            <tr>
                                <td align="center" colspan="1" rowspan="1">
                                    <italic toggle="yes">P</italic>
                                    <sub>22</sub>
                                </td>
                                <td align="center" colspan="1" rowspan="1">0.84 (0.44, 1.0)</td>
                                <td align="center" colspan="1" rowspan="1">0.83 (0.34, 0.96)</td>
                                <td align="center" colspan="1" rowspan="1">0.83 (0.41, 0.96)</td>
                            </tr>
                            <tr>
                                <td align="center" colspan="1" rowspan="1">
                                    <italic toggle="yes">d</italic>
                                    <sub>1</sub>
                                </td>
                                <td align="center" colspan="1" rowspan="1">1.03 (1.00, 1.27)</td>
                                <td align="center" colspan="1" rowspan="1">1.29 (1.12, 1.57)</td>
                                <td align="center" colspan="1" rowspan="1">1.29 (1.12, 1.57)</td>
                            </tr>
                            <tr>
                                <td align="center" colspan="1" rowspan="1">
                                    <italic toggle="yes">d</italic>
                                    <sub>2</sub>
                                </td>
                                <td align="center" colspan="1" rowspan="1">6.52 (4.24, 11.1)</td>
                                <td align="center" colspan="1" rowspan="1">5.77 (4.00, 8.74)</td>
                                <td align="center" colspan="1" rowspan="1">5.78 (3.99, 8.66)</td>
                            </tr>
                        </tbody>
                    </table>
                    <table-wrap-foot>
                        <fn>
                            <p>2-state HMM Poisson parameter (
                                <italic toggle="yes">&#x03bb;</italic>) and transition probability (
                                <italic toggle="yes">P</italic>) median estimates are listed, as given by the EM algorithm (combined with parametric simulation), the Bayesian Poisson-gamma model MCMC analysis and the Bayesian log-linear model MCMC analysis. The corresponding 0.025 and 0.975 quantiles are given in brackets. The hidden-state mean-duration (
                                <italic toggle="yes">d</italic>) median estimates (given by 1
                                <italic toggle="yes">/</italic>(1 &#x2212; 
                                <italic toggle="yes">P
                                    <sub>ii</sub>
                                </italic> ), 
                                <italic toggle="yes">i</italic> = 1, 2) are also listed together with their 0.25 and 0.75 quantiles. The mean duration 95% intervals are large, due to uncertainty in the transition probabilities from which these are derived, coupled with the inflation that occurs as 1 &#x2212; 
                                <italic toggle="yes">P
                                    <sub>ii</sub>
                                </italic> tends to zero. We have, therefore, chosen to list the 0.25 and 0.75 mean duration quantiles, since these do provide useful clinical information.</p>
                        </fn>
                    </table-wrap-foot>
                </table-wrap>
            </sec>
            <sec>
                <title>Case 1. Hidden-state (seizure-state) probabilities and mean-duration statistics</title>
                <p>An important feature of epilepsy seizure-count hidden Markov modelling is the potential to provide information regarding the seizure state of the subject on a given occasion. As stated in the Introduction, considerable insight into the underlying random process can be obtained using the EM algorithm with local and/or global decoding. Local decoding provides information on the state probabilities at each occasion while global decoding provides state-sequence probabilities. Related information is provided by the marginal posterior distribution obtained for the hidden states, 
                    <italic toggle="yes">Z
                        <sub>t</sub>
                    </italic>, 
                    <italic toggle="yes">t</italic> = 1, &#x2026;, 
                    <italic toggle="yes">N</italic> (i.e., the hidden seizure state at each occasion) given by the Bayesian analyses. In addition, mean duration statistics can be derived from the transition probability estimates.</p>
                <p>
                    <xref ref-type="fig" rid="f4">Figure 4</xref> shows the EM local decoding results, with superimposed error bars indicating the 0.025 and 0.975 quantiles given by the Poisson distribution with mean values taken from the EM solution. Hidden-state credibility time-series plots derived from the Poisson-gamma model marginal posterior samples are included in the figure. The agreement between the local decoding results and the Bayesian hidden-state credibility trajectory is striking, given the very different nature of the analyses on which these two results are based. The hidden-state mean-duration median estimates are included in 
                    <xref ref-type="table" rid="T1">Table 1</xref>, together with their 0.25 and 0.75 quantiles. These statistics are derived from the transition matrix diagonal elements, and their imprecision is, in part, a reflection of the lack of precision in the transition probabilities. The uncertainty in the mean duration estimate becomes inflated as the transition probability approaches unity. Nevertheless, the mean-duration 50% intervals are not so large as to render these estimates meaningless in the clinical context.</p>
                <fig fig-type="figure" id="f4" orientation="portrait" position="float">
                    <label>Figure 4. </label>
                    <caption>
                        <title>Case 1 (single extreme-value case) 2-state time-series plots.</title>
                        <p>(
                            <bold>a</bold>) Local decoding results. Local decoding was performed to determine which of the two states is most likely at each occasion. The estimated mean seizure rate (
                            <italic toggle="yes">&#x03bb;</italic>
                            <sub>1</sub>=1.03, 
                            <italic toggle="yes">&#x03bb;</italic>
                            <sub>2</sub>=5.28) associated with each of the two states is shown by the trapezoidal-shaped line, with superimposed error bars showing the 0.025 and 0.975 quantiles given by the Poisson distribution. The observed seizure counts are shown as filled circles. (The global decoding results are identical.) (
                            <bold>b</bold>) hidden-state credibility trajectories derived from the Bayesian Poisson-gamma 2-HM model. State credibility is defined as 
                            <inline-formula>
                                <mml:math display="inline" id="M3">
                                    <mml:mrow>
                                        <mml:mi>P</mml:mi>
                                        <mml:mrow>
                                            <mml:mo>(</mml:mo>
                                            <mml:mrow>
                                                <mml:msub>
                                                    <mml:mi>Z</mml:mi>
                                                    <mml:mi>t</mml:mi>
                                                </mml:msub>
                                                <mml:mo>=</mml:mo>
                                                <mml:mi>i</mml:mi>
                                                <mml:mo>|</mml:mo>
                                                <mml:mtext mathvariant="italic">data</mml:mtext>
                                            </mml:mrow>
                                            <mml:mo>)</mml:mo>
                                        </mml:mrow>
                                        <mml:mo>=</mml:mo>
                                        <mml:mo>#</mml:mo>
                                        <mml:mrow>
                                            <mml:mrow>
                                                <mml:mo>{</mml:mo>
                                                <mml:msubsup>
                                                    <mml:mi>Z</mml:mi>
                                                    <mml:mi>t</mml:mi>
                                                    <mml:mrow>
                                                        <mml:mrow>
                                                            <mml:mo>(</mml:mo>
                                                            <mml:mi>T</mml:mi>
                                                            <mml:mo>)</mml:mo>
                                                        </mml:mrow>
                                                    </mml:mrow>
                                                </mml:msubsup>
                                                <mml:mo>=</mml:mo>
                                                <mml:mi>i</mml:mi>
                                                <mml:mo>}</mml:mo>
                                            </mml:mrow>
                                            <mml:mo>/</mml:mo>
                                            <mml:mrow>
                                                <mml:msub>
                                                    <mml:mi>N</mml:mi>
                                                    <mml:mrow>
                                                        <mml:mi>s</mml:mi>
                                                        <mml:mi>i</mml:mi>
                                                        <mml:mi>m</mml:mi>
                                                    </mml:mrow>
                                                </mml:msub>
                                            </mml:mrow>
                                        </mml:mrow>
                                    </mml:mrow>
                                </mml:math>
                            </inline-formula> (see 
                            <xref ref-type="sec" rid="N5">Note S5</xref> for an explanation of the notation used in this expression). The trajectories given by the log-linear model are visually indistinguishable. (
                            <bold>c</bold>) Plot indicating which of the two states is the most credible on each occasion, i.e., the state with the largest value of 
                            <italic toggle="yes">P</italic>(
                            <italic toggle="yes">Z
                                <sub>t</sub>
                            </italic> = 
                            <italic toggle="yes">i|data</italic>). The log-linear and Poisson-Gamma plots are identical.</p>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/10507/5b001739-d79d-4ffb-ab46-190631b22c0a_figure4.gif"/>
                </fig>
            </sec>
            <sec>
                <title>Case 1. Sojourn-time statistics</title>
                <p>The main motivation for the HM modelling exercise outlined in this paper is the provision of information on the expected duration of each seizure state. Accordingly, the Case 1 2-state HMM transition-matrix posterior samples were used to calculate the sojourn-time probability densities, together with the associated cumulative distributions (
                    <italic toggle="yes">F</italic>(
                    <italic toggle="yes">s</italic>), where 
                    <italic toggle="yes">s</italic> is sojourn time) and complementary cumulative distributions (1 
                    <italic toggle="yes">&#x2212;F</italic>(
                    <italic toggle="yes">s</italic>)). The cumulative distributions (i.e., cumulative probabilities) provide an estimate of the probability that each seizure state will persist for up to some specified time, while each complementary cumulative distribution gives an estimate of the probability that a given state will persist for longer than the specified time. (As stated in the Methods section, this complementary cumulative probability is equivalent to the survivor function that is well known in survival analysis.) We have chosen to show the complementary cumulative distributions rather than the probability densities because they provide sojourn-time information in a form that is more easily communicated among clinicians. The Case 1 2-HMM log-linear model complementary cumulative probability distributions are shown in 
                    <xref ref-type="fig" rid="f5">Figure 5</xref>.</p>
                <fig fig-type="figure" id="f5" orientation="portrait" position="float">
                    <label>Figure 5. </label>
                    <caption>
                        <title>Case 1. Low and high seizure-state sojourn-time complementary cumulative distributions, as given by the 2-state log-linear model.</title>
                        <p>The centre curve (full line) shows the median estimate; the surrounding curves (dashed lines) show the 0.1, 0.25, 0.75 and 0.9 quantiles. From a clinical perspective these curves suggest that the patient is expected to be in a high seizure state more often than a low seizure state. The probability that a low seizure state persists for more than 10 weeks is negligible, whereas the median curve indicates that a high seizure state lasting more than 10 weeks would not be surprising. If a change in treatment led to a low seizure state for more than 10 weeks, then it would be clinically justifiable to conclude that the treatment change had been effective.</p>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/10507/5b001739-d79d-4ffb-ab46-190631b22c0a_figure5.gif"/>
                </fig>
                <p>In order to provide a clear clinical insight into the information that can be extracted from these distributions, and taking 2 weeks as an example, the median estimate obtained for the probability that each of the sojourn times exceeds 2 weeks (Prob(
                    <italic toggle="yes">s</italic> &gt; 2)) is 5.1% (25% and 75% posterior quantiles: 1.2%, 13%), and 68% (25% and 75% posterior quantiles: 56%, 78%) for States 1 and 2, respectively. Two points emerge from an inspection of 
                    <xref ref-type="fig" rid="f5">Figure 5</xref>. Firstly, the estimation error is considerable. Secondly, regardless of the estimation error, a considerable range of sojourn times must be expected; this is an inescapable consequence of the stochastic nature of the processes and is unrelated to parameter estimation error. Periods of high seizure frequency lasting many weeks are not unexpected under these HM models. Thus the occurrence of a long period of higher than average seizure activity does not necessarily indicate a change in the underlying pathology or a permanent deterioration. An awareness that clinicians should expect to see a considerable variation in the duration of unusual seizure activity might minimise excessive treatment.</p>
            </sec>
            <sec>
                <title>Case 2. Changepoint behaviour. 3-state model results</title>
                <p>The most striking feature of the time series data acquired from the second patient is an abrupt fall in seizure rate after the 23rd week (
                    <xref ref-type="fig" rid="f6">Figure 6</xref>), despite no change in treatment. The need to capture this change point, together with the occurrence of two occasions with an unusually high seizure rate, renders this second case somewhat more challenging than the first. Three alternative HMMs were examined in their capacity to capture the observations, namely a 3-state HMM with constant state-specific Poisson parameters (3-HM), a 3-state HMM with AR(1) time dependence in the Poisson parameters (3-HM-AR) and a 3-state HMM based on state-specific rate parameters that include a temporal random effect term with a conditional autoregressive prior distribution (3-HM-CAR). (The distinction between an autoregressive likelihood and an autoregressive prior is important.) Posterior predictive simulation was performed to examine the capacity of these models to capture important features of the data. Visual inspection of the plots given in 
                    <xref ref-type="fig" rid="f6">Figure 6</xref> indicates that the simple 3-state HMM appears to account for the main features of the data although the posterior predictive residuals show some structure. Adding AR(1) dependence offers no substantial improvement (graphical output produced using the AR1 model is not included in this report), while the 3-HM-CAR residuals show less departure from the ideal distribution about zero. Despite these observations, posterior predictive tests suggest that the simple 3-state models are adequate. Details are given in 
                    <xref ref-type="sec" rid="N6">Note S6</xref>. Parameter estimates given by three 3-HM model analyses are listed in 
                    <xref ref-type="table" rid="T2">Table 2</xref>. An important finding emerges from the model assessment exercise, namely that the random effect term that is incorporated into the 3-HM-CAR model tends to dominate the fitted time dependence, hidden-state transitions making a relatively small contribution to the seizure rate changes. Thus, although the 3-HM-CAR model provides an important standard against which the simpler models can be compared, in Case 2 we regard the 3-HM-CAR model as uninteresting from a clinical perspective (see 
                    <xref ref-type="sec" rid="N6">Note S6</xref> for additional information).</p>
                <fig fig-type="figure" id="f6" orientation="portrait" position="float">
                    <label>Figure 6. </label>
                    <caption>
                        <title>Case2. Observed time-series data and posterior predictive simulation results.</title>
                        <p>(Top row, column 
                            <bold>a</bold>) Time series data collected from a patient (Case 2) with two distinct seizure activity phases. (Columns 
                            <bold>b</bold> and 
                            <bold>c</bold>) Log-linear model posterior predictive simulation results generated using two alternative 3-state HMMs. The first is a standard 3-state HMM, while the Poisson rate parameters of the second model include an additional random effects term. Each top-row plot shows 10 replicate posterior-predictive time series generated by resampling the posterior predictive simulation output at evenly spaced MCMC iterations. The associated residuals plots are given in the bottom row.</p>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/10507/5b001739-d79d-4ffb-ab46-190631b22c0a_figure6.gif"/>
                </fig>
                <table-wrap id="T2" orientation="portrait" position="anchor">
                    <label>Table 2. </label>
                    <caption>
                        <title>Case 2.</title>
                        <p>3-state HMM parameter statistics.</p>
                    </caption>
                    <table content-type="article-table" frame="hsides">
                        <thead>
                            <tr>
                                <th align="center" colspan="1" rowspan="2">Parameter</th>
                                <th align="center" colspan="3" rowspan="1">Algorithm - Model</th>
                            </tr>
                            <tr>
                                <th align="center" colspan="1" rowspan="1">log-linear</th>
                                <th align="center" colspan="1" rowspan="1">Poi-gamma</th>
                                <th align="center" colspan="1" rowspan="1">3-HM-AR</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td align="center" colspan="1" rowspan="1">
                                    <italic toggle="yes">&#x03bb;</italic>
                                    <sub>1</sub>
                                </td>
                                <td align="center" colspan="1" rowspan="1">3.70 (0.08, 5.26)</td>
                                <td align="center" colspan="1" rowspan="1">3.22 (0.003, 5.10)</td>
                                <td align="center" colspan="1" rowspan="1">0.25 - 0.32</td>
                            </tr>
                            <tr>
                                <td align="center" colspan="1" rowspan="1">
                                    <italic toggle="yes">&#x03bb;</italic>
                                    <sub>2</sub>
                                </td>
                                <td align="center" colspan="1" rowspan="1">6.55 (3.95, 13.0)</td>
                                <td align="center" colspan="1" rowspan="1">5.64 (3.78, 12.56)</td>
                                <td align="center" colspan="1" rowspan="1">3.1 - 4.1</td>
                            </tr>
                            <tr>
                                <td align="center" colspan="1" rowspan="1">
                                    <italic toggle="yes">&#x03bb;</italic>
                                    <sub>3</sub>
                                </td>
                                <td align="center" colspan="1" rowspan="1">12.73 (10.94, 17.24)</td>
                                <td align="center" colspan="1" rowspan="1">12.57 (10.83, 16.68)</td>
                                <td align="center" colspan="1" rowspan="1">10.5 - 12.3</td>
                            </tr>
                            <tr>
                                <td align="center" colspan="1" rowspan="1">
                                    <italic toggle="yes">P</italic>
                                    <sub>11</sub>
                                </td>
                                <td align="center" colspan="1" rowspan="1">0.68 (0.05, 0.96)</td>
                                <td align="center" colspan="1" rowspan="1">0.53 (0.03, 0.95)</td>
                                <td align="center" colspan="1" rowspan="1">0.27 (0.01, 0.75)</td>
                            </tr>
                            <tr>
                                <td align="center" colspan="1" rowspan="1">
                                    <italic toggle="yes">P</italic>
                                    <sub>12</sub>
                                </td>
                                <td align="center" colspan="1" rowspan="1">0.18 (0.005, 0.80)</td>
                                <td align="center" colspan="1" rowspan="1">0.27 (0.008, 0.84)</td>
                                <td align="center" colspan="1" rowspan="1">0.42 (0.03, 0.87)</td>
                            </tr>
                            <tr>
                                <td align="center" colspan="1" rowspan="1">
                                    <italic toggle="yes">P</italic>
                                    <sub>13</sub>
                                </td>
                                <td align="center" colspan="1" rowspan="1">0.095 (0.004, 0.57)</td>
                                <td align="center" colspan="1" rowspan="1">0.11 (0.004, 0.61)</td>
                                <td align="center" colspan="1" rowspan="1">0.21 (0.01, 0.80)</td>
                            </tr>
                            <tr>
                                <td align="center" colspan="1" rowspan="1">
                                    <italic toggle="yes">P</italic>
                                    <sub>21</sub>
                                </td>
                                <td align="center" colspan="1" rowspan="1">0.20 (0.01, 0.75)</td>
                                <td align="center" colspan="1" rowspan="1">0.20 (0.01, 0.75)</td>
                                <td align="center" colspan="1" rowspan="1">0.12 (0.01, 0.48)</td>
                            </tr>
                            <tr>
                                <td align="center" colspan="1" rowspan="1">
                                    <italic toggle="yes">P</italic>
                                    <sub>22</sub>
                                </td>
                                <td align="center" colspan="1" rowspan="1">0.50 (0.03, 0.92)</td>
                                <td align="center" colspan="1" rowspan="1">0.55 (0.03, 0.92)</td>
                                <td align="center" colspan="1" rowspan="1">0.74 (0.10, 0.95)</td>
                            </tr>
                            <tr>
                                <td align="center" colspan="1" rowspan="1">
                                    <italic toggle="yes">P</italic>
                                    <sub>23</sub>
                                </td>
                                <td align="center" colspan="1" rowspan="1">0.19 (0.01, 0.82)</td>
                                <td align="center" colspan="1" rowspan="1">0.16 (0.006, 0.80)</td>
                                <td align="center" colspan="1" rowspan="1">0.12 (0.004, 0.63)</td>
                            </tr>
                            <tr>
                                <td align="center" colspan="1" rowspan="1">
                                    <italic toggle="yes">P</italic>
                                    <sub>31</sub>
                                </td>
                                <td align="center" colspan="1" rowspan="1">0.066 (0.002, 0.42)</td>
                                <td align="center" colspan="1" rowspan="1">0.057 (0.002, 0.36)</td>
                                <td align="center" colspan="1" rowspan="1">0.028 (0.001, 0.14)</td>
                            </tr>
                            <tr>
                                <td align="center" colspan="1" rowspan="1">
                                    <italic toggle="yes">P</italic>
                                    <sub>32</sub>
                                </td>
                                <td align="center" colspan="1" rowspan="1">0.15 (0.01, 0.80)</td>
                                <td align="center" colspan="1" rowspan="1">0.12 (0.008, 0.75)</td>
                                <td align="center" colspan="1" rowspan="1">0.11 (0.01, 0.30)</td>
                            </tr>
                            <tr>
                                <td align="center" colspan="1" rowspan="1">
                                    <italic toggle="yes">P</italic>
                                    <sub>33</sub>
                                </td>
                                <td align="center" colspan="1" rowspan="1">0.77 (0.05, 0.95)</td>
                                <td align="center" colspan="1" rowspan="1">0.80 (0.08, 0.95)</td>
                                <td align="center" colspan="1" rowspan="1">0.86 (0.65, 0.97)</td>
                            </tr>
                            <tr>
                                <td align="center" colspan="1" rowspan="1">
                                    <italic toggle="yes">d</italic>
                                    <sub>1</sub>
                                </td>
                                <td align="center" colspan="1" rowspan="1">3.11 (1.54, 6.28)</td>
                                <td align="center" colspan="1" rowspan="1">2.11 (1.35, 4.94)</td>
                                <td align="center" colspan="1" rowspan="1">.</td>
                            </tr>
                            <tr>
                                <td align="center" colspan="1" rowspan="1">
                                    <italic toggle="yes">d</italic>
                                    <sub>2</sub>
                                </td>
                                <td align="center" colspan="1" rowspan="1">2.00 (1.33, 3.44)</td>
                                <td align="center" colspan="1" rowspan="1">2.22 (1.42, 3.79)</td>
                                <td align="center" colspan="1" rowspan="1">.</td>
                            </tr>
                            <tr>
                                <td align="center" colspan="1" rowspan="1">
                                    <italic toggle="yes">d</italic>
                                    <sub>3</sub>
                                </td>
                                <td align="center" colspan="1" rowspan="1">4.33 (2.26, 7.05)</td>
                                <td align="center" colspan="1" rowspan="1">5.12 (3.17, 8.12)</td>
                                <td align="center" colspan="1" rowspan="1">.</td>
                            </tr>
                        </tbody>
                    </table>
                    <table-wrap-foot>
                        <fn>
                            <p>Case 2 3-state HMM parameter statistics are listed, as given by an MCMC implementation of the Bayesian log-linear and Poisson-gamma models, and the 3-HM-AR model. The first two data columns list the Poisson parameter (
                                <italic toggle="yes">&#x03bb;</italic>) and transition probability (
                                <italic toggle="yes">P</italic>) median estimates, together with the 0.025 and 0.975 quantiles, which are given in brackets. The mean duration estimates (
                                <italic toggle="yes">d</italic>), as given by 1
                                <italic toggle="yes">/</italic>(1
                                <italic toggle="yes">&#x2212;P
                                    <sub>ii</sub>
                                </italic> ), 
                                <italic toggle="yes">i</italic> = 1, 2, 3, are also listed. The mean duration 95% intervals are large, due to uncertainty in the transition probabilities from which these are derived, coupled with the inflation that occurs as 1 
                                <italic toggle="yes">&#x2212; P
                                    <sub>ii</sub>
                                </italic> tends to zero. We have, therefore, chosen to list the 0.25 and 0.75 mean duration quantiles, since these do provide useful clinical information. The third data column provides the 3-HM-AR model statistics. In this case the Poisson rates vary with time and are therefore listed as ranges, as given by the median minimum and maximum estimates.</p>
                        </fn>
                    </table-wrap-foot>
                </table-wrap>
            </sec>
            <sec>
                <title>Case 2. Mean-duration statistics</title>
                <p>The Case 2 hidden-state mean-duration statistics are listed in 
                    <xref ref-type="table" rid="T2">Table 2</xref> together with the associated Poisson-rate parameter and transition probability statistics. The model parameter estimates together with the corresponding hidden-state trajectory plots (this hidden-state graphical output is not included in this report) indicate that transitions between adjacent states have a non-negligible probability both before and after the change-point and that the system is not held in a high-activity state prior to the changepoint and a low activity state afterwards.</p>
                <p>Among the other points that emerge from the analysis is the considerable uncertainty in the hidden-state trajectory underlying the observed count data. The identity of the hidden state is particularly uncertain on some occasions. The fact remains that, under the Poisson distribution, a relatively high count can arise by chance even when the system is in a low seizure state, and cannot be attributed with certainty to an underlying high seizure-rate state. Thus, a series of consecutive occasions during which the seizure counts are consistently high does not rule out the possibility of underlying transitions between high and lower activity states. Furthermore, a sequence of consecutive occasions with no change in the most probable state does not preclude the possibility that transitions have occurred. Finally, 
                    <xref ref-type="table" rid="T2">Table 2</xref> includes the 3-HM-AR Poisson rates and transition-probability estimates, showing that these differ substantially from those obtained with the simple 3-HM models. It is not surprising that introducing time dependence into the Poisson rate parameters substantially alters the transition statistics.</p>
            </sec>
            <sec>
                <title>Case 2. Other models</title>
                <p>Additional analyses were performed using a number of 2-state and single-state models. Although the 2-HM-CAR model yields very satisfactory posterior predictive simulation results, it happens to exhibit the same random effect dominance described above for the 3-HM-CAR model. For that reason, in Case 2, it is uninteresting from a clinical perspective. Similarly, the single state-CAR model is dismissed as lacking in terms of the clinical insight it provides in Case 2, although it is not ruled out by the posterior predictive simulation analysis. The posterior predictive simulation results obtained with the 2-HM and 2-HM-AR models indicate that these models tend to produce Bayesian p-values that are low, although these do not fall below 0.05 (Bayesian p-value details not included). Based on these observations, the following section focusses on the sojourn time statistics derived from the time-independent log-linear 3-state model.</p>
            </sec>
            <sec>
                <title>Case 2. Sojourn-time statistics</title>
                <p>As in the previous case, we again resort to using the posterior marginal samples obtained for the transition matrix diagonal elements, in conjunction with the geometric distribution, as a mechanism for generating the state sojourn-time probability densities and their associated complementary cumulative distributions. 
                    <xref ref-type="fig" rid="f7">Figure 7</xref> shows the results given by the log-linear 3-HM model. Taking an example duration-of-interest equal to 2 weeks, the median estimate obtained for the probability that the sojourn time exceeds 2 weeks (Prob(
                    <italic toggle="yes">s &gt;</italic> 2)) is 46% (25% and 75% posterior quantiles: 12%, 71%), 25% (25% and 75% posterior quantiles: 6%, 50%) and 59% (25% and 75% posterior quantiles: 31%, 74%) for States 1, 2 and 3, respectively. Although the median curves might give the impression of a difference between States 2 and 3, the estimation error is too large to allow any definite conclusion other than the inescapable fact that, putting estimation error aside, the duration of each of the states is expected to exhibit considerable variability due to the stochastic nature of the process.</p>
                <fig fig-type="figure" id="f7" orientation="portrait" position="float">
                    <label>Figure 7. </label>
                    <caption>
                        <title>Case 2 seizure-state sojourn-time complementary cumulative distributions.</title>
                        <p>Sojourn-time complementary cumulative distributions are shown, as given by the log-linear 3-HM model. The centre curve in each graph (full line) shows the median estimate; the surrounding curves (dashed lines) show the 0.1, 0.25, 0.75 and 0.9 quantiles. These curves, taken in combination with the parameter estimates given in 
                            <xref ref-type="table" rid="T2">Table 2</xref>, indicate that a treatment-induced reduction in the duration of the intermediate and high frequency states would be beneficial, in addition to any intervention that reduces the Poisson rates.</p>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/10507/5b001739-d79d-4ffb-ab46-190631b22c0a_figure7.gif"/>
                </fig>
            </sec>
            <sec>
                <title>Case 3. Quadratic behaviour</title>
                <p>A striking feature of the time series collected from Case 3 is the appearance of a quadratic time dependence in the underlying seizure activity (
                    <xref ref-type="fig" rid="f8">Figure 8</xref>). It is well known, however, that autoregressive processes can give rise to data that are deceptive in their shape, taking on a profile that appears deterministic. The preceding three 3-state HMMs (i.e., 3-HM, 3-HM-AR, and 3-HM-CAR models) were each investigated for their capacity to capture the observations, together with an HMM supplemented with a second-order polynomial (3-HM-quad). The corresponding 2-state models were also examined, together with the simple single-state quadratic model. Details concerning the various model adequacy tests that were performed are given in 
                    <xref ref-type="sec" rid="N7">Note S7</xref>. Here we focus on the 2-state quadratic model (2-HM-quad), which was found to be adequate (Bayesian p-values of 0.21 and 0.34 were obtained for the two curvature tests defined in 
                    <xref ref-type="sec" rid="N7">Note S7</xref>). The transition matrix and mean state-duration statistics derived from this model are included in 
                    <xref ref-type="table" rid="T3">Table 3</xref>.</p>
                <fig fig-type="figure" id="f8" orientation="portrait" position="float">
                    <label>Figure 8. </label>
                    <caption>
                        <title>Case 3 time-series data.</title>
                        <p>The observed seizure counts in the third patient give the appearance of an underlying quadratic trend in seizure activity.</p>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/10507/5b001739-d79d-4ffb-ab46-190631b22c0a_figure8.gif"/>
                </fig>
                <table-wrap id="T3" orientation="portrait" position="anchor">
                    <label>Table 3. </label>
                    <caption>
                        <title>Case 3.</title>
                        <p>2-HM-quad model parameter statistics.</p>
                    </caption>
                    <table content-type="article-table" frame="hsides">
                        <thead>
                            <tr>
                                <th align="left" colspan="1" rowspan="1">Parameter</th>
                                <th align="left" colspan="1" rowspan="1">posterior
                                    <break/>median</th>
                                <th align="left" colspan="1" rowspan="1">posterior interval</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td align="left" colspan="1" rowspan="1">
                                    <italic toggle="yes">&#x03bb;</italic>
                                    <sub>1</sub>
                                </td>
                                <td align="left" colspan="1" rowspan="1">8.1 - 13.7</td>
                                <td align="left" colspan="1" rowspan="1">5.5, 11.6; 10.2, 18.3</td>
                            </tr>
                            <tr>
                                <td align="left" colspan="1" rowspan="1">
                                    <italic toggle="yes">&#x03bb;</italic>
                                    <sub>2</sub>
                                </td>
                                <td align="left" colspan="1" rowspan="1">13.2 - 22.4</td>
                                <td align="left" colspan="1" rowspan="1">9.9, 18.1; 19.2, 26.6</td>
                            </tr>
                            <tr>
                                <td align="left" colspan="1" rowspan="1">
                                    <italic toggle="yes">P</italic>
                                    <sub>11</sub>
                                </td>
                                <td align="left" colspan="1" rowspan="1">0.50</td>
                                <td align="left" colspan="1" rowspan="1">0.12, 0.84</td>
                            </tr>
                            <tr>
                                <td align="left" colspan="1" rowspan="1">
                                    <italic toggle="yes">P</italic>
                                    <sub>12</sub>
                                </td>
                                <td align="left" colspan="1" rowspan="1">0.50</td>
                                <td align="left" colspan="1" rowspan="1">0.16, 0.88</td>
                            </tr>
                            <tr>
                                <td align="left" colspan="1" rowspan="1">
                                    <italic toggle="yes">P</italic>
                                    <sub>21</sub>
                                </td>
                                <td align="left" colspan="1" rowspan="1">0.28</td>
                                <td align="left" colspan="1" rowspan="1">0.08, 0.67</td>
                            </tr>
                            <tr>
                                <td align="left" colspan="1" rowspan="1">
                                    <italic toggle="yes">P</italic>
                                    <sub>22</sub>
                                </td>
                                <td align="left" colspan="1" rowspan="1">0.72</td>
                                <td align="left" colspan="1" rowspan="1">0.33, 0.92</td>
                            </tr>
                            <tr>
                                <td align="left" colspan="1" rowspan="1">
                                    <italic toggle="yes">d</italic>
                                    <sub>1</sub>
                                </td>
                                <td align="left" colspan="1" rowspan="1">2.0</td>
                                <td align="left" colspan="1" rowspan="1">1.6, 2.7</td>
                            </tr>
                            <tr>
                                <td align="left" colspan="1" rowspan="1">
                                    <italic toggle="yes">d</italic>
                                    <sub>2</sub>
                                </td>
                                <td align="left" colspan="1" rowspan="1">3.6</td>
                                <td align="left" colspan="1" rowspan="1">2.6, 5.0</td>
                            </tr>
                        </tbody>
                    </table>
                    <table-wrap-foot>
                        <fn>
                            <p>The Poisson rate (
                                <italic toggle="yes">&#x03bb;</italic>), transition probability (
                                <italic toggle="yes">P</italic>) and mean duration (
                                <italic toggle="yes">d</italic>) median estimates are listed in the first data column. The rates, which are time dependent, are given as ranges, based on the median minimum and maximum estimates. The second data column provides the Poisson rate and transition-probability posterior 0.025 and 0.975 quantiles, and the mean duration 0.25 and 0.75 quantile estimates.</p>
                        </fn>
                    </table-wrap-foot>
                </table-wrap>
            </sec>
            <sec>
                <title>Case 3. Sojourn-time statistics</title>
                <p>
                    <xref ref-type="fig" rid="f9">Figure 9</xref> shows the Case 3 sojourn-time complementary cumulative probability distributions given by the 2-HM-quad model. If, as in the previous cases, we take a 2-week duration-of-interest, the median estimates obtained for the probability that the sojourn time exceeds 2 weeks (Prob(
                    <italic toggle="yes">s &gt;</italic> 2)) are 25% (25% and 75% posterior quantiles: 14%, 39%) and 51.8% (25% and 75% posterior quantiles: 38%, 64%) for States 1 and 2, respectively. The considerable uncertainty in these estimates is a reflection of the limited amount of data available for analysis. This lack of precision must be taken into consideration if sojourn times are to be used in clinical decision making, albeit in conjunction with other information. Putting this imprecision aside, the results do serve to illustrate the important fact that, at any point in time, an additional and considerable uncertainty exists regarding imminent behaviour, due to the fundamentally stochastic nature of the process.</p>
                <fig fig-type="figure" id="f9" orientation="portrait" position="float">
                    <label>Figure 9. </label>
                    <caption>
                        <title>Case 3 seizure-state sojourn-time complementary cumulative distributions.</title>
                        <p>Complementary cumulative distributions are shown for the low and high seizure-rate states, as given by the 2-HM-quad model. The centre curve in each graph (full line) shows the median estimate; the surrounding curves (dashed lines) show the 0.1, 0.25, 0.75 and 0.9 quantiles. The median curve shown in the right-hand plot suggests that high seizure-state episodes lasting more than 15 weeks are low in probability. The patient and physician could agree that if a future high seizure episode lasts more than 15 weeks, for example, a treatment change could be considered. The converse is that a treatment change would not be recommended unless this condition is met, minimising treatment modifications to those that are most appropriate.</p>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/10507/5b001739-d79d-4ffb-ab46-190631b22c0a_figure9.gif"/>
                </fig>
            </sec>
        </sec>
        <sec sec-type="discussion">
            <title>Discussion</title>
            <p>The major finding in the current study is that clinically important patient-specific information can be extracted from seizure frequencies recorded over time using HM modelling. This statistical approach was useful across a variety of seizure patterns with a small but clinically appropriate number of observations, suggesting that it should generalise to much of the population with medically intractable epilepsy.</p>
            <p>The fluctuating nature of seizure frequencies in people with medically intractable epilepsy is increasingly being recognised (see 
                <xref ref-type="bibr" rid="ref-3">3</xref>, for example). Without this recognition patients with epilepsy frequently seek medical advice during times of increased seizure frequency and are often prescribed either higher doses of current antiepileptic drugs or new antiepileptic drugs are initiated. This can lead to treatment with excessive doses or polytherapy which results in an increase in the number of side effects
                <sup>
                    <xref ref-type="bibr" rid="ref-3">3</xref>,
                    <xref ref-type="bibr" rid="ref-28">28</xref>
                </sup>. An unfortunate consequence is that quality of life is then impacted by the combined effects of the underlying etiology, the side effects of medication and the inability to completely prevent seizures. A way to prevent overtreatment is to understand the nature of the spontaneous changes that occur in seizure activity and thus determine whether a given altered seizure pattern should be rejected as a reason for a change in medication. We show that clinically relevant parameters can be obtained using HM modelling in three cases representing very different seizure frequency patterns.</p>
            <p>In each of the three cases presented in this paper, the observed data are overdispersed relative to the Poisson distribution, suggesting the presence of at least two seizure states (low and high frequency states). The state-specific mean seizure frequencies and sojourn-time statistics are useful for informing patients and their parents of what might be expected in the future, assuming that the biological or environmental processes influencing seizure frequency remain unchanged. Case 1 is an example in which seizure fluctuations over the course of a year were largely stable. According to the HMM results, the high-frequency state dominates, the estimated probability of a low-frequency episode lasting longer than 2 weeks being about 5% (median estimate of the complementary cumulative probability). If this patient were to be treated during a high frequency state, a change to a low frequency state would often be interpreted as a positive therapeutic effect. The return to a high frequency state is frequently considered to be the end of the &#x2018;honeymoon period&#x2019;. But, given the absence of any change in treatment during the study period in this individual, the observed differences in weekly seizure counts must be attributed to the underlying pathophysiology. It should be noted that, due to the relatively short duration of the time series used in this analysis, the precision of the 2-week complementary cumulative probability estimate given above is low (the 75% quantile is 13%).</p>
            <p>The other two cases appear more complex, but similar information can be derived from the seizure data. Despite the absence of a change in therapy, Case 2 underwent a marked change in seizure activity during the observation period. A 3-state HMM was used in the analysis of these data, the results suggesting that the highest seizure-rate state dominated the first half of the observation period, after which the lower activity states were dominant (hidden-state plots not shown). Given the data acquired during the first half of the observation period, one might have predicted that the pattern would have continued. The seizure pattern did change, however, and a question for the clinician is whether the patient might revert to the high frequency state. According to the simple 3-state models (the two Bayesian 3-HM models and corresponding AR analysis), the probability of a transition from the intermediate state to the high frequency state is in the range 0.12 to 0.19 (based on median estimates; the posterior/confidence intervals are given in 
                <xref ref-type="table" rid="T2">Table 2</xref>). Similarly, the probability of a transition from the lowest to highest activity state is non-negligible. This is important information for families who need to be prepared for a return to the highest frequency state, and should be informed about the possibility of this happening.</p>
            <p>Case 3 appears to exhibit a quadratic time dependence in seizure rate, which can be captured by including linear and quadratic terms in the log-linear expression for the HMM Poisson rates. Despite the time dependence in the resulting state-specific rates, the hidden state transitions remain an important source of seizure-frequency variation. The transition probabilities and sojourn-time statistics thus retain their clinical significance. It should be noted that, while the HM modelling approach outlined in this paper is general in its application, and expected to apply to any seizure-count time series that might be encountered, the model details must be tailored to each individual. Thus, although simple HMMs with time independent Poisson rates offer the advantage of simplicity, cases will arise where more complex models are required. Case 3 (quadratic case) provides an example where simple 2- and 3-state HMMs were demonstrably inadequate. Although we concluded that, for differing reasons, the AR and CAR models had little to offer in the present three cases, we envisage cases where these will be useful for dealing with subtle but non-ignorable trends in the state-specific rates. Furthermore, the CAR (random effect) HMMs provided a flexible and useful standard against which to judge simpler models in their capacity to produce satisfactory posterior predictive simulation residuals.</p>
            <p>This paper demonstrates that HMMs provide a characterisation of case-specific seizure patterns in a manner that is relevant to both the clinician and their patients. Clinical trials in patients with epilepsy tend to use average seizure frequencies over a time period of about 6 weeks. However, this approach may miss important information about changes in seizure pattern that could be captured using some form of HMM. This raises the question regarding the use of seizure pattern as an outcome in future drug trials, rather than simply averaging seizure frequency. Clearly, a typical clinical trial aims to provide population statistics, which appears to be very different to the present work where the focus is parameter estimation and decision making as it applies to the individual. The present results show that one cannot expect to obtain subject-specific HMM parameter estimates with good precision, given a single observation period that is restricted to a few weeks. It might be argued that a solution to this problem is to adopt a pooled-data (population modelling) analysis. This is a well-documented approach to improving the precision of subject-specific estimates when the data are sparse
                <sup>
                    <xref ref-type="bibr" rid="ref-29">29</xref>,
                    <xref ref-type="bibr" rid="ref-30">30</xref>
                </sup>. Thus, population modelling might be considered in the present subject-specific estimation context, in addition to its obvious application in clinical trials. Unfortunately, we do not have the information required to undertake a meaningful pooled-data analysis. The central problem is the marked difference between individuals regarding their seizure behaviour. Although patient heterogeneity has been dealt with in other applications by including covariates in a pooled-data model, this requires a comprehensive set of covariates to account for important differences between cases. It assumes a detailed knowledge of the relationship between the covariates and the model parameters
                <sup>
                    <xref ref-type="bibr" rid="ref-30">30</xref>
                </sup>. We do not have the data required to construct a general pooled-data model involving covariates. In particular, we do not have an exogenous variable for defining &#x2018;homogenous&#x2019; sub-populations.</p>
            <p>A final point needs to be addressed concerning the relatively poor precision of the parameter estimates reported in this paper. Some statisticians might argue that statistical modelling should not be attempted with short time series data. As a rejoinder we would suggest that important clinical decisions are currently made without any objective way of evaluating potential changes in seizure activity over time. This has a negative impact on the ability of the clinician to provide high quality and safe care to their patients. Thus, although we recognise that the model parameter estimates are compromised due to the necessity to work with short time series, the information provided by the models is far superior to anything currently available. Re-stated, a parameter estimate with a wide probability/confidence interval is better than pure guesswork.</p>
            <p>Among other objections that might be raised regarding the approach outlined in this paper is the level of user input it requires. This precludes its use in some clinical settings. We have emphasised that the details of the statistical model (and model adequacy tests) must be tailored to each subject-specific dataset. While the lack of a black box implementation rules out the possibility of using HM modelling as a routine clinical tool, that does not preclude its use in a tertiary referral centre dealing with the small proportion of patients with severe and intractable epilepsy. In that setting the assistance of a data analyst is a realistic possibility. For those who choose to reject this proposition, the results presented in this paper do, at the very least, suggest the need for some caution in responding to an apparently sudden increase in seizure activity.</p>
            <p>An interesting issue that arises in this work is an uncertainty regarding the interpretation that might be attached to a given HMM result, beyond the immediate clinical interpretation outlined above. There is a distinction between using a result as a convenient description of the observations, versus the supposition that it provides a real description of the neuronal processes underlying the observed seizures, thus providing real mechanistic insight. Some might reject the second of these perspectives, based on a premise that the neuronal processes are entirely deterministic and that stochastic models happen to capture the observations. A stochastic model might therefore be seen as a pragmatic solution to the absence of information on the underlying deterministic control system(s). We note that the discrimination between stochastic and deterministic behaviour in neuronal systems has been addressed (see, for example, 
                <xref ref-type="bibr" rid="ref-31">31</xref>,
                <xref ref-type="bibr" rid="ref-32">32</xref>). It might also be noted, however, that the very notion of tests designed to distinguish stochastic and deterministic behaviour might be questionable. Werndl (2009)
                <sup>
                    <xref ref-type="bibr" rid="ref-33">33</xref>
                </sup>, for example, states that every stochastic process is observationally equivalent to a deterministic system, and that many deterministic systems are observationally equivalent to stochastic processes. Regardless of these more philosophical questions, for the clinician faced with the problem of patient management, a model that merely provides a characterisation of the seizure time-series data remains useful, especially if it is reliable in its predictions. It does not matter if the model merely provides an empirical description of the observed seizure pattern, unrelated to the underlying pathophysiological process.</p>
            <sec>
                <title>Comments on the models and methods, including model assessment and convergence tests</title>
                <p>To keep this paper to a reasonable length we have not shown a comprehensive set of model assessment results, as obtained for every model and every case. Instead the content of the paper is designed to illustrate some of the modelling possibilities. The majority of posterior predictive simulation results are based on tests epileptologists will consider relevant to the clinical problem, for example, the number of occasions with an extreme seizure count. A related issue is whether or not the models should be regarded as definitive. We do not regard model selection with a view to finding the &#x2018;best&#x2019; model as being among the objectives. In this context there is a need to distinguish between modelling the data and modelling the process that gives rise to the data. In the latter setting model comparison and the search for the best model has a greater relevance. From a clinical perspective interest might be focused on modelling the data while those engaged in basic science research may be more interested in modelling with a view to shedding light on the underlying pathophysiology. It is our view that a clinician whose concern is patient management will be primarily interested in empirical statistical models that provide a useful characterisation of the observed time series and an insight into future seizure activity. Given this objective, we do not seek to find the best model. Instead, a comparison of the results derived from differing models is undertaken as a mechanism for assessing robustness. If different models yield consistent parameter estimates this is taken as an indicator that the estimates are sound. In that sense we do not necessarily regard alternative models as competing. This is the reason for showing the results given by both the Poisson-gamma and log-linear Bayesian models where applicable. As shown, we obtained reasonable agreement between the two models. Given the differing form of the likelihood and priors under these two models, together with the Poisson parameter ordering constraint that is incorporated into the log-linear model, the similarity in the parameter estimates suggests that these are robust, i.e., the results exhibit a desirable insensitivity to the priors and are predominantly determined by the data. Similarly, in those cases in which the EM algorithm was adopted and combined with parametric simulation (an example is given in 
                    <xref ref-type="table" rid="T1">Table 1</xref>), agreement between the resulting confidence intervals and the posterior marginal distributions derived from the corresponding Bayesian analyses is an indication of robustness. Having taken this approach to assessing the reliability of the statistics obtained for a given subject, we have attached less importance to convergence testing and simulation accuracy calculations. For example, agreement between the MCMC results given by a Bayesian model and those produced using parametric simulation based on an EM solution would be unexpected if effective convergence to a stationary distribution had not been achieved in the former case. That said, MCMC convergence test results are reported, as obtained for key model parameters.</p>
            </sec>
        </sec>
        <sec sec-type="conclusions">
            <title>Conclusion</title>
            <p>In conclusion, we have presented results obtained by fitting HMMs to the seizure data collected from three paediatric epilepsy patients. We suggest that these models provide useful clinical insights. In particular, we propose that sojourn time cumulative distributions are informative and a useful aid to clinical decision making in epileptology. Thus the HM modelling approach has the potential to make a major contribution to patient management, and could ultimately maximise quality of life.</p>
        </sec>
        <sec>
            <title>Data availability</title>
            <p>The data referenced by this article are under copyright with the following copyright statement: Copyright: &#x00ef;&#x00bf;&#x00bd; 2016 King MD et al.</p>
            <p>Data associated with the article are available under the terms of the Creative Commons Zero "No rights reserved" data waiver (CC0 1.0 Public domain dedication).
                <ext-link ext-link-type="uri" xlink:href="http://creativecommons.org/publicdomain/zero/1.0/"/>
            </p>
            <p>
				
                <italic toggle="yes">F1000Research</italic>: Dataset 1. Weekly seizure count data for each of the three cases presented in this report, 
                <ext-link ext-link-type="uri" xlink:href="http://dx.doi.org/10.5256/f1000research.9746.d138204">10.5256/f1000research.9746.d138204</ext-link>
                <sup>
                    <xref ref-type="bibr" rid="ref-34">34</xref>
                </sup>
            </p>
        </sec>
    </body>
    <back>
        <sec id="SM" sec-type="supplementary-material">
            <title>Supplementary material</title>
            <sec id="N1">
                <title>Note S1</title>
                <p>
                    <italic toggle="yes">
                        <bold>Hidden Markov models.</bold>
                    </italic> A discrete first order Markov process is a stochastic process in which the state probabilities on a given occasion depend only on the preceding state and, given that previous state, are independent of the more distant history. The term &#x2018;conditional independence&#x2019; is used in this context. To express this a little more formally, and using the notation 
                    <italic toggle="yes">Z</italic>
                    <sub>1</sub>, 
                    <italic toggle="yes">Z</italic>
                    <sub>2</sub>, 
                    <italic toggle="yes">Z</italic>
                    <sub>3</sub>, &#x2026; to represent a sequence of states, then 
                    <disp-formula id="e19">
                        <mml:math display="block" id="math2">
                            <mml:mrow>
                                <mml:mtext>Pr</mml:mtext>
                                <mml:mo>&#x2061;</mml:mo>
                                <mml:mrow>
                                    <mml:mo>(</mml:mo>
                                    <mml:mrow>
                                        <mml:msub>
                                            <mml:mi>Z</mml:mi>
                                            <mml:mrow>
                                                <mml:mi>t</mml:mi>
                                                <mml:mo>+</mml:mo>
                                                <mml:mn>1</mml:mn>
                                            </mml:mrow>
                                        </mml:msub>
                                        <mml:mo>|</mml:mo>
                                        <mml:msub>
                                            <mml:mi>Z</mml:mi>
                                            <mml:mi>t</mml:mi>
                                        </mml:msub>
                                        <mml:mo>,</mml:mo>
                                        <mml:mo>&#x2026;</mml:mo>
                                        <mml:mo>,</mml:mo>
                                        <mml:msub>
                                            <mml:mi>Z</mml:mi>
                                            <mml:mn>1</mml:mn>
                                        </mml:msub>
                                    </mml:mrow>
                                    <mml:mo>)</mml:mo>
                                </mml:mrow>
                                <mml:mo>=</mml:mo>
                                <mml:mtext>Pr</mml:mtext>
                                <mml:mo>&#x2061;</mml:mo>
                                <mml:mrow>
                                    <mml:mo>(</mml:mo>
                                    <mml:mrow>
                                        <mml:msub>
                                            <mml:mi>Z</mml:mi>
                                            <mml:mrow>
                                                <mml:mi>t</mml:mi>
                                                <mml:mo>+</mml:mo>
                                                <mml:mn>1</mml:mn>
                                            </mml:mrow>
                                        </mml:msub>
                                        <mml:mo>|</mml:mo>
                                        <mml:msub>
                                            <mml:mi>Z</mml:mi>
                                            <mml:mi>t</mml:mi>
                                        </mml:msub>
                                    </mml:mrow>
                                    <mml:mo>)</mml:mo>
                                </mml:mrow>
                                <mml:mo>.</mml:mo>
                            </mml:mrow>
                        </mml:math>
                    </disp-formula>
                </p>
                <p>Key to a hidden Markov model is the probability of a transition between any two states, 
                    <italic toggle="yes">Z
                        <sub>t</sub>
                    </italic> = 
                    <italic toggle="yes">i</italic> and 
                    <italic toggle="yes">Z</italic>
                    <sub>
                        <italic toggle="yes">t</italic>+1</sub> = 
                    <italic toggle="yes">j</italic>, i.e., the single-step transition probabilities (this description is restricted to so-called homogenous chains which assume the transition probabilities to be time independent) 
                    <disp-formula id="e20">
                        <mml:math display="block" id="math3">
                            <mml:mrow>
                                <mml:msub>
                                    <mml:mi>&#x03b3;</mml:mi>
                                    <mml:mrow>
                                        <mml:mi>i</mml:mi>
                                        <mml:mi>j</mml:mi>
                                    </mml:mrow>
                                </mml:msub>
                                <mml:mo>=</mml:mo>
                                <mml:mi>Pr</mml:mi>
                                <mml:mo>&#x2061;</mml:mo>
                                <mml:mrow>
                                    <mml:mo>(</mml:mo>
                                    <mml:mrow>
                                        <mml:msub>
                                            <mml:mi>Z</mml:mi>
                                            <mml:mrow>
                                                <mml:mi>t</mml:mi>
                                                <mml:mo>+</mml:mo>
                                                <mml:mn>1</mml:mn>
                                            </mml:mrow>
                                        </mml:msub>
                                        <mml:mo>=</mml:mo>
                                        <mml:mi>j</mml:mi>
                                        <mml:mo>|</mml:mo>
                                        <mml:msub>
                                            <mml:mi>Z</mml:mi>
                                            <mml:mi>t</mml:mi>
                                        </mml:msub>
                                        <mml:mo>=</mml:mo>
                                        <mml:mi>i</mml:mi>
                                    </mml:mrow>
                                    <mml:mo>)</mml:mo>
                                </mml:mrow>
                                <mml:mo>.</mml:mo>
                            </mml:mrow>
                        </mml:math>
                    </disp-formula>
                </p>
                <p>The count (
                    <italic toggle="yes">y
                        <sub>t</sub>
                    </italic>) observed on a given occasion is assumed to have a Poisson distribution with a state-specific rate, 
                    <italic toggle="yes">&#x03bb;
                        <sub>Z
                            <sub>t</sub>
                        </sub>
                    </italic>. Thus, given an HMM with 
                    <italic toggle="yes">m</italic> states and associated Poisson parameters 
                    <italic toggle="yes">&#x03bb;
                        <sub>z</sub>
                    </italic>, 
                    <italic toggle="yes">z</italic> = 1, 2, &#x2026;, 
                    <italic toggle="yes">m</italic>, 
                    <disp-formula>
                        <mml:math display="block" id="math4">
                            <mml:mrow>
                                <mml:msub>
                                    <mml:mi>y</mml:mi>
                                    <mml:mi>t</mml:mi>
                                </mml:msub>
                                <mml:mo>|</mml:mo>
                                <mml:msub>
                                    <mml:mi>Z</mml:mi>
                                    <mml:mi>t</mml:mi>
                                </mml:msub>
                                <mml:mo>,</mml:mo>
                                <mml:mrow>
                                    <mml:mo>(</mml:mo>
                                    <mml:mrow>
                                        <mml:msub>
                                            <mml:mi>&#x03bb;</mml:mi>
                                            <mml:mn>1</mml:mn>
                                        </mml:msub>
                                        <mml:mo>,</mml:mo>
                                        <mml:mo>&#x2026;</mml:mo>
                                        <mml:msub>
                                            <mml:mi>&#x03bb;</mml:mi>
                                            <mml:mi>m</mml:mi>
                                        </mml:msub>
                                    </mml:mrow>
                                    <mml:mo>)</mml:mo>
                                </mml:mrow>
                                <mml:mo>&#x223c;</mml:mo>
                                <mml:mtext>Poisson</mml:mtext>
                                <mml:mrow>
                                    <mml:mo>(</mml:mo>
                                    <mml:mrow>
                                        <mml:msub>
                                            <mml:mi>y</mml:mi>
                                            <mml:mi>t</mml:mi>
                                        </mml:msub>
                                        <mml:mo>|</mml:mo>
                                        <mml:msub>
                                            <mml:mi>&#x03bb;</mml:mi>
                                            <mml:mrow>
                                                <mml:msub>
                                                    <mml:mi>Z</mml:mi>
                                                    <mml:mi>t</mml:mi>
                                                </mml:msub>
                                            </mml:mrow>
                                        </mml:msub>
                                    </mml:mrow>
                                    <mml:mo>)</mml:mo>
                                </mml:mrow>
                                <mml:mo>,</mml:mo>
                                <mml:mi>t</mml:mi>
                                <mml:mo>=</mml:mo>
                                <mml:mn>1</mml:mn>
                                <mml:mo>,</mml:mo>
                                <mml:mo>&#x22ef;</mml:mo>
                                <mml:mo>,</mml:mo>
                                <mml:mi>T</mml:mi>
                            </mml:mrow>
                        </mml:math>
                    </disp-formula>
                </p>
            </sec>
            <sec id="N2">
                <title>Note S2</title>
                <p>
                    <italic toggle="yes">
                        <bold>Posterior predictive simulation and Bayesian p-values.</bold>
                    </italic> Posterior predictive simulation has been used extensively in this study, and it is appropriate to comment on this approach to model assessment. Gelman is among those who have championed this method (see, for example, 
                    <xref ref-type="bibr" rid="ref-13">13</xref>,
                    <xref ref-type="bibr" rid="ref-14">14</xref>,
                    <xref ref-type="bibr" rid="ref-35">35</xref>&#x2013;
                    <xref ref-type="bibr" rid="ref-37">37</xref>) and we find the arguments appealing. A central proposition is that no statistical model should be regarded as correct in every detail (in essence, all models are wrong; see 
                    <xref ref-type="bibr" rid="ref-37">37</xref>, for example) and that what matters is model adequacy as it relates to the research question and resulting statistical inferences. From that perspective, model inadequacies that have little impact on the statistical inferences and resulting conclusions can be ignored. For this reason our posterior predictive simulation analyses focused on the capacity of each model under consideration to capture the extremes in seizure activity. From a clinical perspective this is the primary requirement of any candidate model.</p>
                <p>Bayarri and Castellanos (2007)
                    <sup>
                        <xref ref-type="bibr" rid="ref-38">38</xref>
                    </sup>, provide useful additional information regarding this model checking procedure, listing the choices that must be made. These are (1) the discrepancy measure or test statistic used to measure incompatibility between the observed data and the model, (2) the distribution of the discrepancy measure/statistic, under the model (in the present context this is provided by the posterior predictive distribution), and (3) a method for measuring conflict between the observed statistic (value) and this distribution; a measure of surprise. Tail areas (posterior predictive p-values) are a commonly used measure. In this paper we refer to these tail areas as Bayesian p-values; these were calculated as outlined in the following paragraph. Posterior predictive p-values (Bayesian p-values, 
                    <italic toggle="yes">p
                        <sub>B</sub>
                    </italic> ) were obtained for a given model by performing posterior predictive simulation and using selected test statistics to compare the observed and replicate data. Thus, given some suitable statistic, the observed value is compared with its posterior predictive distribution. Following Gelman et al. (2004) (page 162 in 
                    <xref ref-type="bibr" rid="ref-9">9</xref>) a Bayesian p-value is defined as the probability that replicate posterior predictive data ( 
                    <italic toggle="yes">y
                        <sup>rep</sup>
                    </italic>) might be more extreme than the observed data based on the chosen discrepancy measure, 
                    <italic toggle="yes">T</italic>(
                    <italic toggle="yes">y</italic>, 
                    <italic toggle="yes">&#x03b8;</italic>). Thus 
                    <disp-formula>
                        <mml:math display="block" id="math5">
                            <mml:mrow>
                                <mml:msub>
                                    <mml:mi>p</mml:mi>
                                    <mml:mi>B</mml:mi>
                                </mml:msub>
                                <mml:mo>=</mml:mo>
                                <mml:mtext>Pr</mml:mtext>
                                <mml:mo>&#x2061;</mml:mo>
                                <mml:mrow>
                                    <mml:mo>(</mml:mo>
                                    <mml:mrow>
                                        <mml:mi>T</mml:mi>
                                        <mml:mrow>
                                            <mml:mo>(</mml:mo>
                                            <mml:mrow>
                                                <mml:msup>
                                                    <mml:mi>y</mml:mi>
                                                    <mml:mrow>
                                                        <mml:mi>r</mml:mi>
                                                        <mml:mi>e</mml:mi>
                                                        <mml:mi>p</mml:mi>
                                                    </mml:mrow>
                                                </mml:msup>
                                                <mml:mo>,</mml:mo>
                                                <mml:mi>&#x03b8;</mml:mi>
                                            </mml:mrow>
                                            <mml:mo>)</mml:mo>
                                        </mml:mrow>
                                        <mml:mo>&#x2265;</mml:mo>
                                        <mml:mi>T</mml:mi>
                                        <mml:mrow>
                                            <mml:mo>(</mml:mo>
                                            <mml:mrow>
                                                <mml:mi>y</mml:mi>
                                                <mml:mo>,</mml:mo>
                                                <mml:mi>&#x03b8;</mml:mi>
                                            </mml:mrow>
                                            <mml:mo>)</mml:mo>
                                        </mml:mrow>
                                        <mml:mo>|</mml:mo>
                                        <mml:mi>y</mml:mi>
                                    </mml:mrow>
                                    <mml:mo>)</mml:mo>
                                </mml:mrow>
                            </mml:mrow>
                        </mml:math>
                    </disp-formula> taken jointly over the posterior predictive distribution of 
                    <italic toggle="yes">y
                        <sup>rep</sup>
                    </italic> and the posterior distribution of 
                    <italic toggle="yes">&#x03b8;</italic>. An estimate of 
                    <italic toggle="yes">p
                        <sub>B</sub>
                    </italic> is given by the proportion of 
                    <italic toggle="yes">L</italic> simulations satisfying 
                    <disp-formula id="e23">
                        <mml:math display="block" id="math6">
                            <mml:mrow>
                                <mml:mi>T</mml:mi>
                                <mml:mrow>
                                    <mml:mo>(</mml:mo>
                                    <mml:mrow>
                                        <mml:msup>
                                            <mml:mi>y</mml:mi>
                                            <mml:mrow>
                                                <mml:mi>r</mml:mi>
                                                <mml:mi>e</mml:mi>
                                                <mml:mi>p</mml:mi>
                                                <mml:mrow>
                                                    <mml:mo>(</mml:mo>
                                                    <mml:mi>l</mml:mi>
                                                    <mml:mo>)</mml:mo>
                                                </mml:mrow>
                                            </mml:mrow>
                                        </mml:msup>
                                        <mml:mo>,</mml:mo>
                                        <mml:msup>
                                            <mml:mi>&#x03b8;</mml:mi>
                                            <mml:mi>l</mml:mi>
                                        </mml:msup>
                                    </mml:mrow>
                                    <mml:mo>)</mml:mo>
                                </mml:mrow>
                                <mml:mo>&#x2265;</mml:mo>
                                <mml:mi>T</mml:mi>
                                <mml:mrow>
                                    <mml:mo>(</mml:mo>
                                    <mml:mrow>
                                        <mml:mi>y</mml:mi>
                                        <mml:mo>,</mml:mo>
                                        <mml:msup>
                                            <mml:mi>&#x03b8;</mml:mi>
                                            <mml:mi>l</mml:mi>
                                        </mml:msup>
                                    </mml:mrow>
                                    <mml:mo>)</mml:mo>
                                </mml:mrow>
                                <mml:mo>,</mml:mo>
                                <mml:mi>l</mml:mi>
                                <mml:mo>=</mml:mo>
                                <mml:mn>1</mml:mn>
                                <mml:mo>,</mml:mo>
                                <mml:mo>&#x2026;</mml:mo>
                                <mml:mo>,</mml:mo>
                                <mml:mi>L</mml:mi>
                                <mml:mo>.</mml:mo>
                            </mml:mrow>
                            <mml:mspace width="10em"/>
                            <mml:mo stretchy="false">(</mml:mo>
                            <mml:mn>19</mml:mn>
                            <mml:mo stretchy="false">)</mml:mo>
                        </mml:math>
                    </disp-formula>
                </p>
                <p>In those instances where this yields a p-value greater than 0.5 the result is given as 1 
                    <italic toggle="yes">&#x2212; p
                        <sub>B</sub>
                    </italic>. Thus improbable simulation test results are indicated by Bayesian p-values near zero. The majority of discrepancy measures adopted in this study do not depend on unknown parameters in which case 
                    <italic toggle="yes">T</italic>(
                    <italic toggle="yes">y</italic>, 
                    <italic toggle="yes">&#x03b8;</italic>) = 
                    <italic toggle="yes">T</italic>(
                    <italic toggle="yes">y</italic>).</p>
            </sec>
            <sec id="N3">
                <title>Note S3</title>
                <p>
                    <italic toggle="yes">
                        <bold>Label switching, label sorting and identifiability constraints.</bold>
                    </italic> HMMs are a class of mixture model, the term &#x2018;mixture model&#x2019; referring to statistical models consisting of a mixture of probability distributions. In fact, one approach to HMM parameter estimation is to treat it as a standard mixture model problem and to use a conventional minimisation routine to find the maximum log-likelihood
                    <sup>
                        <xref ref-type="bibr" rid="ref-8">8</xref>
                    </sup>. The recognition that HMMs are mixture models is relevant to the present study because it is well known that a so-called label-switching problem arises in mixture model parameter estimation, and it follows that the problem must arise in HMM applications. The central issue is a &#x2018;symmetry&#x2019; in the likelihood caused by invariance to permutation of the mixture component labels. Re-expressed, a complication arises because relabelling the mixture components (swapping the component labels) has no effect on the likelihood. In fact, all permutations of the component labels produce the same likelihood. This might be regarded as a lack of identifiability.</p>
                <p>A number of solutions have been suggested, including the incorporation of identifiability constraints to prevent label switches (page 465 in 
                    <xref ref-type="bibr" rid="ref-9">9</xref>; 
                    <xref ref-type="bibr" rid="ref-39">39</xref>, including the discussion), and the application of relabelling algorithms
                    <sup>
                        <xref ref-type="bibr" rid="ref-40">40</xref>
                    </sup>. In the present study, an identifiability constraint was incorporated into the log-linear model in the form of an ordering constraint on the Poisson rates, an approach which is expected to work well when the component Poisson parameter distributions are well separated. No such constraints are included in the Poisson-gamma model. Instead post-simulation label sorting is applied to the MCMC output. We adopted a simple approach in which this was achieved by ordering the Poisson rate parameters by magnitude and subsequently sorting the transition matrix parameters as dictated by the rate-parameter label changes. This is clearly related to the order constraints included in the log-linear model. Thus, relabelling an entire set of parameters based on the sorted order of a single parameter is expected to yield valid results when the chosen parameter consists of component distributions that are well separated. More sophisticated approaches have been suggested (see, for example, 
                    <xref ref-type="bibr" rid="ref-40">40</xref>,
                    <xref ref-type="bibr" rid="ref-41">41</xref>). We acknowledge that label switching is especially important when mixture-model/HMM parameter estimation is performed using MCMC because it has implications regarding the need for convergence to a stationary distribution. In fact, convergence in mixture-model MCMC and the related matter of order constraints has been the subject of some controversy (see, for example, 
                    <xref ref-type="bibr" rid="ref-39">39</xref>,
                    <xref ref-type="bibr" rid="ref-42">42</xref>,
                    <xref ref-type="bibr" rid="ref-43">43</xref>), one that we have summarised briefly in a previous paper
                    <sup>
                        <xref ref-type="bibr" rid="ref-44">44</xref>
                    </sup>. One or other of the more advanced methods for dealing with label switching might be explored in a future study, given the weakness of the well-separated distribution assumption in some cases.</p>
            </sec>
            <sec id="N4">
                <title>Note S4</title>
                <p>
                    <italic toggle="yes">
                        <bold>Temporal random effects and first order autoregressive models.</bold>
                    </italic> In some children with epilepsy there is an apparent time dependence in seizure activity, in addition to the observed state-switching behaviour. A temporal random effects term ( 
                    <italic toggle="yes">f
                        <sub>t</sub>
                    </italic> = 
                    <italic toggle="yes">&#x03b3;
                        <sub>t</sub>
                    </italic> in 
                    <xref ref-type="other" rid="e8">equation 8</xref>) with an intrinsic Gaussian conditional autoregressive (CAR) prior distribution
                    <sup>
                        <xref ref-type="bibr" rid="ref-45">45</xref>,
                        <xref ref-type="bibr" rid="ref-46">46</xref>
                    </sup> (also see Example 9 in 
                    <xref ref-type="bibr" rid="ref-24">24</xref> for additional information) was therefore adopted as one approach to incorporating time dependence into the state-specific Poisson rate parameters. In the time series context the CAR prior takes the form 
                    <disp-formula>
                        <mml:math display="block" id="math7">
                            <mml:mrow>
                                <mml:msub>
                                    <mml:mi>&#x03b3;</mml:mi>
                                    <mml:mi>i</mml:mi>
                                </mml:msub>
                                <mml:mo>|</mml:mo>
                                <mml:msub>
                                    <mml:mi>&#x03b3;</mml:mi>
                                    <mml:mi>v</mml:mi>
                                </mml:msub>
                                <mml:mo>,</mml:mo>
                                <mml:mi>i</mml:mi>
                                <mml:mo>&#x2260;</mml:mo>
                                <mml:mi>v</mml:mi>
                                <mml:mo>&#x223c;</mml:mo>
                                <mml:mi>N</mml:mi>
                                <mml:mrow>
                                    <mml:mo>(</mml:mo>
                                    <mml:mrow>
                                        <mml:msub>
                                            <mml:mover accent="true">
                                                <mml:mi>&#x03b3;</mml:mi>
                                                <mml:mo>&#x00af;</mml:mo>
                                            </mml:mover>
                                            <mml:mi>i</mml:mi>
                                        </mml:msub>
                                        <mml:mo>,</mml:mo>
                                        <mml:msubsup>
                                            <mml:mi>w</mml:mi>
                                            <mml:mi>&#x03b3;</mml:mi>
                                            <mml:mn>2</mml:mn>
                                        </mml:msubsup>
                                        <mml:mo>/</mml:mo>
                                        <mml:msub>
                                            <mml:mi>m</mml:mi>
                                            <mml:mi>i</mml:mi>
                                        </mml:msub>
                                    </mml:mrow>
                                    <mml:mo>)</mml:mo>
                                </mml:mrow>
                            </mml:mrow>
                            <mml:mspace width="5em"/>
                            <mml:mo stretchy="false">(</mml:mo>
                            <mml:mn>20</mml:mn>
                            <mml:mo stretchy="false">)</mml:mo>
                        </mml:math>
                    </disp-formula> where 
                    <inline-formula>
                        <mml:math display="inline" id="M4">
                            <mml:mrow>
                                <mml:msub>
                                    <mml:mover accent="true">
                                        <mml:mi>&#x03b3;</mml:mi>
                                        <mml:mo>&#x00af;</mml:mo>
                                    </mml:mover>
                                    <mml:mi>i</mml:mi>
                                </mml:msub>
                                <mml:mo>=</mml:mo>
                                <mml:mfrac>
                                    <mml:mn>1</mml:mn>
                                    <mml:mrow>
                                        <mml:msub>
                                            <mml:mi>m</mml:mi>
                                            <mml:mi>i</mml:mi>
                                        </mml:msub>
                                    </mml:mrow>
                                </mml:mfrac>
                                <mml:msub>
                                    <mml:mi>&#x2211;</mml:mi>
                                    <mml:mrow>
                                        <mml:mi>v</mml:mi>
                                        <mml:mo>&#x2208;</mml:mo>
                                        <mml:msub>
                                            <mml:mi>&#x03b4;</mml:mi>
                                            <mml:mi>i</mml:mi>
                                        </mml:msub>
                                    </mml:mrow>
                                </mml:msub>
                                <mml:msub>
                                    <mml:mi>&#x03b3;</mml:mi>
                                    <mml:mi>v</mml:mi>
                                </mml:msub>
                                <mml:mo>,</mml:mo>
                                <mml:msubsup>
                                    <mml:mi>w</mml:mi>
                                    <mml:mi>&#x03b3;</mml:mi>
                                    <mml:mn>2</mml:mn>
                                </mml:msubsup>
                            </mml:mrow>
                        </mml:math>
                    </inline-formula> is a variance parameter, and 
                    <italic toggle="yes">m
                        <sub>i</sub>
                    </italic> is the number of &#x2018;adjacent&#x2019; observations, i.e., 2 for all but the first and last occasions. 
                    <italic toggle="yes">&#x03b4;
                        <sub>i</sub>
                    </italic> denotes the set of occasion labels belonging to those occasions that precede and follow the 
                    <italic toggle="yes">ith</italic> occasion. Thus, the prior conditional mean is the average of the adjacent observations. A complication arises in the present implementation, however, because the CAR random effects sum to zero and must be accompanied by an intercept term (see 
                    <xref ref-type="other" rid="e23">equation 23</xref>), the latter of which must be assigned a flat prior. As a consequence of the ordering constraint that is imposed on the log-linear Poisson rates, a change of variables is required to transform the Gibbs sampler rate parameters to the constrained log domain. This change-of-variables transformation was implemented, as follows, based on the zeros trick
                    <sup>
                        <xref ref-type="bibr" rid="ref-47">47</xref>
                    </sup> (noting the altered definition of 
                    <italic toggle="yes">&#x03bb;&#x2032;</italic> in the following): 
                    <disp-formula>
                        <mml:math display="block" id="math8">
                            <mml:mrow>
                                <mml:mtext mathvariant="italic">log</mml:mtext>
                                <mml:mrow>
                                    <mml:mo>(</mml:mo>
                                    <mml:mrow>
                                        <mml:msub>
                                            <mml:mi>&#x03bb;</mml:mi>
                                            <mml:mrow>
                                                <mml:mi>j</mml:mi>
                                                <mml:mi>t</mml:mi>
                                            </mml:mrow>
                                        </mml:msub>
                                    </mml:mrow>
                                    <mml:mo>)</mml:mo>
                                </mml:mrow>
                                <mml:mo>=</mml:mo>
                                <mml:msubsup>
                                    <mml:mi>&#x03bb;</mml:mi>
                                    <mml:mrow>
                                        <mml:mi>j</mml:mi>
                                        <mml:mi>t</mml:mi>
                                    </mml:mrow>
                                    <mml:mo>&#x2032;</mml:mo>
                                </mml:msubsup>
                                <mml:mo>,</mml:mo>
                                <mml:mi>j</mml:mi>
                                <mml:mo>=</mml:mo>
                                <mml:mn>1</mml:mn>
                                <mml:mo>,</mml:mo>
                                <mml:mo>&#x2026;</mml:mo>
                                <mml:mo>,</mml:mo>
                                <mml:mi>J</mml:mi>
                                <mml:mo>,</mml:mo>
                                <mml:mi>t</mml:mi>
                                <mml:mo>=</mml:mo>
                                <mml:mn>1</mml:mn>
                                <mml:mo>,</mml:mo>
                                <mml:mo>&#x2026;</mml:mo>
                                <mml:mo>,</mml:mo>
                                <mml:mi>N</mml:mi>
                            </mml:mrow>
                            <mml:mspace width="14em"/>
                            <mml:mo stretchy="false">(</mml:mo>
                            <mml:mn>21</mml:mn>
                            <mml:mo stretchy="false">)</mml:mo>
                        </mml:math>
                    </disp-formula>
                    <disp-formula>
                        <mml:math display="block" id="math9">
                            <mml:mrow>
                                <mml:msubsup>
                                    <mml:mi>&#x03bb;</mml:mi>
                                    <mml:mrow>
                                        <mml:mi>1</mml:mi>
                                        <mml:mi>t</mml:mi>
                                    </mml:mrow>
                                    <mml:mo>&#x2032;</mml:mo>
                                </mml:msubsup>
                                <mml:mo>=</mml:mo>
                                <mml:mi>L</mml:mi>
                                <mml:mo>+</mml:mo>
                                <mml:mrow>
                                    <mml:mo>(</mml:mo>
                                    <mml:mrow>
                                        <mml:mi>U</mml:mi>
                                        <mml:mo>&#x2212;</mml:mo>
                                        <mml:mi>L</mml:mi>
                                    </mml:mrow>
                                    <mml:mo>)</mml:mo>
                                </mml:mrow>
                                <mml:mrow>
                                    <mml:mrow>
                                        <mml:msup>
                                            <mml:mi>e</mml:mi>
                                            <mml:mrow>
                                                <mml:msubsup>
                                                    <mml:mi>&#x03bb;</mml:mi>
                                                    <mml:mi>t</mml:mi>
                                                    <mml:mo>&#x2033;</mml:mo>
                                                </mml:msubsup>
                                            </mml:mrow>
                                        </mml:msup>
                                    </mml:mrow>
                                    <mml:mo>/</mml:mo>
                                    <mml:mrow>
                                        <mml:mrow>
                                            <mml:mo>(</mml:mo>
                                            <mml:mrow>
                                                <mml:mn>1</mml:mn>
                                                <mml:mo>+</mml:mo>
                                                <mml:msup>
                                                    <mml:mi>e</mml:mi>
                                                    <mml:mrow>
                                                        <mml:msubsup>
                                                            <mml:mi>&#x03bb;</mml:mi>
                                                            <mml:mi>t</mml:mi>
                                                            <mml:mo>&#x2033;</mml:mo>
                                                        </mml:msubsup>
                                                    </mml:mrow>
                                                </mml:msup>
                                            </mml:mrow>
                                            <mml:mo>)</mml:mo>
                                        </mml:mrow>
                                    </mml:mrow>
                                </mml:mrow>
                            </mml:mrow>
                            <mml:mspace width="15em"/>
                            <mml:mo stretchy="false">(</mml:mo>
                            <mml:mn>22</mml:mn>
                            <mml:mo stretchy="false">)</mml:mo>
                        </mml:math>
                    </disp-formula>
                    <disp-formula>
                        <mml:math display="block" id="math10">
                            <mml:mrow>
                                <mml:msubsup>
                                    <mml:mi>&#x03bb;</mml:mi>
                                    <mml:mi>t</mml:mi>
                                    <mml:mo>&#x2033;</mml:mo>
                                </mml:msubsup>
                                <mml:mo>=</mml:mo>
                                <mml:mi>c</mml:mi>
                                <mml:mo>+</mml:mo>
                                <mml:msub>
                                    <mml:mi>&#x03b3;</mml:mi>
                                    <mml:mi>t</mml:mi>
                                </mml:msub>
                            </mml:mrow>
                            <mml:mspace width="25em"/>
                            <mml:mo stretchy="false">(</mml:mo>
                            <mml:mn>23</mml:mn>
                            <mml:mo stretchy="false">)</mml:mo>
                        </mml:math>
                    </disp-formula>
                    <disp-formula>
                        <mml:math display="block" id="math11">
                            <mml:mrow>
                                <mml:msubsup>
                                    <mml:mi>&#x03bb;</mml:mi>
                                    <mml:mrow>
                                        <mml:mi>j</mml:mi>
                                        <mml:mi>t</mml:mi>
                                    </mml:mrow>
                                    <mml:mo>&#x2032;</mml:mo>
                                </mml:msubsup>
                                <mml:mo>=</mml:mo>
                                <mml:msubsup>
                                    <mml:mi>&#x03bb;</mml:mi>
                                    <mml:mrow>
                                        <mml:mi>j</mml:mi>
                                        <mml:mo>&#x2212;</mml:mo>
                                        <mml:mn>1</mml:mn>
                                        <mml:mo>,</mml:mo>
                                        <mml:mi>t</mml:mi>
                                    </mml:mrow>
                                    <mml:mo>&#x2032;</mml:mo>
                                </mml:msubsup>
                                <mml:mo>+</mml:mo>
                                <mml:msub>
                                    <mml:mi>a</mml:mi>
                                    <mml:mi>j</mml:mi>
                                </mml:msub>
                                <mml:mo>,</mml:mo>
                                <mml:mi>j</mml:mi>
                                <mml:mo>=</mml:mo>
                                <mml:mn>2</mml:mn>
                                <mml:mo>,</mml:mo>
                                <mml:mo>&#x2026;</mml:mo>
                                <mml:mo>,</mml:mo>
                                <mml:mi>J</mml:mi>
                            </mml:mrow>
                            <mml:mspace width="18em"/>
                            <mml:mo stretchy="false">(</mml:mo>
                            <mml:mn>24</mml:mn>
                            <mml:mo stretchy="false">)</mml:mo>
                        </mml:math>
                    </disp-formula>
                    <disp-formula>
                        <mml:math display="block" id="math12">
                            <mml:mrow>
                                <mml:msub>
                                    <mml:mi>a</mml:mi>
                                    <mml:mi>j</mml:mi>
                                </mml:msub>
                                <mml:mo>&#x223c;</mml:mo>
                                <mml:mi>N</mml:mi>
                                <mml:mrow>
                                    <mml:mo>(</mml:mo>
                                    <mml:mrow>
                                        <mml:mn>0</mml:mn>
                                        <mml:mo>,</mml:mo>
                                        <mml:mi>&#x03f5;</mml:mi>
                                    </mml:mrow>
                                    <mml:mo>)</mml:mo>
                                </mml:mrow>
                                <mml:mo>,</mml:mo>
                                <mml:mn>0</mml:mn>
                                <mml:mo>&lt;</mml:mo>
                                <mml:msub>
                                    <mml:mi>a</mml:mi>
                                    <mml:mi>j</mml:mi>
                                </mml:msub>
                                <mml:mo>&lt;</mml:mo>
                                <mml:msup>
                                    <mml:mi>U</mml:mi>
                                    <mml:mo>&#x2032;</mml:mo>
                                </mml:msup>
                                <mml:mo>,</mml:mo>
                                <mml:mi>j</mml:mi>
                                <mml:mo>=</mml:mo>
                                <mml:mn>2</mml:mn>
                                <mml:mo>,</mml:mo>
                                <mml:mo>&#x2026;</mml:mo>
                                <mml:mo>,</mml:mo>
                                <mml:mi>J</mml:mi>
                            </mml:mrow>
                            <mml:mspace width="15em"/>
                            <mml:mo stretchy="false">(</mml:mo>
                            <mml:mn>25</mml:mn>
                            <mml:mo stretchy="false">)</mml:mo>
                        </mml:math>
                    </disp-formula>
                    <disp-formula>
                        <mml:math display="block" id="math13">
                            <mml:mrow>
                                <mml:mi>c</mml:mi>
                                <mml:mo>&#x223c;</mml:mo>
                                <mml:mtext>flat</mml:mtext>
                            </mml:mrow>
                            <mml:mspace width="25em"/>
                            <mml:mo stretchy="false">(</mml:mo>
                            <mml:mn>26</mml:mn>
                            <mml:mo stretchy="false">)</mml:mo>
                        </mml:math>
                    </disp-formula>
                    <disp-formula>
                        <mml:math display="block" id="math14">
                            <mml:mrow>
                                <mml:msub>
                                    <mml:mi>&#x03b3;</mml:mi>
                                    <mml:mi>t</mml:mi>
                                </mml:msub>
                                <mml:mo>&#x223c;</mml:mo>
                                <mml:mtext>car</mml:mtext>
                                <mml:mo>.</mml:mo>
                                <mml:mtext>normal</mml:mtext>
                            </mml:mrow>
                            <mml:mspace width="21em"/>
                            <mml:mo stretchy="false">(</mml:mo>
                            <mml:mn>27</mml:mn>
                            <mml:mo stretchy="false">)</mml:mo>
                        </mml:math>
                    </disp-formula>
                    <disp-formula>
                        <mml:math display="block" id="math15">
                            <mml:mrow>
                                <mml:msub>
                                    <mml:mi>X</mml:mi>
                                    <mml:mi>t</mml:mi>
                                </mml:msub>
                                <mml:mo>=</mml:mo>
                                <mml:mn>0</mml:mn>
                            </mml:mrow>
                            <mml:mspace width="26em"/>
                            <mml:mo stretchy="false">(</mml:mo>
                            <mml:mn>28</mml:mn>
                            <mml:mo stretchy="false">)</mml:mo>
                        </mml:math>
                    </disp-formula>
                    <disp-formula>
                        <mml:math display="block" id="math16">
                            <mml:mrow>
                                <mml:msub>
                                    <mml:mi>X</mml:mi>
                                    <mml:mi>t</mml:mi>
                                </mml:msub>
                                <mml:mo>&#x223c;</mml:mo>
                                <mml:mi>P</mml:mi>
                                <mml:mi>o</mml:mi>
                                <mml:mi>i</mml:mi>
                                <mml:mi>s</mml:mi>
                                <mml:mi>s</mml:mi>
                                <mml:mi>o</mml:mi>
                                <mml:mi>n</mml:mi>
                                <mml:mrow>
                                    <mml:mo>(</mml:mo>
                                    <mml:mrow>
                                        <mml:msub>
                                            <mml:mi>g</mml:mi>
                                            <mml:mi>t</mml:mi>
                                        </mml:msub>
                                    </mml:mrow>
                                    <mml:mo>)</mml:mo>
                                </mml:mrow>
                            </mml:mrow>
                            <mml:mspace width="22em"/>
                            <mml:mo stretchy="false">(</mml:mo>
                            <mml:mn>29</mml:mn>
                            <mml:mo stretchy="false">)</mml:mo>
                        </mml:math>
                    </disp-formula>
                    <disp-formula>
                        <mml:math display="block" id="math17">
                            <mml:mrow>
                                <mml:msub>
                                    <mml:mi>g</mml:mi>
                                    <mml:mi>t</mml:mi>
                                </mml:msub>
                                <mml:mo>=</mml:mo>
                                <mml:mo>&#x2212;</mml:mo>
                                <mml:mtext mathvariant="italic">log</mml:mtext>
                                <mml:mo>&#x2061;</mml:mo>
                                <mml:mrow>
                                    <mml:mo>(</mml:mo>
                                    <mml:mrow>
                                        <mml:msub>
                                            <mml:mi>w</mml:mi>
                                            <mml:mi>t</mml:mi>
                                        </mml:msub>
                                    </mml:mrow>
                                    <mml:mo>)</mml:mo>
                                </mml:mrow>
                            </mml:mrow>
                            <mml:mspace width="22em"/>
                            <mml:mo stretchy="false">(</mml:mo>
                            <mml:mn>30</mml:mn>
                            <mml:mo stretchy="false">)</mml:mo>
                        </mml:math>
                    </disp-formula>
                    <disp-formula>
                        <mml:math display="block" id="math18">
                            <mml:mrow>
                                <mml:msub>
                                    <mml:mi>w</mml:mi>
                                    <mml:mi>t</mml:mi>
                                </mml:msub>
                                <mml:mo>=</mml:mo>
                                <mml:mrow>
                                    <mml:mo>(</mml:mo>
                                    <mml:mrow>
                                        <mml:mi>U</mml:mi>
                                        <mml:mo>&#x2212;</mml:mo>
                                        <mml:mi>L</mml:mi>
                                    </mml:mrow>
                                    <mml:mo>)</mml:mo>
                                </mml:mrow>
                                <mml:msup>
                                    <mml:mrow>
                                        <mml:mrow>
                                            <mml:mrow>
                                                <mml:msup>
                                                    <mml:mi>e</mml:mi>
                                                    <mml:mrow>
                                                        <mml:msubsup>
                                                            <mml:mi>&#x03bb;</mml:mi>
                                                            <mml:mi>t</mml:mi>
                                                            <mml:mo>&#x2033;</mml:mo>
                                                        </mml:msubsup>
                                                    </mml:mrow>
                                                </mml:msup>
                                            </mml:mrow>
                                            <mml:mo>/</mml:mo>
                                            <mml:mrow>
                                                <mml:mrow>
                                                    <mml:mo>(</mml:mo>
                                                    <mml:mrow>
                                                        <mml:mn>1</mml:mn>
                                                        <mml:mo>+</mml:mo>
                                                        <mml:msup>
                                                            <mml:mi>e</mml:mi>
                                                            <mml:mrow>
                                                                <mml:msubsup>
                                                                    <mml:mi>&#x03bb;</mml:mi>
                                                                    <mml:mi>t</mml:mi>
                                                                    <mml:mo>&#x2033;</mml:mo>
                                                                </mml:msubsup>
                                                            </mml:mrow>
                                                        </mml:msup>
                                                    </mml:mrow>
                                                    <mml:mo>)</mml:mo>
                                                </mml:mrow>
                                            </mml:mrow>
                                        </mml:mrow>
                                    </mml:mrow>
                                    <mml:mn>2</mml:mn>
                                </mml:msup>
                            </mml:mrow>
                            <mml:mspace width="18em"/>
                            <mml:mo stretchy="false">(</mml:mo>
                            <mml:mn>31</mml:mn>
                            <mml:mo stretchy="false">)</mml:mo>
                        </mml:math>
                    </disp-formula> where 
                    <inline-formula>
                        <mml:math display="inline" id="M5">
                            <mml:mrow>
                                <mml:msubsup>
                                    <mml:mi>&#x03bb;</mml:mi>
                                    <mml:mrow>
                                        <mml:mi>j</mml:mi>
                                        <mml:mi>t</mml:mi>
                                    </mml:mrow>
                                    <mml:mo>&#x2032;</mml:mo>
                                </mml:msubsup>
                            </mml:mrow>
                        </mml:math>
                    </inline-formula> is the 
                    <italic toggle="yes">jth</italic> Poisson rate in the log domain at the 
                    <italic toggle="yes">t</italic>th observation time and 
                    <inline-formula>
                        <mml:math display="inline" id="M6">
                            <mml:mrow>
                                <mml:msubsup>
                                    <mml:mi>&#x03bb;</mml:mi>
                                    <mml:mrow>
                                        <mml:mi>j</mml:mi>
                                        <mml:mi>t</mml:mi>
                                    </mml:mrow>
                                    <mml:mo>&#x2033;</mml:mo>
                                </mml:msubsup>
                            </mml:mrow>
                        </mml:math>
                    </inline-formula> is the corresponding unconstrained Gibbs sampler parameter for the first state, 
                    <italic toggle="yes">L</italic> is a lower constraint, 
                    <italic toggle="yes">U</italic> and 
                    <italic toggle="yes">U&#x2032;</italic> are upper constraints, 
                    <monospace>car.normal</monospace> is the intrinsic Gaussian CAR prior (defined in 
                    <xref ref-type="other" rid="e20">equation 20</xref> and provided by the GeoBUGS car.normal distribution) and 
                    <monospace>flat</monospace> is an improper uniform prior (provided by the WinBUGS dflat distribution, see page 345 in 
                    <xref ref-type="bibr" rid="ref-18">18</xref>). 
                    <italic toggle="yes">w
                        <sub>t</sub>
                    </italic> is the likelihood weighting required under the change-of-variables rule.</p>
                <p>An AR(1) model was also investigated as an approach to incorporating time dependence into the state-specific Poisson rates. In this case the random coefficients in the preceding change-of-variables treatment were replaced with the following autoregressive parameters (thus 
                    <italic toggle="yes">f
                        <sub>t</sub>
                    </italic> = 
                    <italic toggle="yes">&#x03b3;
                        <sub>t</sub>
                    </italic> in 
                    <xref ref-type="other" rid="e8">equation 8</xref> becomes autoregressive): 
                    <disp-formula>
                        <mml:math display="block" id="math19">
                            <mml:mrow>
                                <mml:msub>
                                    <mml:mi>&#x03b3;</mml:mi>
                                    <mml:mi>t</mml:mi>
                                </mml:msub>
                                <mml:mo>=</mml:mo>
                                <mml:mi>&#x03d5;</mml:mi>
                                <mml:msub>
                                    <mml:mi>&#x03b3;</mml:mi>
                                    <mml:mrow>
                                        <mml:mi>t</mml:mi>
                                        <mml:mo>&#x2212;</mml:mo>
                                        <mml:mn>1</mml:mn>
                                    </mml:mrow>
                                </mml:msub>
                                <mml:mo>,</mml:mo>
                                <mml:mi>t</mml:mi>
                                <mml:mo>=</mml:mo>
                                <mml:mn>2</mml:mn>
                                <mml:mo>,</mml:mo>
                                <mml:mn>3</mml:mn>
                                <mml:mo>,</mml:mo>
                                <mml:mo>&#x22ef;</mml:mo>
                                <mml:mo>,</mml:mo>
                                <mml:mi>N</mml:mi>
                            </mml:mrow>
                            <mml:mspace width="15em"/>
                            <mml:mo stretchy="false">(</mml:mo>
                            <mml:mn>32</mml:mn>
                            <mml:mo stretchy="false">)</mml:mo>
                        </mml:math>
                    </disp-formula>
                    <disp-formula>
                        <mml:math display="block" id="math20">
                            <mml:mrow>
                                <mml:mi>&#x03d5;</mml:mi>
                                <mml:mo>&#x223c;</mml:mo>
                                <mml:mi>N</mml:mi>
                                <mml:mrow>
                                    <mml:mo>(</mml:mo>
                                    <mml:mrow>
                                        <mml:mn>0</mml:mn>
                                        <mml:mo>,</mml:mo>
                                        <mml:mn>0.01</mml:mn>
                                    </mml:mrow>
                                    <mml:mo>)</mml:mo>
                                </mml:mrow>
                                <mml:mo>,</mml:mo>
                                <mml:mn>0</mml:mn>
                                <mml:mo>&#x2264;</mml:mo>
                                <mml:mi>&#x03d5;</mml:mi>
                                <mml:mo>&lt;</mml:mo>
                                <mml:mn>1</mml:mn>
                            </mml:mrow>
                            <mml:mspace width="15em"/>
                            <mml:mo stretchy="false">(</mml:mo>
                            <mml:mn>33</mml:mn>
                            <mml:mo stretchy="false">)</mml:mo>
                        </mml:math>
                    </disp-formula>
                    <disp-formula>
                        <mml:math display="block" id="math21">
                            <mml:mrow>
                                <mml:msub>
                                    <mml:mi>&#x03b3;</mml:mi>
                                    <mml:mn>1</mml:mn>
                                </mml:msub>
                                <mml:mo>&#x223c;</mml:mo>
                                <mml:mi>N</mml:mi>
                                <mml:mrow>
                                    <mml:mo>(</mml:mo>
                                    <mml:mrow>
                                        <mml:mn>0</mml:mn>
                                        <mml:mo>,</mml:mo>
                                        <mml:mn>0.01</mml:mn>
                                    </mml:mrow>
                                    <mml:mo>)</mml:mo>
                                </mml:mrow>
                                <mml:mo>.</mml:mo>
                            </mml:mrow>
                            <mml:mspace width="20em"/>
                            <mml:mo stretchy="false">(</mml:mo>
                            <mml:mn>34</mml:mn>
                            <mml:mo stretchy="false">)</mml:mo>
                        </mml:math>
                    </disp-formula> (It might be noted that Congdon (2001)
                    <sup>
                        <xref ref-type="bibr" rid="ref-48">48</xref>
                    </sup> discusses autoregressive models of temporal correlation, and their implementation in WinBUGS.)</p>
            </sec>
            <sec id="N5">
                <title>Note S5</title>
                <p>
                    <italic toggle="yes">
                        <bold>Case 1. 2-state HMM posterior predictive simulation and Bayesian p-value results.</bold>
                    </italic> Two strategies were adopted as a mechanism for assessing HMM performance. The first was based on Bayesian p-value generation using tests designed to probe the capacity of the model in question to capture crucial features of the data. The following results were obtained for Case 1. Tests based on observing 1 occasion with 13 seizures (
                    <italic toggle="yes">T</italic>(
                    <italic toggle="yes">y</italic>) = #( 
                    <italic toggle="yes">y</italic>
                    <sub>
                        <italic toggle="yes">t</italic>&#x2208;{1&#x2026;
                        <italic toggle="yes">N</italic>}</sub> &gt; 12), 
                    <italic toggle="yes">p
                        <sub>B</sub>
                    </italic> = #(
                    <italic toggle="yes">T</italic>(
                    <italic toggle="yes">y
                        <sup>rep</sup>
                    </italic>) &#x2265; 
                    <italic toggle="yes">T</italic>(
                    <italic toggle="yes">y</italic>) = 1)/
                    <italic toggle="yes">K</italic>, where 
                    <italic toggle="yes">K</italic> is the number of MCMC iterations): log-linear model 
                    <italic toggle="yes">p
                        <sub>B</sub>
                    </italic> = 0.15, Poi-gamma 
                    <italic toggle="yes">p
                        <sub>B</sub>
                    </italic> = 0.15, EM 
                    <italic toggle="yes">p</italic> = 0.13. (Throughout this paper the notation 
                    <italic toggle="yes">t</italic> &#x2208; {
                    <italic toggle="yes">n</italic>
                    <sub>1</sub>&#x2026;
                    <italic toggle="yes">n</italic>
                    <sub>2</sub>} is used to indicate that the occasion label, 
                    <italic toggle="yes">t</italic>, takes on the set of values 
                    <italic toggle="yes">n</italic>
                    <sub>1</sub> to 
                    <italic toggle="yes">n</italic>
                    <sub>2</sub>. Notation of the type #{
                    <italic toggle="yes">y</italic>
                    <sub>
                        <italic toggle="yes">t</italic>&#x2208;{
                        <italic toggle="yes">n</italic>
                        <sub>1</sub>&#x2026;
                        <italic toggle="yes">n</italic>
                        <sub>2</sub>}</sub> &gt; 
                    <italic toggle="yes">C</italic>} is used to indicate the number of occasions within the specified set of occasions on which a given condition is satisfied.) Tests based on observing 2 occasions with no seizures (
                    <italic toggle="yes">T</italic>(
                    <italic toggle="yes">y</italic>) = #(
                    <italic toggle="yes">y</italic>
                    <sub>
                        <italic toggle="yes">t</italic>&#x2208;{1&#x2026;
                        <italic toggle="yes">N</italic>}</sub> &lt; 1), 
                    <italic toggle="yes">p
                        <sub>B</sub>
                    </italic> = #(
                    <italic toggle="yes">T</italic> (
                    <italic toggle="yes">y
                        <sup>rep</sup>
                    </italic>) &#x2264; 
                    <italic toggle="yes">T</italic>(
                    <italic toggle="yes">y</italic>) = 2)/
                    <italic toggle="yes">K</italic>; i.e., test with sign reversal): log-linear model 
                    <italic toggle="yes">p
                        <sub>B</sub>
                    </italic> = 0.5, Poi-gamma 
                    <italic toggle="yes">p
                        <sub>B</sub>
                    </italic> = 0.49, EM 
                    <italic toggle="yes">p</italic> = 0.37. These tests are based entirely on a comparison of the observed and simulated data, using a discrepancy measure based solely on the data, i.e., based on a comparison of 
                    <italic toggle="yes">y</italic> and 
                    <italic toggle="yes">y
                        <sup>rep</sup>
                    </italic> only. It is common practice, however, to construct discrepancy measures that depend on the data and unknown model parameters. An example of the latter is the test based on 
                    <italic toggle="yes">T</italic>(
                    <italic toggle="yes">y</italic>, 
                    <italic toggle="yes">&#x03b8;</italic>) = 
                    <italic toggle="yes">max</italic>(
                    <italic toggle="yes">y
                        <sub>t</sub>
                    </italic> &#x2212; 
                    <italic toggle="yes">&#x03bb;
                        <sub>Z
                            <sub>t</sub>
                        </sub>
                    </italic>) where 
                    <italic toggle="yes">&#x03bb;
                        <sub>Z
                            <sub>t</sub>
                        </sub>
                    </italic> is the Poisson rate parameter conditional on state. The resulting log-linear model Bayesian p-value is 0.14. Although some of these Bayesian p-values are not far from the tail-area of probabilities, we do not reject the 2-state HMM as inadequate.</p>
                <p>The second strategy uses visual inspection of the replicate datasets generated by simulation (and residual plots) to look for systematic differences between the observations and the replicate data. The usual practice in which the results are displayed as overlaid profiles is not helpful in this instance because it obscures the key information, namely, the proportion of predictive time series lacking one or more extreme periods of seizure activity (count 
                    <italic toggle="yes">&gt;</italic> 12). For this reason a subset (obtained using evenly spaced MCMC samples) of 10 time series are shown as separate plots (
                    <xref ref-type="fig" rid="f3">Figure 3</xref>). Several of these time series fail to mimic the observation that an unusually high seizure count was observed on one occasion (
                    <xref ref-type="fig" rid="f2">Figure 2</xref>), and this is reflected in the associated p-values given above (0.13 to 0.15). Taken together, the Bayesian p-values and posterior predictive time series plots indicate that the 2-state HMM is not demonstrably inadequate. The one occasion with an observed count greater than 12 might indeed be a low probability event.</p>
            </sec>
            <sec id="N6">
                <title>Note S6</title>
                <p>
                    <italic toggle="yes">
                        <bold>Case 2. Posterior predictive simulation and Bayesian p-value results.</bold>
                    </italic> A number of tests were constructed to examine the capacity of each of the three models (3-HM, 3-HM-AR, 3-HM-CAR) to capture the observations, paying particular attention to the change point. These include a test on the mean during the interval 22 to 27 weeks (i.e., 
                    <italic toggle="yes">T</italic>(
                    <italic toggle="yes">y</italic>) = 
                    <italic toggle="yes">y</italic>&#x0304;
                    <sub>
                        <italic toggle="yes">t</italic>&#x2208;{22&#x2026;27}</sub>, selected because it yielded the smallest/least favourable p-values), maximum difference in weekly seizure counts during weeks 1 to 20 (
                    <italic toggle="yes">T</italic>(
                    <italic toggle="yes">y</italic>) = max(
                    <italic toggle="yes">y</italic>
                    <sub>
                        <italic toggle="yes">t</italic>&#x2208;{1&#x2026;20}</sub>) &#x2212; min(
                    <italic toggle="yes">y</italic>
                    <sub>
                        <italic toggle="yes">t</italic>&#x2208;{1&#x2026;20}</sub>)), maximum difference in weekly counts over the entire observation period (
                    <italic toggle="yes">T</italic>(
                    <italic toggle="yes">y</italic>) = max(
                    <italic toggle="yes">y</italic>
                    <sub>t&#x2208;{1&#x2026;
                        <italic toggle="yes">N</italic>}</sub>) &#x2212; min(
                    <italic toggle="yes">y</italic>
                    <sub>t&#x2208;{1&#x2026;
                        <italic toggle="yes">N</italic>}</sub>), high seizure count based on observing two occasions with a count &gt; 18 (
                    <italic toggle="yes">T</italic>(
                    <italic toggle="yes">y</italic>) = #{
                    <italic toggle="yes">y</italic>
                    <sub>
                        <italic toggle="yes">t</italic>&#x2208;{1&#x2026; 
                        <italic toggle="yes">N</italic>}</sub> &gt; 18}), low seizure count based on observing 5 occasions with count &lt; 3, (
                    <italic toggle="yes">T</italic>(
                    <italic toggle="yes">y</italic>) = #{
                    <italic toggle="yes">y</italic>
                    <sub>
                        <italic toggle="yes">t</italic>&#x2208;{1&#x2026;
                        <italic toggle="yes">N</italic>}</sub> &lt; 3}), and the difference between the mean counts in the first and last ten observations, (
                    <italic toggle="yes">T</italic>(
                    <italic toggle="yes">y</italic>) = 
                    <italic toggle="yes">y</italic>&#x0304;
                    <sub>
                        <italic toggle="yes">t</italic>&#x2208;{1&#x2026;10}</sub> &#x2212; 
                    <italic toggle="yes">y</italic>&#x0304;
                    <sub>
                        <italic toggle="yes">t</italic>&#x2208;{
                        <italic toggle="yes">N</italic>&#x2212;9&#x2026;
                        <italic toggle="yes">N</italic>
                    </sub>}). Satisfactory results were obtained for all the tests, each of the models giving 
                    <italic toggle="yes">pB</italic> values that were mostly well removed from the tail of their distributions. The lowest 
                    <italic toggle="yes">p
                        <sub>B</sub>
                    </italic> value of 0.2 occurred in the test on the mean seizure count during the interval 22 to 27 weeks, as given by the 3-HM model. Thus, the Bayesian p-values indicate that the simplest of the three models (the 3-HM model) is not demonstrably inadequate. That said, visual inspection of the posterior predictive simulation plots given in 
                    <xref ref-type="fig" rid="f6">Figure 6</xref> indicates that the 3-HM model yields residuals that retain a degree of dependence on time, while the 3-HM-CAR residuals appear more random. The 3-HM-AR residuals appear somewhat less satisfactory than the 3-HM-CAR residuals (not shown).</p>
                <p>A final point that emerged from the model assessment exercise is that the process captured by the random effects term that is incorporated into the 3-HM-CAR model dominates the fitted seizure time dependence, with hidden-state transitions playing a minor role. This behaviour renders this model uninteresting from a clinical perspective in this case, although it remains important as a standard against which the simpler models can be compared. It should be noted that this observation does not exclude the possibility that a random effect HMM might be useful in other cases, and provide the required clinical insight.</p>
            </sec>
            <sec id="N7">
                <title>Note S7</title>
                <p>
                    <italic toggle="yes">
                        <bold>Case 3. Posterior predictive simulation and Bayesian p-value results.</bold>
                    </italic> Inspection of the posterior predictive simulated data and associated residual plots obtained for the third case (
                    <xref ref-type="other" rid="SF1">Figure S1</xref>) suggests that the 3-HM fails to capture fully the underlying curvature (similarly the 3-HM-AR model is not entirely satisfactory; plots not shown), while the 3-HM-CAR model gives the appearance of being adequate. Further investigation of the 3-HM-CAR model indicates, however, that it exhibits the same complete dominance of the random effect term that was observed in the previous case. The 2-HM-CAR model exhibits the same behaviour and these two models are dismissed as clinically uninteresting. The posterior predictive time series and residuals plots generated using the 3-HM-quad model (
                    <xref ref-type="other" rid="SF2">Figure S2</xref>) provide little suggestion of model inadequacy, a conclusion that is supported by the Bayesian p-values given by two curvature tests (
                    <italic toggle="yes">T</italic>(
                    <italic toggle="yes">y</italic>) = 
                    <italic toggle="yes">y</italic>&#x0304;
                    <sub>
                        <italic toggle="yes">t</italic>&#x2208;{1&#x2026;5}</sub> &#x2013; 
                    <italic toggle="yes">y</italic>&#x0304;
                    <sub>
                        <italic toggle="yes">t</italic>&#x2208;{21:25}</sub> and 
                    <italic toggle="yes">T</italic>(
                    <italic toggle="yes">y</italic>) = 
                    <italic toggle="yes">y</italic>&#x0304;
                    <sub>
                        <italic toggle="yes">t</italic>&#x2208;{
                        <italic toggle="yes">N</italic>&#x2013;4&#x2026;
                        <italic toggle="yes">N</italic>}</sub> &#x2013; 
                    <italic toggle="yes">y</italic>&#x0304;
                    <sub>
                        <italic toggle="yes">t</italic>&#x2208;{21:25}</sub>) designed to detect systematic model departure from the true underlying trend. These tests yielded Bayesian p-values of 0.23 and 0.36, respectively. We note that a more standard procedure would use a single test constructed by combining these two tests, 
                    <italic toggle="yes">T</italic>(
                    <italic toggle="yes">y</italic>) = 
                    <italic toggle="yes">y
                        <sub>start</sub>
                    </italic> &#x2212; 2 * 
                    <italic toggle="yes">y
                        <sub>mid</sub>
                    </italic> + 
                    <italic toggle="yes">y
                        <sub>end</sub>
                    </italic>, for example, but we have chosen to examine the two components separately.</p>
                <p>The preceding results indicating a preference for the 3-HM-quad model over the alternative 3-state models motivates an examination of the two-state and single-state quadratic models. The 2-HM-quad model yields 
                    <italic toggle="yes">p
                        <sub>B</sub>
                    </italic> = 0.21 and 0.34, respectively, for the two curvature tests, which are satisfactory. These results are broadly consistent with the residuals plots generated by posterior predictive simulation (
                    <xref ref-type="other" rid="SF3">Figure S3</xref>), although these do appear marginally less random than those derived from the 3-HM-quad model, suggesting a degree of inadequacy in the 2-HM-quad model. Nevertheless, we focus on this model because of its relative simplicity and the useful clinical insight it provides. The hidden-state trajectories are shown in 
                    <xref ref-type="other" rid="SF4">Figure S4</xref>, these indicating the occurrence of multiple transitions. These plots, together with the associated time-dependent Poisson rates (
                    <xref ref-type="table" rid="T3">Table 3</xref>), indicate that hidden-state switching and quadratic dependence in the state-specific Poisson rates both make important contributions to the observed time dependence. The single-state quadratic model yields 
                    <italic toggle="yes">p
                        <sub>B</sub>
                    </italic> = 0.039 and 0.11, respectively, for the two curvature tests, indicating model inadequacy. This is consistent with the residuals plots generated by posterior predictive simulation which indicate the presence of structure as opposed to complete randomness (these residuals plots are not included in this report).</p>
                <fig fig-type="figure" id="SF1" orientation="portrait" position="float">
                    <label>Figure S1. </label>
                    <caption>
                        <title>Case 3 time-series data.</title>
                        <p>(Top row, column 
                            <bold>a</bold>) The observed seizure-count time series. This plot is a duplicate of 
                            <xref ref-type="fig" rid="f8">Figure 8</xref> and is shown here to assist comparison with the simulated time-series data. (Columns 
                            <bold>b</bold> and 
                            <bold>c</bold>) Posterior predictive simulation results generated using two alternative 3-state HMMs. The first assumes time independent Poisson parameters, while the rate parameters of the second model include a temporal random effect term. The top row plots (columns 
                            <bold>b</bold> and 
                            <bold>c</bold>) each show 10 predictive time series generated by sampling the posterior predictive simulation output at evenly spaced intervals. The associated residuals plots are given in the bottom row.</p>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/10507/5b001739-d79d-4ffb-ab46-190631b22c0a_suppl_figure1.gif"/>
                </fig>
                <fig fig-type="figure" id="SF2" orientation="portrait" position="float">
                    <label>Figure S2. </label>
                    <caption>
                        <title>Case 3 3-HM-quad model posterior predictive simulated data plots.</title>
                        <p>(a) 10 predictive time series, as obtained by sampling the MCMC output at evenly spaced intervals, and (b) associated residuals plots.</p>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/10507/5b001739-d79d-4ffb-ab46-190631b22c0a_suppl_figure2.gif"/>
                </fig>
                <fig fig-type="figure" id="SF3" orientation="portrait" position="float">
                    <label>Figure S3. </label>
                    <caption>
                        <title>Case 3 2-HM-quad posterior predictive simulated data plots.</title>
                        <p>(a) 10 predictive time series, as obtained by sampling the MCMC output at evenly spaced intervals, and (b) associated residuals plots.</p>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/10507/5b001739-d79d-4ffb-ab46-190631b22c0a_suppl_figure3.gif"/>
                </fig>
                <fig fig-type="figure" id="SF4" orientation="portrait" position="float">
                    <label>Figure S4. </label>
                    <caption>
                        <title>Case 3 seizure-state time series plots.</title>
                        <p>These plots show which state is most credible at each occasion, as given by 
                            <inline-formula>
                                <mml:math display="inline" id="M7">
                                    <mml:mrow>
                                        <mml:mi>P</mml:mi>
                                        <mml:mrow>
                                            <mml:mo>(</mml:mo>
                                            <mml:mrow>
                                                <mml:msub>
                                                    <mml:mi>Z</mml:mi>
                                                    <mml:mi>t</mml:mi>
                                                </mml:msub>
                                                <mml:mo>=</mml:mo>
                                                <mml:mi>i</mml:mi>
                                                <mml:mo>|</mml:mo>
                                                <mml:mtext mathvariant="italic">data</mml:mtext>
                                            </mml:mrow>
                                            <mml:mo>)</mml:mo>
                                        </mml:mrow>
                                        <mml:mo>=</mml:mo>
                                        <mml:mi>#</mml:mi>
                                        <mml:mrow>
                                            <mml:mrow>
                                                <mml:mo>{</mml:mo>
                                                <mml:msubsup>
                                                    <mml:mi>Z</mml:mi>
                                                    <mml:mi>t</mml:mi>
                                                    <mml:mrow>
                                                        <mml:mrow>
                                                            <mml:mo>(</mml:mo>
                                                            <mml:mi>T</mml:mi>
                                                            <mml:mo>)</mml:mo>
                                                        </mml:mrow>
                                                    </mml:mrow>
                                                </mml:msubsup>
                                                <mml:mo>=</mml:mo>
                                                <mml:mi>i</mml:mi>
                                                <mml:mo>}</mml:mo>
                                            </mml:mrow>
                                            <mml:mo>/</mml:mo>
                                            <mml:mrow>
                                                <mml:msub>
                                                    <mml:mi>N</mml:mi>
                                                    <mml:mrow>
                                                        <mml:mi>s</mml:mi>
                                                        <mml:mi>i</mml:mi>
                                                        <mml:mi>m</mml:mi>
                                                    </mml:mrow>
                                                </mml:msub>
                                            </mml:mrow>
                                        </mml:mrow>
                                    </mml:mrow>
                                </mml:math>
                            </inline-formula> derived from the 2-HM-quad model. (a) 
                            <italic toggle="yes">P</italic>(
                            <italic toggle="yes">Z
                                <sub>t</sub>
                            </italic> = 
                            <italic toggle="yes">i|data</italic>) trajectory, (b) time series plot indicating which state has the largest value for 
                            <italic toggle="yes">P</italic>(
                            <italic toggle="yes">Z
                                <sub>t</sub>
                            </italic> = 
                            <italic toggle="yes">i|data</italic>) on each occasion (dashed-curve), superimposed on the observed seizure count time series (solid line). The 
                            <italic toggle="yes">most credible state</italic> curve shows the median estimate of the time-dependent seizure rate associated with that state. It serves to illustrate the magnitude of the change in mean seizure activity that is attributable to the quadratic time dependence, relative to the change caused by between-state transitions.</p>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/10507/5b001739-d79d-4ffb-ab46-190631b22c0a_suppl_figure4.gif"/>
                </fig>
            </sec>
        </sec>
        <ref-list>
            <ref id="ref-1">
                <label>1</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Kwan</surname>
                            <given-names>P</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Brodie</surname>
                            <given-names>MJ</given-names>
                        </name>
					</person-group>:
                    <article-title>Early identification of refractory epilepsy.</article-title>
                    <source>
						
                        <italic toggle="yes">N Engl J Med.</italic>
					</source>
                    <year>2000</year>;<volume>342</volume>(<issue>5</issue>):<fpage>314</fpage>&#x2013;<lpage>319</lpage>.
                    <pub-id pub-id-type="pmid">10660394</pub-id>
                    <pub-id pub-id-type="doi">10.1056/NEJM200002033420503</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-2">
                <label>2</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Haut</surname>
                            <given-names>SR</given-names>
                        </name>
					</person-group>:
                    <article-title>Seizure clustering.</article-title>
                    <source>
						
                        <italic toggle="yes">Epilepsy Behav.</italic>
					</source>
                    <year>2006</year>;<volume>8</volume>(<issue>1</issue>):<fpage>50</fpage>&#x2013;<lpage>55</lpage>.
                    <pub-id pub-id-type="pmid">16246629</pub-id>
                    <pub-id pub-id-type="doi">10.1016/j.yebeh.2005.08.018</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-3">
                <label>3</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Pujar</surname>
                            <given-names>S</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Calvert</surname>
                            <given-names>S</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Cortina-Borja</surname>
                            <given-names>M</given-names>
                        </name>
						
                        <etal/>
					</person-group>:
                    <article-title>Statistical process control (SPC)--a simple objective method for monitoring seizure frequency and evaluating effectiveness of drug interventions in refractory childhood epilepsy.</article-title>
                    <source>
						
                        <italic toggle="yes">Epilepsy Res.</italic>
					</source>
                    <year>2010</year>;<volume>91</volume>(<issue>2&#x2013;3</issue>):<fpage>205</fpage>&#x2013;<lpage>213</lpage>.
                    <pub-id pub-id-type="pmid">20810251</pub-id>
                    <pub-id pub-id-type="doi">10.1016/j.eplepsyres.2010.07.013</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-4">
                <label>4</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Hopkins</surname>
                            <given-names>A</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Davies</surname>
                            <given-names>P</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Dobson</surname>
                            <given-names>C</given-names>
                        </name>
					</person-group>:
                    <article-title>Mathematical models of patterns of seizures. Their use in the evaluation of drugs.</article-title>
                    <source>
						
                        <italic toggle="yes">Arch Neurol.</italic>
					</source>
                    <year>1985</year>;<volume>42</volume>(<issue>5</issue>):<fpage>463</fpage>&#x2013;<lpage>467</lpage>.
                    <pub-id pub-id-type="pmid">3888154</pub-id>
                    <pub-id pub-id-type="doi">10.1001/archneur.1985.04060050061009</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-5">
                <label>5</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Albert</surname>
                            <given-names>PS</given-names>
                        </name>
					</person-group>:
                    <article-title>A two-state Markov mixture model for a time series of epileptic seizure counts.</article-title>
                    <source>
						
                        <italic toggle="yes">Biometrics.</italic>
					</source>
                    <year>1991</year>;<volume>47</volume>(<issue>4</issue>):<fpage>1371</fpage>&#x2013;<lpage>1381</lpage>.
                    <pub-id pub-id-type="pmid">1786324</pub-id>
                    <pub-id pub-id-type="doi">10.2307/2532392</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-6">
                <label>6</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Wang</surname>
                            <given-names>P</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Puterman</surname>
                            <given-names>ML</given-names>
                        </name>
					</person-group>:
                    <article-title>Analysis of longitudinal data of epileptic seizure counts - a two-state hidden Markov regression approach.</article-title>
                    <source>
						
                        <italic toggle="yes">Biometric J.</italic>
					</source>
                    <year>2001</year>;<volume>43</volume>(<issue>8</issue>):<fpage>941</fpage>&#x2013;<lpage>962</lpage>.
                    <pub-id pub-id-type="doi">10.1002/1521-4036(200112)43:8&lt;941::AID-BIMJ941&gt;3.0.CO;2-%23</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-7">
                <label>7</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Wong</surname>
                            <given-names>S</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Gardner</surname>
                            <given-names>AB</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Krieger</surname>
                            <given-names>AM</given-names>
                        </name>
						
                        <etal/>
					</person-group>:
                    <article-title>A stochastic framework for evaluating seizure prediction algorithms using hidden Markov models.</article-title>
                    <source>
						
                        <italic toggle="yes">J Neurophysiol.</italic>
					</source>
                    <year>2007</year>;<volume>97</volume>(<issue>3</issue>):<fpage>2525</fpage>&#x2013;<lpage>2532</lpage>.
                    <pub-id pub-id-type="pmid">17021032</pub-id>
                    <pub-id pub-id-type="doi">10.1152/jn.00190.2006</pub-id>
                    <pub-id pub-id-type="pmcid">2230664</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-8">
                <label>8</label>
                <mixed-citation publication-type="book">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Zucchini</surname>
                            <given-names>W</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>MacDonald</surname>
                            <given-names>IL</given-names>
                        </name>
					</person-group>:
                    <article-title>Hidden Markov models for time series: an introduction using R</article-title>. Boca Raton, Florida: Chapman &amp; Hall/CRC;<year>2009</year>.
                    <ext-link ext-link-type="uri" xlink:href="https://books.google.co.in/books?hl=en&amp;lr=&amp;id=LDDzvCsdVs8C&amp;oi=fnd&amp;pg=PP1&amp;dq=Hidden+Markov+models+for+time+series:+an+introduction+using+R.+pdf&amp;ots=Ept7xb6AHZ&amp;sig=XWXbPodhf-9ujbTkCSHO5xnLz9g#v=onepage&amp;q&amp;f=false">Reference Source</ext-link>
                </mixed-citation>
            </ref>
            <ref id="ref-9">
                <label>9</label>
                <mixed-citation publication-type="book">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Gelman</surname>
                            <given-names>A</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Carlin</surname>
                            <given-names>JB</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Stern</surname>
                            <given-names>HS</given-names>
                        </name>
						
                        <etal/>
					</person-group>:
                    <article-title>Bayesian data analysis</article-title>. 2nd ed. Boca Raton, Florida: Chapman &amp; Hall/CRC;<year>2004</year>.
                    <ext-link ext-link-type="uri" xlink:href="https://vk.com/doc168073_327287692?hash=6c23b15d7259b25c31&amp;dl=4703557d87ec82400c">Reference Source</ext-link>
                </mixed-citation>
            </ref>
            <ref id="ref-10">
                <label>10</label>
                <mixed-citation publication-type="book">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Carlin</surname>
                            <given-names>BP</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Louis</surname>
                            <given-names>TA</given-names>
                        </name>
					</person-group>:
                    <article-title>Bayesian methods for data analysis</article-title>. 3rd ed. Boca Raton, Florida: Chapman &amp; Hall/CRC;<year>2009</year>.
                    <ext-link ext-link-type="uri" xlink:href="https://books.google.co.in/books?id=GTJUt8fcFx8C&amp;printsec=frontcover">Reference Source</ext-link>
                </mixed-citation>
            </ref>
            <ref id="ref-11">
                <label>11</label>
                <mixed-citation publication-type="book">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Davison</surname>
                            <given-names>AC</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Hinkley</surname>
                            <given-names>DV</given-names>
                        </name>
					</person-group>:
                    <article-title>Bootstrap methods and their application</article-title>. Cambridge: Cambridge University Press;<year>1997</year>.
                    <pub-id pub-id-type="doi">10.1017/CBO9780511802843</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-12">
                <label>12</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Lunn</surname>
                            <given-names>DJ</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Thomas</surname>
                            <given-names>A</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Best</surname>
                            <given-names>N</given-names>
                        </name>
						
                        <etal/>
					</person-group>:
                    <article-title>WinBUGS - A Bayesian modelling framework: Concepts, structure, and extensibility.</article-title>
                    <source>
						
                        <italic toggle="yes">Stat Comput.</italic>
					</source>
                    <year>2000</year>;<volume>10</volume>:<fpage>325</fpage>&#x2013;<lpage>337</lpage>.
                    <pub-id pub-id-type="doi">10.1023/A:1008929526011</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-13">
                <label>13</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Gelman</surname>
                            <given-names>A</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Goegebeur</surname>
                            <given-names>Y</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Tuerlinckx</surname>
                            <given-names>F</given-names>
                        </name>
						
                        <etal/>
					</person-group>:
                    <article-title>Diagnostic checks for discrete data regression models using posterior predictive simulations.</article-title>
                    <source>
						
                        <italic toggle="yes">Appl Stat.</italic>
					</source>
                    <year>2000</year>;<volume>49</volume>:<fpage>247</fpage>&#x2013;<lpage>268</lpage>.
                    <pub-id pub-id-type="doi">10.1111/1467-9876.00190</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-14">
                <label>14</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Gelman</surname>
                            <given-names>A</given-names>
                        </name>
					</person-group>:
                    <article-title>Exploratory data analysis for complex models.</article-title>
                    <source>
						
                        <italic toggle="yes">J Comput Graph Stat.</italic>
					</source>
                    <year>2004</year>;<volume>13</volume>:<fpage>755</fpage>&#x2013;<lpage>779</lpage>.
                    <pub-id pub-id-type="doi">10.1198/106186004X11435</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-15">
                <label>15</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Jackson</surname>
                            <given-names>CH</given-names>
                        </name>
					</person-group>:
                    <article-title>Multi-state models for panel data: The msm package for R.</article-title>
                    <source>
						
                        <italic toggle="yes">J Stat Softw.</italic>
					</source>
                    <year>2011</year>;<volume>38</volume>(<issue>8</issue>):<fpage>1</fpage>&#x2013;<lpage>28</lpage>.
                    <ext-link ext-link-type="uri" xlink:href="http://www.jstatsoft.org/v38/i08/">Reference Source</ext-link>
                </mixed-citation>
            </ref>
            <ref id="ref-16">
                <label>16</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Haut</surname>
                            <given-names>SR</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Hall</surname>
                            <given-names>CB</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Masur</surname>
                            <given-names>J</given-names>
                        </name>
						
                        <etal/>
					</person-group>:
                    <article-title>Seizure occurrence: precipitants and prediction.</article-title>
                    <source>
						
                        <italic toggle="yes">Neurology.</italic>
					</source>
                    <year>2007</year>;<volume>69</volume>(<issue>20</issue>):<fpage>1905</fpage>&#x2013;<lpage>1910</lpage>.
                    <pub-id pub-id-type="pmid">17998482</pub-id>
                    <pub-id pub-id-type="doi">10.1212/01.wnl.0000278112.48285.84</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-17">
                <label>17</label>
                <mixed-citation publication-type="book">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Congdon</surname>
                            <given-names>P</given-names>
                        </name>
					</person-group>:
                    <article-title>Bayesian statistical modelling</article-title>. 2nd ed. Chichester: John Wiley;<year>2006</year>.
                    <ext-link ext-link-type="uri" xlink:href="http://bacbuc.hd.free.fr/WebDAV/data/Bouquins/Congdon%20-%20Bayesian%20Statistical%20Modelling.pdf">Reference Source</ext-link>
                </mixed-citation>
            </ref>
            <ref id="ref-18">
                <label>18</label>
                <mixed-citation publication-type="book">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Lunn</surname>
                            <given-names>D</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Jackson</surname>
                            <given-names>C</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Best</surname>
                            <given-names>N</given-names>
                        </name>
						
                        <etal/>
					</person-group>:
                    <article-title>The BUGS book - a practical introduction to Bayesian analysis.</article-title>Boca Raton, Florida: CRC Press;<year>2013</year>.
                    <pub-id pub-id-type="doi">10.1111/anzs.12058</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-19">
                <label>19</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>George</surname>
                            <given-names>EI</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Makov</surname>
                            <given-names>UE</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Smith</surname>
                            <given-names>AFM</given-names>
                        </name>
					</person-group>:
                    <article-title>Conjugate likelihood distributions.</article-title>
                    <source>
						
                        <italic toggle="yes">Scand J Statist.</italic>
					</source>
                    <year>1993</year>;<volume>20</volume>:<fpage>147</fpage>&#x2013;<lpage>156</lpage>.
                    <ext-link ext-link-type="uri" xlink:href="https://www.researchgate.net/profile/Edward_George/publication/265142375_Conjugate_Likelihood_Distributions/links/55b1085708aec0e5f430eb36.pdf?inViewer=0&amp;pdfJsDownload=0&amp;origin=publication_detail">Reference Source</ext-link>
                </mixed-citation>
            </ref>
            <ref id="ref-20">
                <label>20</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Gelfand</surname>
                            <given-names>AE</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Smith</surname>
                            <given-names>AFM</given-names>
                        </name>
					</person-group>:
                    <article-title>Sampling-based approaches to calculating marginal densities.</article-title>
                    <source>
						
                        <italic toggle="yes">J Am Stat Assoc.</italic>
					</source>
                    <year>1990</year>;<volume>85</volume>(<issue>410</issue>):<fpage>398</fpage>&#x2013;<lpage>409</lpage>.
                    <pub-id pub-id-type="doi">10.2307/2289776</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-21">
                <label>21</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Bulla</surname>
                            <given-names>J</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Bulla</surname>
                            <given-names>I</given-names>
                        </name>
					</person-group>:
                    <article-title>Stylized facts of financial time series and hidden semi-Markov models.</article-title>
                    <source>
						
                        <italic toggle="yes">Comput Stat Data Anal.</italic>
					</source>
                    <year>2006</year>;<volume>51</volume>(<issue>4</issue>):<fpage>2192</fpage>&#x2013;<lpage>2209</lpage>.
                    <pub-id pub-id-type="doi">10.1016/j.csda.2006.07.021</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-22">
                <label>22</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Gelfand</surname>
                            <given-names>AE</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Hills</surname>
                            <given-names>SE</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Racine-Poon</surname>
                            <given-names>A</given-names>
                        </name>
						
                        <etal/>
					</person-group>:
                    <article-title>Illustration of Bayesian inference in normal data models using Gibbs sampling.</article-title>
                    <source>
						
                        <italic toggle="yes">J Am Stat Assoc.</italic>
					</source>
                    <year>1990</year>;<volume>85</volume>(<issue>412</issue>):<fpage>972</fpage>&#x2013;<lpage>985</lpage>.
                    <pub-id pub-id-type="doi">10.1080/01621459.1990.10474968</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-23">
                <label>23</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Lunn</surname>
                            <given-names>D</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Spiegelhalter</surname>
                            <given-names>D</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Thomas</surname>
                            <given-names>A</given-names>
                        </name>
						
                        <etal/>
					</person-group>:
                    <article-title>The BUGS project: Evolution, critique and future directions.</article-title>
                    <source>
						
                        <italic toggle="yes">Stat Med.</italic>
					</source>
                    <year>2009</year>;<volume>28</volume>(<issue>25</issue>):<fpage>3049</fpage>&#x2013;<lpage>3067</lpage>.
                    <pub-id pub-id-type="pmid">19630097</pub-id>
                    <pub-id pub-id-type="doi">10.1002/sim.3680</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-24">
                <label>24</label>
                <mixed-citation publication-type="book">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Thomas</surname>
                            <given-names>A</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Best</surname>
                            <given-names>N</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Lunn</surname>
                            <given-names>D</given-names>
                        </name>
						
                        <etal/>
					</person-group>:
                    <article-title>GeoBUGS user manual</article-title>.<year>2004</year>.
                    <ext-link ext-link-type="uri" xlink:href="http://www.mrc-bsu.cam.ac.uk/wp-content/uploads/geobugs12manual.pdf">Reference Source</ext-link>
                </mixed-citation>
            </ref>
            <ref id="ref-25">
                <label>25</label>
                <mixed-citation publication-type="book">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Lunn</surname>
                            <given-names>D</given-names>
                        </name>
					</person-group>:
                    <article-title>WinBUGS development interface (WBDev)</article-title>.
                    <italic toggle="yes">ISBA Bulletin</italic>.<year>2003</year>;<volume>10</volume>(<issue>3</issue>):<fpage>10</fpage>&#x2013;<lpage>11</lpage>.
                    <ext-link ext-link-type="uri" xlink:href="http://www.mrc-bsu.cam.ac.uk/software/bugs/the-bugs-project-latest-news/winbugs-development-interface-wbdev/">Reference Source</ext-link>
                </mixed-citation>
            </ref>
            <ref id="ref-26">
                <label>26</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Cowles</surname>
                            <given-names>MK</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Carlin</surname>
                            <given-names>BP</given-names>
                        </name>
					</person-group>:
                    <article-title>Markov chain Monte Carlo convergence diagnostics: a comparative review.</article-title>
                    <source>
						
                        <italic toggle="yes">J Am Stat Assoc.</italic>
					</source>
                    <year>1996</year>;<volume>91</volume>(<issue>434</issue>):<fpage>883</fpage>&#x2013;<lpage>904</lpage>.
                    <pub-id pub-id-type="doi">10.1080/01621459.1996.10476956</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-27">
                <label>27</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Plummer</surname>
                            <given-names>M</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Best</surname>
                            <given-names>N</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Cowles</surname>
                            <given-names>K</given-names>
                        </name>
						
                        <etal/>
					</person-group>:
                    <article-title>CODA: Convergence diagnosis and output analysis for MCMC.</article-title>
                    <source>
						
                        <italic toggle="yes">R News.</italic>
					</source>
                    <year>2006</year>;<volume>6</volume>(<issue>1</issue>):<fpage>7</fpage>&#x2013;<lpage>11</lpage>.
                    <ext-link ext-link-type="uri" xlink:href="http://oro.open.ac.uk/22547/">Reference Source</ext-link>
                </mixed-citation>
            </ref>
            <ref id="ref-28">
                <label>28</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Schmidt</surname>
                            <given-names>D</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Elger</surname>
                            <given-names>C</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Holmes</surname>
                            <given-names>GL</given-names>
                        </name>
					</person-group>:
                    <article-title>Pharmacological overtreatment in epilepsy: mechanisms and management.</article-title>
                    <source>
						
                        <italic toggle="yes">Epilepsy Res.</italic>
					</source>
                    <year>2002</year>;<volume>52</volume>(<issue>1</issue>):<fpage>3</fpage>&#x2013;<lpage>14</lpage>.
                    <pub-id pub-id-type="pmid">12445955</pub-id>
                    <pub-id pub-id-type="doi">10.1016/S0920-1211(02)00180-8</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-29">
                <label>29</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Gelman</surname>
                            <given-names>A</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Bois</surname>
                            <given-names>F</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Jiang</surname>
                            <given-names>J</given-names>
                        </name>
					</person-group>:
                    <article-title>Physiological pharmacokinetic analysis using population modeling and informative prior distributions.</article-title>
                    <source>
						
                        <italic toggle="yes">J Am Stat Assoc.</italic>
					</source>
                    <year>1996</year>;<volume>91</volume>(<issue>436</issue>):<fpage>1400</fpage>&#x2013;<lpage>1412</lpage>.
                    <pub-id pub-id-type="doi">10.1080/01621459.1996.10476708</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-30">
                <label>30</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Wakefield</surname>
                            <given-names>J</given-names>
                        </name>
					</person-group>:
                    <article-title>The Bayesian analysis of population pharmacokinetic models.</article-title>
                    <source>
						
                        <italic toggle="yes">J Am Stat Assoc.</italic>
					</source>
                    <year>1996</year>;<volume>91</volume>(<issue>433</issue>):<fpage>62</fpage>&#x2013;<lpage>75</lpage>.
                    <pub-id pub-id-type="doi">10.1080/01621459.1996.10476664</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-31">
                <label>31</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Chang</surname>
                            <given-names>T</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Schiff</surname>
                            <given-names>SJ</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Sauer</surname>
                            <given-names>T</given-names>
                        </name>
						
                        <etal/>
					</person-group>:
                    <article-title>Stochastic versus deterministic variability in simple neuronal circuits: I. Monosynaptic spinal cord reflexes.</article-title>
                    <source>
						
                        <italic toggle="yes">Biophys J.</italic>
					</source>
                    <year>1994</year>;<volume>67</volume>(<issue>2</issue>):<fpage>671</fpage>&#x2013;<lpage>683</lpage>.
                    <pub-id pub-id-type="pmid">7948680</pub-id>
                    <pub-id pub-id-type="doi">10.1016/S0006-3495(94)80526-0</pub-id>
                    <pub-id pub-id-type="pmcid">1225409</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-32">
                <label>32</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Schiff</surname>
                            <given-names>SJ</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Sauer</surname>
                            <given-names>T</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Chang</surname>
                            <given-names>T</given-names>
                        </name>
					</person-group>:
                    <article-title>Discriminating deterministic versus stochastic dynamics in neuronal activity.</article-title>
                    <source>
						
                        <italic toggle="yes">Integr Physiol Behav Sci.</italic>
					</source>
                    <year>1994</year>;<volume>29</volume>(<issue>3</issue>):<fpage>246</fpage>&#x2013;<lpage>261</lpage>.
                    <pub-id pub-id-type="pmid">7811645</pub-id>
                    <pub-id pub-id-type="doi">10.1007/BF02691329</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-33">
                <label>33</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Werndl</surname>
                            <given-names>C</given-names>
                        </name>
					</person-group>:
                    <article-title>Are deterministic descriptions and indeterministic descriptions observationally equivalent?</article-title>
                    <source>
						
                        <italic toggle="yes">Stud Hist Philos M P.</italic>
					</source>
                    <year>2009</year>;<volume>40</volume>(<issue>3</issue>):<fpage>232</fpage>&#x2013;<lpage>242</lpage>.
                    <pub-id pub-id-type="doi">10.1016/j.shpsb.2009.06.004</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-34">
                <label>34</label>
                <mixed-citation publication-type="data">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>King</surname>
                            <given-names>M</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Pujar</surname>
                            <given-names>S</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Scott</surname>
                            <given-names>R</given-names>
                        </name>
					</person-group>:
                    <article-title>Dataset 1 in: A hidden Markov model analysis of subject-specific seizure time-series data as a potential aid to clinical decision making.</article-title>
                    <source>
						
                        <italic toggle="yes">F1000Research.</italic>
					</source>
                    <year>2016</year>.
                    <ext-link ext-link-type="uri" xlink:href="http://dx.doi.org/10.5256/f1000research.9746.d138204">Data Source</ext-link>
                </mixed-citation>
            </ref>
            <ref id="ref-35">
                <label>35</label>
                <mixed-citation publication-type="book">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Gelman</surname>
                            <given-names>A</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Meng</surname>
                            <given-names>X-L</given-names>
                        </name>
					</person-group>:
                    <article-title>Model checking and model improvement</article-title>. In: Gilks WR, Richardson S, Spiegelhalter DJ, editors.
                    <italic toggle="yes">Markov chain Monte Carlo in practice</italic>. London: Chapman &amp; Hall;<year>1996</year>;<fpage>189</fpage>&#x2013;<lpage>201</lpage>.
                    <ext-link ext-link-type="uri" xlink:href="http://www.stat.columbia.edu/~gelman/research/published/w2.pdf">Reference Source</ext-link>
                </mixed-citation>
            </ref>
            <ref id="ref-36">
                <label>36</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Gelman</surname>
                            <given-names>A</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Meng</surname>
                            <given-names>X-L</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Stern</surname>
                            <given-names>H</given-names>
                        </name>
					</person-group>:
                    <article-title>Posterior predictive assessment of model fitness via realized discrepancies.</article-title>
                    <source>
						
                        <italic toggle="yes">Statist Sinica.</italic>
					</source>
                    <year>1996</year>;<volume>6</volume>(<issue>4</issue>):<fpage>733</fpage>&#x2013;<lpage>808</lpage>.
                    <ext-link ext-link-type="uri" xlink:href="http://www.jstor.org/stable/24306036">Reference Source</ext-link>
                </mixed-citation>
            </ref>
            <ref id="ref-37">
                <label>37</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Gelman</surname>
                            <given-names>A</given-names>
                        </name>
					</person-group>:
                    <article-title>Comment: Bayesian checking of the second levels of hierarchical models.</article-title>
                    <source>
						
                        <italic toggle="yes">Statist Sci.</italic>
					</source>
                    <year>2007</year>;<volume>22</volume>(<issue>3</issue>):<fpage>349</fpage>&#x2013;<lpage>352</lpage>.
                    <pub-id pub-id-type="doi">10.1214/07-STS235A</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-38">
                <label>38</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Bayarri</surname>
                            <given-names>MJ</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Castellanos</surname>
                            <given-names>ME</given-names>
                        </name>
					</person-group>:
                    <article-title>Bayesian checking of the second levels of hierarchical models.</article-title>
                    <source>
						
                        <italic toggle="yes">Statist Sci.</italic>
					</source>
                    <year>2007</year>;<volume>22</volume>(<issue>3</issue>):<fpage>322</fpage>&#x2013;<lpage>343</lpage>.
                    <pub-id pub-id-type="doi">10.1214/07-STS235</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-39">
                <label>39</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Richardson</surname>
                            <given-names>S</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Green</surname>
                            <given-names>PJ</given-names>
                        </name>
					</person-group>:
                    <article-title>On Bayesian analysis of mixtures with an unknown number of components.</article-title>
                    <source>
						
                        <italic toggle="yes">J R Statist Soc B.</italic>
					</source>
                    <year>1997</year>;<volume>59</volume>(<issue>4</issue>):<fpage>731</fpage>&#x2013;<lpage>792</lpage>.
                    <pub-id pub-id-type="doi">10.1111/1467-9868.00095</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-40">
                <label>40</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Stephens</surname>
                            <given-names>M</given-names>
                        </name>
					</person-group>:
                    <article-title>Dealing with label switching in mixture models.</article-title>
                    <source>
						
                        <italic toggle="yes">J R Statist Soc B.</italic>
					</source>
                    <year>2000</year>;<volume>62</volume>(<issue>4</issue>):<fpage>795</fpage>&#x2013;<lpage>809</lpage>.
                    <pub-id pub-id-type="doi">10.1111/1467-9868.00265</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-41">
                <label>41</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Celeux</surname>
                            <given-names>G</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Hurn</surname>
                            <given-names>M</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Robert</surname>
                            <given-names>CP</given-names>
                        </name>
					</person-group>:
                    <article-title>Computational and inferential difficulties with mixture posterior distributions.</article-title>
                    <source>
						
                        <italic toggle="yes">J Am Stat Assoc.</italic>
					</source>
                    <year>2000</year>;<volume>95</volume>(<issue>451</issue>):<fpage>957</fpage>&#x2013;<lpage>970</lpage>.
                    <pub-id pub-id-type="doi">10.2307/2669477</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-42">
                <label>42</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Jasra</surname>
                            <given-names>A</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Holmes</surname>
                            <given-names>CC</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Stephens</surname>
                            <given-names>DA</given-names>
                        </name>
					</person-group>:
                    <article-title>Markov chain Monte Carlo methods and the label switching problem in Bayesian mixture modeling.</article-title>
                    <source>
						
                        <italic toggle="yes">Stat Sci.</italic>
					</source>
                    <year>2005</year>;<volume>20</volume>(<issue>1</issue>):<fpage>50</fpage>&#x2013;<lpage>67</lpage>.
                    <pub-id pub-id-type="doi">10.1214/088342305000000016</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-43">
                <label>43</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Geweke</surname>
                            <given-names>J</given-names>
                        </name>
					</person-group>:
                    <article-title>Interpretation and inference in mixture models: simple MCMC works.</article-title>
                    <source>
						
                        <italic toggle="yes">Comput Stat Data Anal.</italic>
					</source>
                    <year>2007</year>;<volume>51</volume>(<issue>7</issue>):<fpage>3529</fpage>&#x2013;<lpage>3550</lpage>.
                    <pub-id pub-id-type="doi">10.1016/j.csda.2006.11.026</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-44">
                <label>44</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>King</surname>
                            <given-names>MD</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Gadian</surname>
                            <given-names>DG</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Clark</surname>
                            <given-names>CA</given-names>
                        </name>
					</person-group>:
                    <article-title>A random effects modelling approach to the crossing-fibre problem in tractography.</article-title>
                    <source>
						
                        <italic toggle="yes">Neuroimage.</italic>
					</source>
                    <year>2009</year>;<volume>44</volume>(<issue>3</issue>):<fpage>753</fpage>&#x2013;<lpage>768</lpage>.
                    <pub-id pub-id-type="pmid">19007890</pub-id>
                    <pub-id pub-id-type="doi">10.1016/j.neuroimage.2008.09.058</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-45">
                <label>45</label>
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Shaddick</surname>
                            <given-names>G</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Wakefield</surname>
                            <given-names>J</given-names>
                        </name>
					</person-group>:
                    <article-title>Modelling daily multivariate pollutant data at multiple sites.</article-title>
                    <source>
						
                        <italic toggle="yes">Appl Stat.</italic>
					</source>
                    <year>2002</year>;<volume>51</volume>(<issue>3</issue>):<fpage>351</fpage>&#x2013;<lpage>372</lpage>.
                    <pub-id pub-id-type="doi">10.1111/1467-9876.00273</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-46">
                <label>46</label>
                <mixed-citation publication-type="book">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Wakefield</surname>
                            <given-names>JC</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Best</surname>
                            <given-names>NG</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Waller</surname>
                            <given-names>L</given-names>
                        </name>
					</person-group>:
                    <article-title>Bayesian approaches to disease mapping</article-title>. In: Elliott P, Wakefield JC, Best NG,
                    <italic toggle="yes">et al.</italic>, editors.
                    <italic toggle="yes">Spatial epidemiology: methods and applications</italic>. Oxford: Oxford University Press;<year>2000</year>;<fpage>104</fpage>&#x2013;<lpage>127</lpage>.
                    <pub-id pub-id-type="doi">10.1093/acprof:oso/9780198515326.003.0007</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-47">
                <label>47</label>
                <mixed-citation publication-type="book">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Spiegelhalter</surname>
                            <given-names>D</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Thomas</surname>
                            <given-names>A</given-names>
                        </name>
						
                        <name name-style="western">
                            <surname>Best</surname>
                            <given-names>N</given-names>
                        </name>
						
                        <etal/>
					</person-group>:
                    <article-title>WinBUGS user manual</article-title>. MRC Biostatistics Unit, Institute of Public Health, Cambridge;<year>2003</year>.
                    <ext-link ext-link-type="uri" xlink:href="http://www.mrc-bsu.cam.ac.uk/wp-content/uploads/manual14">Reference Source</ext-link>
                </mixed-citation>
            </ref>
            <ref id="ref-48">
                <label>48</label>
                <mixed-citation publication-type="book">
                    <person-group person-group-type="author">
						
                        <name name-style="western">
                            <surname>Congdon</surname>
                            <given-names>P</given-names>
                        </name>
					</person-group>:
                    <article-title>Bayesian statistical modelling.</article-title>Chichester: John Wiley;<year>2001</year>.
                    <ext-link ext-link-type="uri" xlink:href="http://bacbuc.hd.free.fr/WebDAV/data/Bouquins/Congdon%20-%20Bayesian%20Statistical%20Modelling.pdf">Reference Source</ext-link>
                </mixed-citation>
            </ref>
        </ref-list>
    </back>
</article>
