0

As you can see there is no $ in my lines. However when I try to run the last line it gives me the error of $ blabla atomic. In the beginning I had some $ in there but then I changed everything to the [] format. It still gives me the error. Any idea why?

Attached the code that I used.

library(rugarch)
library(xts)
#uploading and preparing the data
data_sentivola<-read.csv("Some Path")

data_sentivola_INT <- data_sentivola[data_sentivola[,"ticker"] == "INTC",]
xts_sentivola_INTC <- xts(data_sentivola_INT[,c("return","rv")], order.by=as.Date(data_sentivola_INT[,"Date"]))


#Specifying the realGARCH model
spec <- ugarchspec(mean.model = list(armaOrder = c(0, 0), include.mean = FALSE), variance.model = list(model = 'realGARCH', garchOrder = c(1, 1)))  
fit<- ugarchfit(spec, xts_sentivola_INTC[,"return"]*100, solver = "hybrid", realizedVol = xts_sentivola_INTC[,"rv"]*100)

The error message then looks like that

Error: $ operator is invalid for atomic vectors
Gregor Thomas
  • 136,190
  • 20
  • 167
  • 294
  • 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 and desired output that can be used to test and verify possible solutions. Without data we can't run and test the code. After you get the error run `traceback()` to see where it's coming from. It's likely that one of the functions you are using has the `$` code inside. – MrFlick Oct 30 '19 at 16:13
  • The error is from internal code of one of the functions you are using. My guess is that you pass to a function expecting a data.frame or list some different (wrong) data structure. – Roland Oct 30 '19 at 17:12
  • Yes, you were right. I did not do a correct xts transformation and because of that it threw the error. Thanks for bringing me on the correct path. – DripRat Nov 01 '19 at 16:23

1 Answers1

0

Just a hunch : this looks like you are using vec[,my_var] (equivalent to vec$my_var) on a vector (where the syntax is somethin along vec[3]) and not a data.frame .

cbo
  • 1,664
  • 1
  • 12
  • 27