Creating a linear model from a Time Series

I am trying to model the overall trend of the data set globtemp from the astsa R package with a polynomial: however, I am having problems creating the liner model.

Loading required package: zoo

Attaching package: 'zoo'
The following objects are masked from 'package:base':

as.Date, as.Date.numeric
plot(time~temperature, ylab="Temperature", main="Global Temperature Model")
Error in eval(predvars, data, env): object 'temperature' not found

Created on 2021-10-27 by the reprex package (v2.0.1)

The xts data should work with the plot function. Try this.


plot(globtemp, ylab = "Temperature", main = 'Global Temperature Model')

That gives me the original plot. I am trying to remove the trend; therefore, I need to create a linear model of the data. So, it needs to be written in the form of x~y.

Does this need to be answered, or should it be closed.

First, you need to build a model using the lm() function or fable package.

For lm() you need to create a column to capture the trend.

In fable just run y~trend in TSLM() function in the model function...

model(model1 = y ~ trend()). The residuals will be de trended series.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.