所以我试图将隐藏的马尔可夫模型拟合到这个虚构的数据中,但我很想知道为什么在包含第一个数据点时我得到NaN而不是在我排除它时?这是我正在运行的代码:
library(RHmm)
y = c(100,rnorm(10000))
plot(y,type='l')
fit1 = HMMFit(y[-1],nStates=2)
fit2 = HMMFit(y,nStates=2)
这是输出:
> fit1
Call:
----
HMMFit(obs = y[-1], nStates = 2)
Model:
------
2 states HMM with univariate gaussian distribution
Baum-Welch algorithm status:
----------------------------
Number of iterations : 47
Last relative variation of LLH function: 0.000001
Estimation:
-----------
Initial probabilities:
Pi 1 Pi 2
7.143032e-11 1
Transition matrix:
State 1 State 2
State 1 0.6508174 0.3491826
State 2 0.8722256 0.1277744
Conditionnal distribution parameters:
Distribution parameters:
mean var
State 1 -0.1003040 0.9404932
State 2 0.2457188 1.0636770
Log-likelihood: -14189.94
BIC criterium: 28444.35
AIC criterium: 28393.88
> fit2
Call:
----
HMMFit(obs = y, nStates = 2)
Model:
------
2 states HMM with univariate gaussian distribution
Baum-Welch algorithm status:
----------------------------
NO CONVERGENCE AFTER 1 ITERATIONS
PROBLEM IN BAUM-WELCH'S ALGORITHM
Last Estimation:
----------------
Initial probabilities:
Pi 1 Pi 2
NaN NaN
Transition matrix:
State 1 State 2
State 1 NaN NaN
State 2 NaN NaN
Conditionnal distribution parameters:
Distribution parameters:
mean var
State 1 NaN NaN
State 2 NaN NaN
Log-likelihood: NaN
BIC criterium: NaN
AIC criterium: NaN