0

I have price data for an asset. I want to fit a Markow Switching model (with 2 states). The code I have run is below. Price is configured as numeric and date as a date. Not sure where I'm going wrong.

library(MSwM)
# Loading required package: parallel
library(ggplot2)
nstates <- 6
olsPrice <- lm(PriceUSD~date, Priced)
msmPrice <- msmFit(olsPrice, k = nstates, sw = c(FALSE, TRUE, TRUE))

The error message I get is:

Error in w * matrix(resid(modaux), ncol = k, byrow = T)^2 : 
  non-conformable arrays
MrFlick
  • 195,160
  • 17
  • 277
  • 295
JHolmes
  • 23
  • 6
  • 2
    It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input that can be used to test and verify possible solutions. What exactly is in `Priced`? – MrFlick Jan 23 '20 at 19:40
  • It's the name of my dataset. It's just daily price data for an asset on daily frequency. The PriceUSD is the price of the asset in USD and date is the date. No other variables. – JHolmes Jan 23 '20 at 19:43

0 Answers0