Coding Time Variable (2020)

Coding Time Variable by Taking Origin at the Beginning

Suppose we have time-series data for the years 1990, 1991, 1992, and 1994.

We can take the origin of a time series at the beginning and assign $x = 0$ to the first period and $1, 2, 3, …$ to other periods. The code for the year will be

Coding Time Variable

Coding Time Variable by Taking Middle Years as Zero

To simplify the trend calculations, the time variable $t$ (year variable) is coded by taking deviations $t-\overline{t}$, where $\overline{t}$ is the average number computed as $\overline{t}=\frac{First\, Period + Last\, Period}{2}$. Taking $x=t-\overline{t}$ we get
$$\sum x = 0 = \sum x^3 = \sum x^5 = \cdots$$

There are two cases when coding a Time Variable (when taking zero in the Middle):

  • When there are an odd number of Years:
    For an odd number of years (as in the period 1990 to 1994) the $\overline{t}$ is the middle point. The $\overline{t}$ is $\overline{t} = (1990+1994)/2=1992$ the code for the year $t$ is $x=t-\overline{t}$. For t=1990, we have $x=1990-1992 =0$. Thus the coded year is zero at $\overline{t}$. Now after taking x=0 at the middle of an odd number of years, we assign $-1, -2, …$ for the years before the middle of the year and $1,2,…$ for the years after the middle year.
    Year (t) $x=t-\overline{t}$
    1990 -2
    1991 -1
    1992 0
    1993 1
    1994 2
  • When there are even numbers of years
    Suppose we have time-series data for the years 1990, 1991, 1992, 1993, 1994, and 1995. The value of middle point is $\overline{t} = (1990+1995)/2 = 1992.5$. So $x=0$ halfway between the years 1992 and 1993 (in the middle of 1992 and 1993). For $t=1992$, we have $x=t-\overline{t}=1992-1992.5=-0.5$. Thus coding the middle of an even number of years as $x=0$, we assign $-0.5, -1.5, -2.5, …$ for the years before the middle year and $0.5, 1.5, 2.5, …$ for the years after the middle year as shown below
Year(t)$x=t-\overline{t}$$x=\frac{t-\overline{t}}{1/2}$
1990-2.5-5
1991-1.5-3
1992-0.51
19930.51
19941.53
19952.55
https://itfeature.com

To avoid decimals in the coded year, we can take the unit of measurement as $\frac{1}{2}$ year. Therefore, after coding $x=0$ in the middle of an even number of years, we assign $-1,-3, -5,…$ for the year before the middle year and $1,3,5,…$ for the years after the middle year as shown above.

Read more about Coding Time Variables in R

R Programming Language

Computer MCQs

Multiplicative Models and Additive Models (2020)

Here we will discuss the multiplicative models and Additive Models.

The analysis of a time series is the decomposition of a time series into its different components for their separate study. The process of analyzing a time series is to isolate and measure its various components. We try to answer the following questions when we analyze a time series.

  1. What would have been the value of the variable at different points in time if it were influenced only by long-time movements?
  2. What changes occur in the value of the variable due to seasonal variations?
  3. To what extent and in what direction has the variable been affected by cyclical fluctuations?
  4. What has been the effect of irregular variations?

The study of a time series is mainly required for estimation and forecasting. An ideal forecast should be based on forecasts of the various types of fluctuations. Separate forecasts should be made of the trend, seasonal, and cyclical variations. These forecasts become doubtful for a forecast of irregular movements. Therefore, it is necessary to separate and measure various types of fluctuations present in a time series.

A value of a time series variable is considered as the result of the combined impact of its components. The components of a time series follow either the multiplicative or the additive model.

Fro both Multiplicative and additive models, let $Y$= original observation, $T$= trend component, $S$=seasonal component, $C$=cyclical component, and $I$=irregular component.

Multiplicative Models

It is assumed that the value $Y$ of a composite series is the product of the four components. That is

$$Y = T \times S \times C \times I,$$

where $T$ is given in original units of $Y$, but $S$, $C$, and $I$ are expressed as percentage unit-less index numbers.

Additive Models

It is assumed that the value of $Y$ of a composite series is the sum of the four components. That is

$$Y = T + S + C + I,$$

where $T$, $S$, $C$, and $I$ all are given in the original units of $Y$.

Time series analysis is the analysis of a series of data points over time, allowing one to answer a question such as what is the causal effect on a variable $Y$ of a change in variable $X$ over time? An important difference between time series and cross-section data is that the ordering of cases does matter in time series.

Multiplicative Models and Additive Model
Component of Time Series Data

Rather than dealing with individuals as units, the unit of interest is time: the value of $Y$ at time $t$ is $Y_t$. The unit of time can be anything from days to election years. The value of $Y_t$ in the previous period is called the first lag value: $Y_{t-1}$. The jth lag is denoted: $Y_{t-j}$. Similarly, $Y_{t+1}$ is the value of $Y_t$ in the next period. So a simple bivariate regression equation for time series data looks like: \[Y_t = \beta_0 + \beta X_t + u_t\]

