I would like to fit a custom process - a time inhomogeneous 2-state Markov chain, to data. The time inhomogeneity is a result of the transition probabilities varying sinusoidally through time with a periodicity of 1 year. The complete model is shown below:
SelectProb[aVPast_, TrM_] := Module[{tempProb}, tempProb = Switch[aVPast, {1, 0}, TrM[[1, 1]], {0, 1}, TrM[[2, 2]]]];
NextStep[aVPast_, TrM_] := Module[{aRand, aProb}, aProb = SelectProb[aVPast, TrM];
aRand = RandomReal[]; If[aRand >= aProb, {1, 1} - aVPast, aVPast]];
TransitionSineMatrix[t_, pdw_, pwd_] := {{1 - pdw (0.5 + 0.5 Sin[2 [Pi] t/365]), pdw (0.5 + 0.5 Sin[2 [Pi] t/365])}, {pwd (0.5 + 0.5 Sin[2 [Pi] t/365]), 1 - pwd (0.5 + 0.5 Sin[2 [Pi] t/365])}}
DiscreteMarkovProcessTimeInHomogeneous[aInitialState_, tMax_] := FoldList[NextStep, aInitialState,
Array[TransitionSineMatrix[#, pdw, pwd] &, tMax]]
I have tried using FindFit to fit the probabilities $pdw$ and $pwd$, but I seem to run into an issue that there is no explicit time variable in my model.
Does anyone know how I might be able to fit these parameters in Mathematica?
Best,
Ben
NMinimize[]
directly $\endgroup$