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

> ### Name: simule.nh.MSAR
> ### Title: Simulation of (non) homogeneous Markov Stiwtching autoregressive
> ###   models
> ### Aliases: simule.nh.MSAR
> ### Keywords: Simulation MSAR
> 
> ### ** Examples
> 
> data(meteo.data)
> data = array(meteo.data$temperature,c(31,41,1)) 
> k = 40
> plot(data[,k,1],typ="l",xlab=("time (days)"),ylab=("temperature (Celsius degrees)"))
> T = dim(data)[1]
> N.samples = dim(data)[2]
> d = dim(data)[3]
> # Fit Homogeneous MS-AR models
> M = 2
> order = 2
> theta.init = init.theta.MSAR(data,M=M,order=order,label="HH") 
> mod.hh = fit.MSAR(data,theta.init,verbose=TRUE,MaxIter=20)
[1] iteration         1                   loglik =        -2483.91564376157
[1] iteration         2                   loglik =        -2481.57074049901
[1] iteration         3                   loglik =        -2480.93070385664
[1] iteration         4                   loglik =        -2479.89893610667
[1] iteration         5                   loglik =        -2478.49121909125
[1] iteration         6                   loglik =        -2476.81587236579
[1] iteration         7                   loglik =        -2474.99898589161
[1] iteration         8                   loglik =        -2473.14213246927
[1] iteration         9                   loglik =        -2471.31354280926
[1] iteration         10                  loglik =        -2469.55274782894
[1] iteration         11                  loglik =        -2467.86465336614
[1] iteration         12                  loglik =        -2466.19784908813
[1] iteration         13                  loglik =        -2464.48967134409
[1] iteration         14                  loglik =        -2462.84590920213
[1] iteration        15                 loglik =       -2461.4734601506
[1] iteration         16                  loglik =        -2460.40571298584
[1] iteration         17                  loglik =        -2459.56285205389
[1] iteration         18                  loglik =        -2458.86623279608
[1] iteration         19                  loglik =        -2458.26208389195
[1] iteration         20                  loglik =        -2457.71579116053
> # Simulation
> yT = 31
> Bsim = 1
> Ksim = Bsim*N.samples
> Y0 = array(data[1:2,sample(1:dim(data)[2],Ksim,replace=T),],c(2,Ksim,1))
> Y.sim = simule.nh.MSAR(mod.hh$theta,Y0 = Y0,T,N.samples = Ksim) 
Error in sqrt(sigma) : non-numeric argument to mathematical function
Calls: simule.nh.MSAR
Execution halted