Running examples in ‘NHMSAR-Ex.R’ failed
The error most likely occurred in:

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: regimes.plot.MSAR
> ### Title: Plot MSAR time series with regimes
> ### Aliases: regimes.plot.MSAR
> ### Keywords: plot MSAR latent regimes
> 
> ### ** Examples
> 
> data(lynx)
> T = length(lynx)
> data = array(log(lynx),c(T,1,1))
> theta.init = init.theta.MSAR(data,M=2,order=2,label="HH")
> mod.lynx = fit.MSAR(data,theta.init)
> regimes.plot.MSAR(mod.lynx,data,ylab="Captures number")
  [1] NA NA  1  1  1  1  1  1  1  1  1  1  2  2  2  2  2  2  2  2  2  2  2  2  2
 [26]  2  1  1  1  1  1  2  2  2  2  2  1  1  1  1  2  2  2  2  2  2  2  2  2  2
 [51]  2  2  2  2  2  2  2  2  2  2  2  2  2  2  2  2  2  1  2  2  2  2  2  2  2
 [76]  2  2  2  2  2  2  2  1  1  1  2  2  2  2  2  2  2  1  1  1  1  1  1  1  2
[101]  2  2  2  2  2  2  1  1  2  2  2  2  1  1  1  1
> 
> theta.init = init.theta.MSAR(data,M=2,order=2,label="NH",nh.transitions="logistic")
> attributes(theta.init)
$NbComp
[1] 1

$NbRegimes
[1] 2

$order
[1] 2

$label
[1] "NH"

$nh.transitions
function (covar, par.trans, transmat) 
{
    eps = 1e-10
    T <- dim(covar)[1]
    nc <- dim(covar)[3]
    covar = matrix(covar, T, nc)
    M = dim(transmat)[1]
    f <- array(0, c(M, M, T))
    for (m in 1:M) {
        f[m, m, ] = eps + (1 - 2 * eps)/(1 + exp(par.trans[m, 
            1] + par.trans[m, 2:(nc + 1)] %*% t(covar)))
    }
    f[1, 2, ] = 1 - f[1, 1, ]
    f[2, 1, ] = 1 - f[2, 2, ]
    return(f)
}
<bytecode: 0x56550bbb1fa0>
<environment: 0x565509f37660>

$n_par
[1] 12

$emis.linear
[1] FALSE

$names
[1] "A"         "A0"        "sigma"     "prior"     "transmat"  "par.trans"

$class
[1] "MSAR"

> theta.init$A0 = mod.lynx$theta$A0
> theta.init$A = mod.lynx$theta$A
> theta.init$sigma = mod.lynx$theta$sigma
> theta.init$prior = mod.lynx$theta$prior
> theta.init$transmat = mod.lynx$theta$transmat
> theta.init$par.trans = matrix(c(1,-1,-.2,.2),2,2)
> Y = array(data[2:T,,],c(T-1,1,1))
> Z = array(data[2:T,,],c(T-1,1,1))
> mod.lynx = fit.MSAR(Y,theta.init,verbose=TRUE,MaxIter=20,covar.trans=Z)
[1] iteration         1                   loglik =        -81.7078576817072
Error in w[, 1] : incorrect number of dimensions
Calls: fit.MSAR -> Mstep.nh.MSAR -> ucminf -> fn
Execution halted