R: error: dimnames applied to non-array
<p>I am trying to implement the process below with my own data. The data is in a spreadsheet with headers, and the first column has dates, the other columns have returns. </p>

<p><a href="https://inovancetech.com/hmm-tutorial-1.html" rel="nofollow">https://inovancetech.com/hmm-tutorial-1.html</a></p>

<p>My variation on the code:</p>

<pre><code>Returns &lt;- read.csv("MyData.csv",header=TRUE,stringsAsFactor=F)
Date&lt;-as.character(Returns[,1])
DateTS&lt;- as.POSIXlt(Date, format = "%m/%d/%Y")
TSData&lt;-data.frame(Returns[,2:6],row.names=DateTS)
TSData&lt;-as.xts(TSData) 
MyReturns &lt;- TSData[-1,1]
ModelData&lt;-data.frame(MyReturns) 
set.seed(1)
HMM&lt;-depmix(MyReturns~1,data=ModelData,nstates=2,family=gaussian())
</code></pre>

<p>This is where I get an error:
Error in dimnames(cd) &lt;- list(as.character(index(x)), colnames(x)) : 
  'dimnames' applied to non-array</p>

<p>I can't figure out why. Any hints? </p>