Reputation: 21
I'm trying to call the R function garchFit from Julia using Rcall. When I do things directly in R, all is well: the following works
library("fGarch")
library("rugarch")
spxData <- read.csv(file = 'SPXlogreturns.csv')
y = spxData$y
fit.arch <- garchFit(~garch(1,0),data=y,trace=F,include.mean=FALSE)
But when I have the same vector of log returns in Julia and try to do the same thing using RCall:
using RCall
@rput y
R"""
library("fGarch")
library("rugarch")
fit.arch <- garchFit(~garch(1,0),data=y,trace=F,include.mean=FALSE)
"""
I get the error Multivariate data inputs require lhs for the formula. Yet when I @rget y back from R, it's a vector, so I don't understand what garchFit wants. Any help much appreciated.
Upvotes: 1
Views: 168
Reputation: 21
In case anyone googles it and has a similar problem, the answer is that you need to unlist. For no (at least to me) readily obvious reason, @rput creates a list in R, not a vector. So the answer is
using RCall
@rput y
R"""
library("fGarch")
library("rugarch")
yy <- unlist(y)
fit.arch <- garchFit(~garch(1,0),data=yy,trace=F,include.mean=FALSE)
"""
Upvotes: 1