Package: markovchain 1.2.1

Giorgio Alfredo Spedicato
markovchain: Easy Handling Discrete Time Markov Chains
Functions and S4 classes to create, manage and analyse discrete time Markov chains. Includes probabilistic analysis of chain structure (state classification, hitting times, stationary distributions, spectral and mixing diagnostics), statistical inference (maximum likelihood and Bayesian estimation, tests of the Markov property, homogeneity, stationarity and order, simulation), higher-order and multivariate chains, state aggregation, and import/export to JSON, YAML and CSV. Basic support for continuous time Markov chains is also provided; some of these functions depend on the suggested 'ctmcd' package. See Spedicato (2017) <doi:10.32614/RJ-2017-036>.
Authors:
markovchain_1.2.1.tar.gz
markovchain_1.2.1.zip(r-4.7-x86_64)markovchain_1.2.1.zip(r-4.7-arm64)markovchain_1.2.1.zip(r-4.6-x86_64)markovchain_1.2.1.zip(r-4.6-arm64)markovchain_1.2.1.zip(r-4.5-x86_64)
markovchain_1.2.1.tgz(r-4.6-x86_64)markovchain_1.2.1.tgz(r-4.6-arm64)markovchain_1.2.1.tgz(r-4.5-x86_64)markovchain_1.2.1.tgz(r-4.5-arm64)
markovchain_1.2.1.tar.gz(r-4.7-arm64)markovchain_1.2.1.tar.gz(r-4.7-x86_64)markovchain_1.2.1.tar.gz(r-4.6-arm64)markovchain_1.2.1.tar.gz(r-4.6-x86_64)
markovchain_1.2.1.tgz(r-4.6-emscripten)
manual.pdf |manual.html✨
DESCRIPTION |NEWS
card.svg |card.png
markovchain/json (API)
| # Install 'markovchain' in R: |
| install.packages('markovchain', repos = c('https://spedygiorgio.r-universe.dev', 'https://cloud.r-project.org')) |
Bug tracker:https://github.com/spedygiorgio/markovchain/issues
- blanden - Mobility between income quartiles
- craigsendi - CD4 cells counts on HIV Infects between zero and six month
- holson - Holson data set
- kullback - Example from Kullback and Kupperman Tests for Contingency Tables
- preproglucacon - Preprogluccacon DNA protein bases sequences
- rain - Alofi island daily rainfall
- sales - Sales Demand Sequences
- tm_abs - Single Year Corporate Credit Rating Transititions
ctmcdtmcmarkov-chainmarkov-modelr-programmingrcppquartoopenblascpp
Last updated from:42ce47425f. Checks:13 OK, 2 ERROR. Indexed: yes.
| Target | Result | Time | Files | Syslog |
|---|---|---|---|---|
| linux-devel-arm64 | OK | 309 | ||
| linux-devel-x86_64 | OK | 326 | ||
| source / vignettes | OK | 356 | ||
| linux-release-arm64 | OK | 297 | ||
| linux-release-x86_64 | OK | 296 | ||
| macos-release-arm64 | OK | 339 | ||
| macos-release-x86_64 | OK | 585 | ||
| macos-oldrel-arm64 | OK | 359 | ||
| macos-oldrel-x86_64 | OK | 659 | ||
| windows-devel-arm64 | ERROR | 454 | ||
| windows-devel-x86_64 | OK | 407 | ||
| windows-release-arm64 | ERROR | 495 | ||
| windows-release-x86_64 | OK | 627 | ||
| windows-oldrel-x86_64 | OK | 559 | ||
| wasm-release | OK | 199 |
Exports:.markovchainFitRcppabsorbingStatesabsorptionProbabilitiesaggregateStatesassessIndependenceassessOrderassessStationarityautoLumpbirthDeathbootstrapPropertiescanonicFormclosestReversiblecoercecommittorABcommunicatingClassescompareChainsconditionalDistributioncreateSequenceMatrixctmcFitdirichletChaindivergenceRateentropyRateexpectedRewardsexpectedRewardsBeforeHittingAExpectedTimefirstPassagefirstPassageMultiplefitFunctionfitHigherOrderfitHighOrderMultivarMCfitMTDfreq2GeneratorfromDictionaryfromFilefundamentalMatrixgamblersRuingeneratorToTransitionMatrixhigherOrderLogLikhigherOrderPredicthigherOrderSimulatehittingProbabilitieshommcidentityChainimpliedTimescalesimpreciseProbabilityatTinferHyperparamis.accessibleis.CTMCirreducibleis.irreducibleis.lumpableis.regularis.reversibleis.stochasticallyMonotoneis.TimeReversiblekemenyConstantlazyChainlumpmarkovchainFitmarkovchainListFitmarkovchainSequencemeanAbsorptionTimemeanFirstPassageTimemeanNumVisitsmeanRecurrenceTimemergeWithmixingTimemultinomialConfidenceIntervalsnamename<-noofVisitsDistnormalizedEntropyRateperiodplotplotSequencepopulationGeneticsModelpredictpredictHommcpredictiveDistributionprintpriorDistributionprobabilityatTrandomMarkovChainrctmcrecurrentClassesrecurrentStatesredistributerelaxationTimermarkovchainrouwenhorstselectOrdersensitivityseq2freqProbseq2matHighshowslemspectralGapstatessteadyStatessubchainsummaryttauchentauchenHusseytimeCorrelationstimeRelaxationstoBoundedChaintoDictionarytoDottoFiletoMermaidtoNthOrdertopologicalEntropytransientClassestransientStatestransition2GeneratortransitionProbabilityurnModelverifyEmpiricalToTheoreticalverifyHomogeneityverifyMarkovProperty
Dependencies:clicpp11expmglueigraphlatticelifecyclemagrittrMatrixpkgconfigRcppRcppArmadilloRcppParallelrlangvctrs
Last update: 2026-11-01
Started: 2018-12-31
Last update: 2026-11-01
Started: 2026-08-15
Last update: 2026-10-08
Started: 2026-08-15
Readme and manuals
Help Manual
| Help page | Topics |
|---|---|
| Easy Handling Discrete Time Markov Chains | markovchain-package markovchain |
| Absorption probabilities | absorptionProbabilities |
| Aggregate a Markov chain's state space by Kullback-Leibler minimization | aggregateStates aggregateStates,markovchain-method |
| Test independence of consecutive states of an empirical sequence | assessIndependence |
| Aggregate a Markov chain by spectral clustering | autoLump autoLump,markovchain-method |
| Plot a Markov chain with ggplot2 | autoplot.markovchain |
| Build a birth-death Markov chain | birthDeath |
| Mobility between income quartiles | blanden |
| Bootstrap confidence intervals for properties of an estimated chain | bootstrapProperties |
| Closest reversible approximation of a Markov chain | closestReversible closestReversible,markovchain-method |
| Committor probabilities | committorAB |
| Compare two Markov chains | compareChains |
| Conditional distribution of the next state | conditionalDistribution |
| CD4 cells counts on HIV Infects between zero and six month | craigsendi |
| Continuous time Markov chain class | ctmc-class dim,ctmc-method initialize,ctmc_method plot,ctmc,missing-method states,ctmc-method steadyStates,ctmc-method |
| Fit a continuous time Markov chain | ctmcFit |
| Markov chain from a Dirichlet process | dirichletChain |
| Kullback-Leibler divergence rate between two Markov chains | divergenceRate |
| Entropy rate of a Markov chain | entropyRate entropyRate,markovchain-method |
| Expected cumulative reward of a Markov chain | expectedRewards |
| Expected reward collected before hitting a set of states | expectedRewardsBeforeHittingA |
| Expected hitting time of a state in a continuous time Markov chain | ExpectedTime |
| First passage time distribution | firstPassage |
| First passage time distribution of a set of states | firstPassageMultiple |
| Markov chain approximating a continuous transition kernel by quadrature | fitFunction |
| Fit a higher order Markov chain | fitHigherOrder seq2freqProb seq2matHigh |
| Fit a higher order multivariate Markov chain | fitHighOrderMultivarMC |
| Fit a mixture transition distribution (MTD) model | fitMTD |
| Generator matrix estimated from a matrix of transition frequencies | freq2Generator |
| Fundamental matrix of an absorbing Markov chain | fundamentalMatrix |
| Build a gambler's ruin Markov chain | gamblersRuin |
| Transition matrix of the embedded jump chain | generatorToTransitionMatrix |
| Log-likelihood, deviance and information criteria of a higher order Markov chain | higherOrderLogLik |
| Higher order Markov Chains class | HigherOrderMarkovChain-class |
| Next-state probabilities and simulation for higher order Markov chains | higherOrderPredict higherOrderSimulate |
| Hitting probabilities of a Markov chain | hittingProbabilities |
| Holson data set | holson |
| Higher order multivariate Markov chain class | hommc hommc-class |
| An S4 class for representing Imprecise Continuous Time Markovchains | ictmc ictmc-class |
| Identity Markov chain | identityChain |
| Implied timescales of a Markov chain | impliedTimescales impliedTimescales,markovchain-method |
| Lower transition probability of an imprecise continuous time Markov chain | impreciseProbabilityatT |
| Hyperparameters for Bayesian estimation of a Markov chain | inferHyperparam |
| Check whether a state can be reached from another | is.accessible |
| Check whether a continuous time Markov chain is irreducible | is.CTMCirreducible |
| Check whether a Markov chain is irreducible | is.irreducible |
| Check exact lumpability of a Markov chain | is.lumpable is.lumpable,markovchain-method |
| Check if a DTMC is regular | is.regular |
| Check whether a Markov chain is reversible | is.reversible is.reversible,markovchain-method |
| Check whether a Markov chain is stochastically monotone | is.stochasticallyMonotone is.stochasticallyMonotone,ANY-method is.stochasticallyMonotone,markovchain-method is.stochasticallyMonotone,matrix-method |
| Check whether a continuous time Markov chain is time reversible | is.TimeReversible |
| Kemeny's constant of a Markov chain | kemenyConstant kemenyConstant,markovchain-method |
| Example from Kullback and Kupperman Tests for Contingency Tables | kullback |
| Build a lazy version of a Markov chain | lazyChain lazyChain,markovchain-method |
| Aggregate a Markov chain over a partition | lump lump,markovchain-method |
| Markov Chain class | !=,markovchain,markovchain-method *,markovchain,markovchain-method *,markovchain,matrix-method *,markovchain,numeric-method *,matrix,markovchain-method *,numeric,markovchain-method ==,markovchain,markovchain-method absorbingStates,markovchain-method absorptionProbabilities,markovchain-method canonicForm,markovchain-method coerce,data.frame,markovchain-method coerce,etm,markovchain-method coerce,markovchain,data.frame-method coerce,markovchain,igraph-method coerce,markovchain,matrix-method coerce,markovchain,sparseMatrix-method coerce,Matrix,markovchain-method coerce,matrix,markovchain-method coerce,msm,markovchain-method coerce,msm.est,markovchain-method coerce,sparseMatrix,markovchain-method coerce,table,markovchain-method communicatingClasses,markovchain-method conditionalDistribution,markovchain-method dim,markovchain-method hittingProbabilities,markovchain-method initialize,markovchain-method is.accessible,markovchain,character,character-method is.accessible,markovchain,missing,missing-method is.irreducible,markovchain-method is.regular,markovchain-method markovchain-class meanAbsorptionTime,markovchain-method meanFirstPassageTime,markovchain,character-method meanFirstPassageTime,markovchain,missing-method meanNumVisits,markovchain-method meanRecurrenceTime,markovchain-method names<-,markovchain-method plot,markovchain,missing-method predict,markovchain-method print,markovchain-method recurrentClasses,markovchain-method recurrentStates,markovchain-method show,markovchain-method sort,markovchain-method steadyStates,markovchain-method summary,markovchain-method t,markovchain-method transientClasses,markovchain-method transientStates,markovchain-method [,markovchain,ANY,ANY,ANY-method ^,markovchain,numeric-method |
| Session cache of eigenvalues | markovchainCache |
| Fit a discrete time Markov chain | .markovchainFitRcpp createSequenceMatrix markovchainFit |
| Non-homogeneous discrete time Markov chain class | dim,markovchainList-method markovchainList-class predict,markovchainList-method print,markovchainList-method show,markovchainList-method [[,markovchainList-method |
| Fit a non-homogeneous Markov chain | markovchainListFit |
| Simulate a trajectory of a Markov chain | markovchainSequence |
| Mean absorption time | meanAbsorptionTime |
| Mean first passage times of an irreducible Markov chain | meanFirstPassageTime |
| Mean number of visits to each state | meanNumVisits |
| Mean recurrence time | meanRecurrenceTime |
| Merge two Markov chains by convex combination of their transition matrices | mergeWith mergeWith,markovchain,markovchain-method |
| Mixing time of a Markov chain | mixingTime mixingTime,markovchain-method |
| Simultaneous confidence intervals for transition probabilities | multinomialConfidenceIntervals |
| Name of a Markov chain | name name,markovchain-method |
| Set the name of a Markov chain | name<- name<-,markovchain-method |
| Returns the states for a Markov chain object | names,markovchain-method |
| Expected fraction of the first N steps spent in each state | noofVisitsDist |
| Normalized entropy rate of a Markov chain | normalizedEntropyRate normalizedEntropyRate,markovchain-method |
| Returns an Identity matrix | ones |
| Structural analysis of a Markov chain | absorbingStates canonicForm communicatingClasses period recurrentClasses recurrentStates transientClasses transientStates |
| Plot state sequences of a Markov chain | plotSequence |
| Build a population-genetics Markov chain (Moran or Wright-Fisher) | populationGeneticsModel |
| Simulate from a higher order multivariate Markov chain | predictHommc |
| Bayesian predictive probability of new data | predictiveDistribution |
| Preprogluccacon DNA protein bases sequences | preproglucacon |
| Prior density of a transition matrix | priorDistribution |
| Transition probabilities of a continuous time Markov chain at time t | probabilityatT |
| Alofi island daily rainfall | rain |
| Random Markov chain | randomMarkovChain |
| Simulate a continuous time Markov chain | rctmc |
| Evolution of a distribution over time | redistribute redistribute,markovchain-method |
| Relaxation time of a Markov chain | relaxationTime relaxationTime,markovchain-method |
| Simulate from a homogeneous or non-homogeneous Markov chain | rmarkovchain |
| Discretize an AR(1) process into a Markov chain (Rouwenhorst's method) | rouwenhorst |
| Sales Demand Sequences | sales |
| Select the order of a Markov chain by information criteria | selectOrder |
| Sensitivity of the stationary distribution to a state's transition row | sensitivity sensitivity,markovchain-method |
| Function to display the details of hommc object | show,hommc-method |
| Second largest eigenvalue modulus (SLEM) of a Markov chain | slem slem,markovchain-method |
| Spectral gap of a Markov chain | spectralGap spectralGap,markovchain-method |
| States of a Markov chain | states states,markovchain-method |
| Statistical tests for Markov chains | assessOrder assessStationarity statisticalTests verifyEmpiricalToTheoretical verifyHomogeneity verifyMarkovProperty |
| Stationary distributions of a Markov chain | steadyStates |
| Restrict a Markov chain to a subset of states | subchain subchain,markovchain-method |
| Discretize an AR(1) process into a Markov chain (Tauchen's method) | tauchen |
| Discretize an AR(1) process into a Markov chain (Tauchen-Hussey method) | tauchenHussey |
| Time correlations and time relaxations of observed sequences | timeCorrelations timeCorrelations,markovchain-method timeRelaxations timeRelaxations,markovchain-method |
| Single Year Corporate Credit Rating Transititions | tm_abs |
| Apply a boundary condition to a Markov chain's first and last state | toBoundedChain toBoundedChain,markovchain-method |
| Represent a Markov chain as a plain R list | fromDictionary toDictionary toDictionary,markovchain-method |
| Export the transition graph as Graphviz DOT or Mermaid text | toDot toDot,markovchain-method toMermaid toMermaid,markovchain-method |
| Write or read a Markov chain to or from a file | fromFile toFile toFile,markovchain-method |
| Return the n-step transition chain | toNthOrder |
| Topological entropy of a Markov chain | topologicalEntropy topologicalEntropy,markovchain-method |
| Generator matrix from a transition matrix | transition2Generator |
| Transition probability between two states | transitionProbability transitionProbability,markovchain-method |
| Build an Ehrenfest urn model Markov chain | urnModel |
| Matrix to create zeros | zeros |
