Q: I’ve had trouble setting up CARMA objects with real data. After defining a carma model carma.model, I call setYuima(data=setData(mydata), model=carma.model), and get the error message “Error in if (dim([email protected])[2] == 1){ : is of length zero”

A: It is important that you convert your data in an object of class matrix where the number of rows is the number of observations. 

 library(yuima)
mydata0 <- matrix(rnorm(100))
mydata <-setData(mydata0,delta = 1/100)

# Delta must be small in order to ensure the asymptotic properties of qmle
mymod <- setCarma(2,1)
myyuima <- setYuima(data = mydata,model = mymod)

# If you work with time series you can also use the ts object
mydata1 <- setData(ts(mydata0,frequency = 100,start=0))
mymod <- setCarma(2,1)
myyuima1 <- setYuima(data = mydata1,model = mymod)

# or zoo
mydata2 <- setData(zoo(mydata0,order.by = seq(0,1,length.out = 100)))
plot(mydata2)
mymod <- setCarma(2,1)
myyuima2 <- setYuima(data = mydata2,model = mymod)