From the course: Time Series Modeling in Excel, R, and Power BI

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Solution: Determining overall trends

Solution: Determining overall trends

(upbeat music) - [Instructor] Let's start by plotting the San Diego hourly electricity demand in a line chart again. We see what the trends are for the San Diego electricity demand and the line chart, but now let's use linear regression to determine the best fit line that goes through these points. Let's calculate its slope and intercept with a variable m_sandiego, where we'll use the linear model lm function on the data observations from the San Diego xts object compared to the index from the same time series. Let's then view the regression coefficients to get an idea of what the line will look like. We see it has a negative slope, but it's kind of difficult to gauge the impact of the slope on hourly data with so many observations, so let's add it as a line on our hourly plot data. First, let's use it to create a time series object with the predicted fitted values and the date index. While we see we get a time zone…

Contents