$Y_t$ is treated as a random variable. If $Y_t$ is generated by some model (Regression model for time series i.e. $Y_t=x_t\beta +\varepsilon_t$, $E(\varepsilon_t|x_t)=0$, then ordinary least square (OLS) provides a consistent estimates of $\beta$.

See the YouTube video about Multiplicative and Additive Models.

Selection between Multiplicative and Additive Models

A question arose about how to Choose Between Multiplicative and Additive Models. The additive model is useful when the seasonal variation is relatively constant over time. When the seasonal variation increases over time, the multiplicative model is useful.

Read about Introduction to Time Series Data

Learn more about Multiplicative and Additive Models

Frequently Asked Questions about R Programming Language and R Data Analysis

Online Multiple Choice Questions Quizzes Website for Various Subjects with Answers

Components of Time Series

Traditional methods of time series analysis are concerned with decomposing a series into a trend, a seasonal variation, and other irregular fluctuations. Although this approach is not always the best but still useful (Kendall and Stuart, 1996).

Components of Time Series

The components, by which a time series is composed, are called the components of time series data. A time series is not necessarily composed of all these four components of Time Series Data. The components of time series are (i) Seasonal Effect, (ii) Cyclic Variation, (iii) Secular Trend, and (iv) Irregular Variation. The four basic components of time series are described below.

Different Sources of Variation are:

Seasonal effect (Seasonal Variation or Seasonal Fluctuations)

Many of the time series data exhibit a seasonal variation which is the annual period, e.g., sales and temperature readings. Seasonal variations are easy to understand and can be easily measured or removed from the data to give deseasonalized data. Seasonal Fluctuations describe any regular variation with a period of less than one year. For example, the cost of various types of fruits and vegetables, clothes, unemployment figures, average daily rainfall, increase in the sale of tea in winter, increase in the sale of ice cream in summer, etc., all show seasonal variations.

The changes which repeat themselves within a fixed period, are also called seasonal variations. For example, traffic on roads in the morning and evening hours, Sales at festivals like EID, etc., an increase in the number of passengers at the weekend, etc. Climate, social customs, religious activities, etc cause seasonal variations. The main causes of seasonal variations are seasons, religious festivals, and social customs.

Other Cyclic Changes (Cyclical Variation or Cyclic Fluctuations)

Time series exhibits Cyclical Variations at a fixed period due to some other physical cause, such as daily variation in temperature. Cyclical variation is a non-seasonal component that varies in a recognizable cycle. These variations are considered a more dangerous effect on business and economic activity. Sometimes series exhibits oscillation which does not have a fixed period but is somewhat predictable. For example, economic data is affected by business cycles with a period varying between about 5 and 7 years.

The cyclical component may describe any regular variation (fluctuations) in time series data in weekly or monthly data. The cyclical variation is periodic and repeats itself like a business cycle, which has four phases (i) Peak/Prosperity (ii) Recession (iii) Trough/Depression (iv) Expansion.

Trend (Secular Trend or Long Term Variation)

It is a longer-term change. Here we take into account the number of observations available and make a subjective assessment of what is long-term. It represents a relatively smooth, steady, and gradual movement of a time series in the same direction. To understand the meaning of the long term, consider the climate variables. These variables sometimes exhibit cyclic variation over a very long time period such as 50 years.

If one just had 20 years of data, this long-term oscillation would appear to be a trend, but if several hundreds of years of data are available, then long-term oscillations would be visible. These movements are systematic where the movements are broad, steady, showing a slow rise or fall in the same direction. The trend may be linear or non-linear (curvilinear). Some examples of secular trends are:

  • Increase in prices,
  • Increase in pollution,
  • an increase in the need for wheat,
  • an increase in literacy rate,
  • decrease in deaths due to advances in science.

Taking averages over a certain period is a simple way of detecting a trend in seasonal data. Change in averages with time is evidence of a trend in the given series. There are more formal tests for detecting a trend in time series.

Other Irregular Variation (Irregular Fluctuations)

When trend and cyclical variations are removed from a set of time series data, the residual is left, which may or may not be random. Various techniques for analyzing series of this type examine to see “if irregular variation may be explained in terms of probability models such as moving average or autoregressive models, i.e. we can see if any cyclical variation is still left in the residuals. These variations occur due to sudden causes are called residual variations (also called accidental or erratic fluctuations) and are unpredictable. For example, a rise in prices of steel due to strikes in the factory, accidents due to failure of the break, flood, earth quick, and war, etc.

The figure below further explains the components of time series data.

Components of Time Series Data

Computer MCQs Online Test

R and Data Analysis

Historigram (2020)

Here we will discuss the graphical representation of time series data, called historigram.

As we have discussed in the introduction to Time Series, given an observed time series, the first step in analyzing a time series is to plot the given series on a graph taking time intervals ($t$) along X-axis (as an independent variable) and the observed value ($Y_t$) on Y-axis (as the dependent variable: as a function of time). Such a graph will show various types of fluctuations and other points of interest.

A historigram is a graphical representation of a time series that reveals the changes that occurred at different time periods. The first step in the prediction (or forecast) of a time series involves an examination of the set of past observations. In this case, the historigram may be a useful tool. The construction of this involves the following steps described below:

  • Use an appropriate scale and take time $t$ along the $x$-axis as an independent variable.
  • Use an appropriate scale, and plot the observed values of variable $Y$ as a dependent variable against the given points of time.
  • Join the plotted points by line segments to get the required graphical representation.

Historigram Example

Draw a graphical representation of the data to show the population of Pakistan in various census years.

Census Year195119611972198119982017
Population (Million)33.4442.8865.3183.78130.58200.17
Historigram

R Programming Language

MCQs General Knowledge

https://itfeature.com statistics help