'How to use GLS in Python's statsmodel and specify a certain correlation structure: (CorARMA in R)

Summary I am trying to use 'statsmodels' in Python to fit a GLS model, while specifying a certain autocorrelation structure. In particular I am trying to recreate the following command from R:

   model_p10 <- gls(flow ~ time + level + trend,   data=data,  
   correlation=corARMA(p=10,form=~time),   method="ML")

Details I am trying to follow a (free) course on time series intervention analysis, taught using R, but instead using Python. I can see that GLS in Statsmodels does accept other parameters. I am not sure what the Python equivalent of corARMA(p=,q=) would be or if I can feed that in to the statsmodels GLS function to recreate the code snippet above.

Ideally I would like to be able to do something like the following in Python:

GLS(y,X, corARMA(p=,q=)).fit()

I have tried playing around with ARIMA in statsmodels, but I am not a statistician and am not sure what I am doing. For my final result I want the plot to be a straight line, and take into account auto regressive and/or moving average term.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source