rf#r.netfslab

'Invalid term in model formula' when calling R.armaFit


I'm getting this message:

Error in terms.formula(formula, data = data) :

invalid term in model formula

When calling this code:

let data : float[] = // ...
R.eval(R.parse(text="library(fArma)")) |> ignore

let dataset =
    namedParams["XX", box data]
    |> R.data_frame

let fitted = R.armaFit(formula="XX ~ arma(1 , 1)", data=dataset)

The error is triggered by the last line.

I've tried removing the box, the XX ~, but I get the same result.

I was trying to follow this guide: https://www.r-bloggers.com/arma-models-for-trading/

The log reports this:

[03/02/17 18:01:46] [Pid:10004, Tid:1, Apid:1] eval(base::data.frame(XX=fsr_10004_3)) [03/02/17 18:01:46] [Pid:10004, Tid:1, Apid:1] Output: [03/02/17 18:01:50] [Pid:10004, Tid:1, Apid:1] eval(fArma::armaFit(formula=fsr_10004_4, data=fsr_10004_5)) [03/02/17 18:01:50] [Pid:10004, Tid:1, Apid:1] Output: Error in terms.formula(formula, data = data) : invalid term in model formula

[03/02/17 18:01:50] [Pid:10004, Tid:1, Apid:1] Operation failed:
RDotNet.EvaluationException: Error in terms.formula(formula, data = data) : invalid term in model formula


Solution

  • let armaFit = R.armaFit(R.as_formula("xx ~ arma(1,1)"), dataset)