Thursday, October 29, 2015

The Gaussian White Noise

At first let’s define the white noise. The expectation or mean of white noise is zero with some finite variance and ${{i}^{th}}$ and ${{j}^{th}}$observations are uncorrelated for $i\ne j$. Hence for white noise it needs to have following properties.

$E({{e}_{t}})=0\to (i)$

$E(e_{t}^{2})={{\sigma }^{2}}\to (ii)$

$E({{e}_{t}},{{e}_{j}})=0$ for $i\ne j\to (iii)$

If this white noise follows a normal distribution then its known as normal or Gaussain white noise which is written as $et\tilde{\ }N(0,{{\sigma }^{2}})$ or also termed as normally distributed random variable.

Further $(iii)$ can be replaced with stronger assumption of independentness which is then known as Independent white noise and if it follows normal distribution then its known as Gaussian independent white noise or normally distributed independent random variable. There is one note: Independentness means uncorrelatedness but not vice versa.

Let’s develop normally distributed 200 random variables with zero mean and a unit variance. But to make your result consistent with mine we need to use random seed, lets use seed as 1. If you don’t know about random seed then see my previous blog (here).

rm(list = ls())
set.seed(1)
n = 200 #For 200 random numbers
e = rnorm(n, mean = 0, sd = 1)  # Creating 200 random numbers which is normally distributed with zero mean and unit variance.
plot(e, type = “l”, main = “200 normally distributed random numbers with zero mean and unit variance”)
hist(e, main = “histogram of Gaussain white noise with zero mean and unit variance”)

Here is histogram:

shapiro.test(e)  #Testing if e is normal or not
library(tseries)
jarque.bera.test(e) # Jarque Bera Test for normaliyt

t.test(e, mu = 0) #Testing if mean of e is zero or not

acf(e, main="ACF of residuals")

library(forecast)
Box.test(e, lag=10, type = "Box-Pierce")
Box.test(e,lag=10, fitdf=0, type="Ljung-Box")

#test for stationary
kpss.test(e) #Null hypothesis is Data has no unit root or data is stationary
adf.test(e)   #Null hypothesis is Data has unit root or data is non-stationary

See the video for more explanation.

Sunday, October 25, 2015

Seeding the Randomness

You can see the video here and explanation after this video.

Let’s consider series ${{\varepsilon }_{0}}$ and ${{\varepsilon }_{1}}$ both have 100 data entry and these data are normally distributed with zero mean and 1 standard deviation. You can use following commands in R to generate the data.

rm(list = ls())
#Let's generate 100 random numbers and save them in object e0 and e1
n = 100
e0 = rnorm(n, mean = 0, sd = 1)
e1 = rnorm(n, mean = 0, sd = 1)

Then let's find the mean and standard deviation.

#Let's find the mean of series e0 and e1
mean(e0)
mean(e1)
sd(e0)
sd(e1)

You will find the mean and standard deviation both will come close to above specified values but not exact (may be yours values will be different than mine as well see the video). Further we can plot both series (may be your plot will be different than mine see the video).

#Let's plot e0 and e1 at same panel
layout(1:2)
plot(e0, type="l", main = "my first plot of normally distributed 100 number")
plot(e1, type="l", main = "my second plot of normally distributed 100 number")
layout(1:1)

However, you must have noticed that the plot of e0 and e1 are same in nature but different in plot (yours can be different than mine as well). Further, the mean of e0 and e1 are statistically zero as the one tail t-test will fail to reject the null hypothesis of zero mean. Similarly the standard deviation of e0 and e1 are also statistically one.

But, you can make your replication consistent with mine. For that we can use the random seed. let me use random seed as 1 and let's develop another series $e$ with 200 data with mean of zero and standard deviation of 1 (this is a by default setting). A random seed (or seed state, or just seed) is a number (or vector) used to initialize a pseudorandom number generator. Then let’s see the plot as well.

#Now, to make your result consistent with mine there is need to set a random number seed. Let’s set the random seed
set.seed (1)

#Now let’s develop a normally distributed random 500 numbers
e <− rnorm(200)
plot(e, type="l")

If we closely observe the series $e$, we can see that it reverts to the mean of zero and variance is stable. Thus $e$ is a stationary process (I will blog on stationary process latter but for general intuition see here)

Thursday, October 1, 2015

Gross Domestic Product Explained

Gross domestic product/income or expenditure in producer's price (GDP/GDI/GDE) All + All - Gross domestic product/income or expenditure in producer's price (GDP/GDI/GDE)
• + - Income method earnings or cost approach
• + - method-1 (GDI = total factor income (TFI) + tax less subsidies in products)
• Total factor income (TFI) or GDP at factor cost/basic prices)
• + - Compensation of Employees (COE)
• Compensation of employees (COE) measures the total remuneration to employees for work done. It includes wages and salaries, as well as employer contributions to social security and other such programs.
• + - Gross Mixed Income (GMI)
• Gross operating surplus (GOS) is the surplus due to owners of incorporated businesses. Often called profits, although only subsets of total costs are subtracted from gross output to calculate GOS.
• + - Gross Operating Surplus (GOS)
• Gross mixed income (GMI) is the same measure as GOS, but for unincorporated businesses. This often includes most small businesses.
• plus tax less subsidies on product
• Method-2 (GDI = Wages+ Rents + Interests +Profits + Net indirect tax (NIT) - Depreciation (d)
• + - Product method (GDP = GDP at factor cost/basic price + tax less subsidies in products)
• plus tax less subsidies in products
• + - GDP at factor cost/basic prices
• + - Primary Sector (Agricultural Sector)
• Agriculture and forestry
• Fishing
• Mining and Quarrying
• + - Secondary Sector (Manufacturing Sector)
• Manufacturing
• Electricity gas and water
• Construction
• + - Tertiory Sector (Service Sector)
• Hotels and restaurants
• Transport, storage and communications
• Financial intermediation
• Real estate, renting and business activities
• Education
• Health and social work
• Other community, social and personal service activities
• less Financial intermediation indirectly measured (FISIM)
• + - Expenditure method (GDE = C + I + G + X - M )
• + - Gross national expenditure or absorption (A)
• + - Final consumption expenditure (FCE)
• Private consumption of durable and non durable goods (C)
• Government consumption of durable and non durable goods (G)
• + - Investment (I) or Gross fixed capital formulation (GCF)
• Gross fixed capital formulation (GFCF)
• + - Change in stock
• Closing stocks of inventories
• minus opening stocks of inventories
• + - Balance of trade (BOT) or Net export (NX)
• Total export of goods and services (X)
• minus total import of goods and services (M)