Thursday, January 12, 2017

Automatic ARIMA Algorithm for the In sample Forecast Accuracy Optimization in R

You may need to see previous blog: (here) | (here) |

You can download the R file (here)

Here is the explanatory YouTube video:

Tuesday, January 10, 2017

God Vs Man (Estimation of Unknown Parameters)

In this blog, I will try and estimate a regression line while the error term is white noise and try and discuss the meanings of estimates and reasons for preferences of errors to be white noise.

Here is the video:

Here are the codes:

Sunday, January 8, 2017

Why the Sum of AR Coefficients has to be Less than One in Modules Term?

For this you may want to see my previous blogs. (here) | (here) | (here) | (here)

For this blog you can download the excel file for simulation. (here)

The tutorial video is given below:

Convergence Path.

Saturday, January 7, 2017

Generic Demand and Comparative Statics

We will call the possible goods and services that a consumer can consume as commodities. A consumer can consume finite possible commodities and each of those commodities can be defined as ${{x}_{1}},{{x}_{2}}\cdots ,{{x}_{L}}$. This set can be defined as the commodity vector or commodity bundle can be viewed as the point in ${{\mathbb{R}}^{L}}$ or the real commodity space and given as: \[x=\left[ \begin{matrix} {{x}_{1}} \\ \vdots \\ {{x}_{L}} \\ \end{matrix} \right]\] The consumption set $X$ is the subset of such ${L}$ dimensional real commodity space ${{\mathbb{R}}^{L}}$ i.e. $X\subset {{\mathbb{R}}^{L}}$. The $X$ is subset or limited because of various physical constraints imposed by the environment. The consumption set is defined as: \[X={{\mathbb{R}}^{L}}=\left\{ x\in {{\mathbb{R}}^{L}}:{{x}_{L}}\ge 0\forall l=1,2,\cdots L \right\}\] Thus it has major two properties: a) this set is non-negative bundles of commodities and b) this set is convex. One major constraints imposed in the consumption set is affordability. Such affordability depends upon two major things. a) prices of those commodities $p=\left( {{p}_{1}},\cdots {{p}_{L}} \right)$ and b) consumer wealth $w$. Each of these commodities follows principle of completeness or universality, formally, each of these commodities are traded in market at prices quoted publicly and each prices are strictly positive i.e $p>>0$. Further, $p\centerdot x={{p}_{1}}{{x}_{1}}+\cdots +{{p}_{L}}{{x}_{L}}=\sum\limits_{l=1}^{L}{{{p}_{l}}{{x}_{l}}}\le w$ implies the feasibility of such consumption set. Then we can define, Walrasian or competitive budget set as ${{B}_{p,w}}=\left\{ x\subset \mathbb{R}_{+}^{L}:p\centerdot x\le w \right\}$. If, ${{B}_{p,w}}=\left\{ x\subset \mathbb{R}_{+}^{L}:p\centerdot x=w \right\}$then its known as the budget hyperplane. This competitive Walrasian budget set is also convex. The consumer's Walrasian (or market or ordinary) demand correspondence $x(p,w)$ assigns a set of chosen consumption bundle for each price-wealth pair and for single valued $x(p,w)$is referred to demand function. Such demand function has 3 major properties. Firstly, Walrasian demand correspondence $x(p,w)$satisfies the Walrus law i.e. $x(p,w)=w$for $p>>0\And w>0$, that means that there is no slackness or the consumer fully spend their wealth or, $\sum\limits_{l=1}^{L}{{{p}_{l}}{{x}_{l}}}=w$. For now we relax the inter-temporal concept that consumer may safe for future consumption. Secondly, the Walrasian demand correspondence is homogeneous of degree zero i.e any proportionally increment in prices and wealth will un-affect the demand or in other word only the real opportunities matters, formally, $x(\alpha p,\alpha w)=x(p,w)$for any $p,w,\alpha >0$. Lastly, the consumer reveal the information about the stable preferences which is known as the Weak Axiom of Revealed Preferences. Say when two different bundles $x$ and $y$ were available to consumer when his budget was ${{B}_{p,w}}$ and he chooses $x$(he revealed his preferences here) then in another budget say, ${{B}_{{p}',{w}'}}$, if he chooses the bundle $y$, then we can infer that $x$ was in-feasible in budget ${{B}_{{p}',{w}'}}$. For the fixed prices $\overline{p}$, the function of wealth $x(\overline{p},w)$ is known as the consumer's Engel function and its image in positive real space $\mathbb{R}_{+}^{L}$ is known as the wealth expansion path. The derivative, $\frac{\partial {{x}_{L}}(\overline{p},w)}{\partial w}$ is known as the wealth effect. Such wealth effect is positive for normal goods and negative for the inferior goods and zero for the necessity goods. The wealth effects of all the commodities of the consumption bundle real space is given in matrix notation as: \[{{D}_{w}}x(p,w)={{\left[ \begin{matrix} \frac{\partial {{x}_{1}}(p,w)}{\partial w} \\ \frac{\partial {{x}_{2}}(p,w)}{\partial w} \\ \vdots \\ \frac{\partial {{x}_{L}}(p,w)}{\partial w} \\ \end{matrix} \right]}_{L\times 1}}\in {{\mathbb{R}}^{L}}\] For the fixed wealth $\overline{w}$, the function of price $x(p,\overline{w})$ image in positive real space $\mathbb{R}_{+}^{L}$ is known as the offer curve. The derivative, $\frac{\partial {{x}_{l}}(\overline{p},w)}{\partial {{p}_{k}}}$ is known as the price effect. The own price effect is always negative (as per law of demand) i.e $\frac{\partial {{x}_{l}}(\overline{p},w)}{\partial {{p}_{k}}}<0$ $\forall$ $l=k$ except for the giffen goods which is positive i.e $\frac{\partial {{x}_{l}}(\overline{p},w)}{\partial {{p}_{k}}}<0$ for $l=k$. While, this derivative $\frac{\partial {{x}_{l}}(\overline{p},w)}{\partial {{p}_{k}}}<0$ for$l\ne k$ is positive/negative/zero iff $l$ and $k$ are substitute/complementary/unrelated for each other. The price effect in matrix notation is given in $L\times L$ dimension as: \[{{D}_{p}}x(p,w)={{\left[ \begin{matrix} \frac{\partial {{x}_{1}}(p,w)}{\partial {{p}_{1}}} & \cdots & \frac{\partial {{x}_{1}}(p,w)}{\partial {{p}_{L}}} \\ \vdots & \ddots & \vdots \\ \frac{\partial {{x}_{L}}(p,w)}{\partial {{p}_{1}}} & \cdots & \frac{\partial {{x}_{L}}(p,w)}{\partial {{p}_{L}}} \\ \end{matrix} \right]}_{L\times L}}\] where, diagonal elements are own-price effects. One major problems with the marginal are they are not unit-free therefore for different units its create the problem to compare two different marginal. Analysis of elasticity's solve such problem as the elasticity's are unit-free measure of marginal. The percentage change in quantity i.e ${\scriptstyle{}^{\partial {{x}_{l}}(p,w)}/{}_{{{x}_{l}}(p,w)}}$ w.r.t to percentage change in price ${\scriptstyle{}^{\partial {{p}_{k}}}/{}_{{{p}_{k}}}}$ gives the price elasticity of demand expressed as: ${{\varepsilon }_{lk}}(p,w)=\left( \frac{{\scriptstyle{}^{\partial {{x}_{l}}(p,w)}/{}_{{{x}_{l}}(p,w)}}}{{\scriptstyle{}^{\partial {{p}_{k}}}/{}_{{{p}_{k}}}}} \right)$ which can be re-expressed as: ${{\varepsilon }_{lk}}(p,w)=\left( \frac{\partial {{x}_{l}}(p,w)}{\partial {{p}_{k}}} \right)\left( \frac{{{p}_{k}}}{{{x}_{l}}(p,w)} \right)$ where, $\frac{\partial {{x}_{l}}(p,w)}{\partial {{p}_{k}}}$ is the slope of demand function. For, gives the own-price elasticity and for $l\ne k$gives the cross-elasticity. Similarly, the percentage change in quantity i.e ${\scriptstyle{}^{\partial {{x}_{l}}(p,w)}/{}_{{{x}_{l}}(p,w)}}$ w.r.t to percentage change in wealth ${\scriptstyle{}^{\partial w}/{}_{w}}$ gives the wealth elasticity of demand expressed as: ${{\varepsilon }_{lw}}(p,w)=\left( \frac{{\scriptstyle{}^{\partial {{x}_{l}}(p,w)}/{}_{{{x}_{l}}(p,w)}}}{{\scriptstyle{}^{\partial w}/{}_{w}}} \right)$ which can be re-expressed as: ${{\varepsilon }_{lk}}(p,w)=\left( \frac{\partial {{x}_{l}}(p,w)}{\partial w} \right)\left( \frac{w}{{{x}_{l}}(p,w)} \right)$ where, $\frac{\partial {{x}_{l}}(p,w)}{\partial w}$ $\frac{\partial {{x}_{l}}(p,w)}{\partial {{p}_{k}}}$ is the slope of income or wealth demand function.

Note: Once, I define the demand correspondence. I will write $p\centerdot x={{p}_{1}}{{x}_{1}}+\cdots +{{p}_{L}}{{x}_{L}}=\sum\limits_{l=1}^{L}{{{p}_{l}}{{x}_{l}}}\le w$ as $p\centerdot x(p,w)={{p}_{1}}{{x}_{1}}(p,w)+\cdots +{{p}_{L}}{{x}_{L}}(p,w)=\sum\limits_{l=1}^{L}{{{p}_{l}}{{x}_{l}}}(p,w)\le w$.

(Because, I saw Batman last night!)

Sunday, January 1, 2017

Why Prices are Sticky? The Menu Cost Model.

Lucas Supply Function is based on the mis-information. $y=\beta (p-E(p))$$\beta >0$, If they make mistake on the actual and expectation price that change the output. The inference is that only the shocks matter.This discuss provoked series of paper like Taylor/Fisher who looked at the wage contracts/ staggered price on the wage. Other than the shock, the predictable changes matter as well. They just assumed the contracts but have not derived it. But still their results didn't show the reason "why price/wage are sticky?" 

The Mankiw Menu Cost Model try to answer it theoretically. The major idea is: microeconomic model of "Why prices are sticky?" The concept they introduced is the "menu cost". Hence their model is known as the Menu Cost model. 

Their setup is the monopoly market whose underline assumption is the imperfect competition and firms can choose the price. We want to figure out where/when the money matters? in this model Their nominal cost function is: $C=kqM$ where $M$ is money, $q$ is the quantity. $k>0$ constant. 

They assumed an inverse demand function: $P=f(q)M$ this represents nominal price depends on output and money. The marginal cost is $MC=\frac{dC}{dq}=kM$ 

The Marginal Revenue is: $MR=\frac{dqP}{dq}=\frac{qf(q)M}{dq}=\left( q{f}'(q)+f(q) \right)M$ 

For optimum 
$kM=\left( q{f}'(q)+f(q) \right)M$ 
$k=\left( q{f}'(q)+f(q) \right)$. 

Here the nominal money drops out, $q$ depends not on $M$ that means money doenot matter for the output. Suppose, real variable are denoted as: $c=\frac{C}{M},p=\frac{P}{M}$ and ${{p}_{m}}$ is the profit maximizing real price of a monopolist firm. 

Suppose, the firm faces a real cost $z$ for changing price (Menu Cost). The firm sells the prices one period ahead with the expectation that $M$ in that period will be ${{M}^{e}}$ (expected $M$ ). The nominal price they set is: ${{p}_{m}}{{M}^{e}}$ real actual price: ${{p}_{0}}=\frac{{{p}_{m}}{{M}^{e}}}{M}$ so, ${{p}_{m}}={{p}_{0}}$ if ${{M}^{e}}=M$ , But what happens if ${{M}^{e}}\ne M$, i.e, suppose ${{M}^{e}}>M\Rightarrow {{p}_{0}}>{{p}_{m}}$ or, ${{M}^{e}}<M\Rightarrow {{p}_{0}}<{{p}_{m}}$. Will firms change the prices? 

The Loss of profit for changing the price when expectation don't match is: $\pi ({{p}_{0}})-\pi ({{p}_{m}})$ where $\pi ({{p}_{m}})$ is the maximum profit there fore ${\pi }'\left( {{p}_{m}} \right)=0$ A second order Taylor series approximation is \[\pi \left( {{p}_{0}} \right)\cong \pi \left( {{p}_{m}} \right)+{\pi }'\left( {{p}_{m}} \right)\left( {{p}_{0}}-{{p}_{m}} \right)+\frac{1}{2}{\pi }''\left( {{p}_{m}} \right){{\left( {{p}_{0}}-{{p}_{m}} \right)}^{2}}\] \[\underbrace{\pi \left( {{p}_{0}} \right)-\pi \left( {{p}_{m}} \right)}_{B-A}\cong \frac{1}{2}{\pi }''\left( {{p}_{m}} \right){{\left( {{p}_{0}}-{{p}_{m}} \right)}^{2}}\because {\pi }'\left( {{p}_{m}} \right)=0\] $\underbrace{\pi \left( {{p}_{0}} \right)-\pi \left( {{p}_{m}} \right)}_{B-A}\cong \frac{1}{2}{\pi }''\left( {{p}_{m}} \right){{\left( {{p}_{0}}-{{p}_{m}} \right)}^{2}}$ is the second order effect. And, the reason the firms may not or don't change the price is due to second order effect. If the effect is say, $0<{{p}_{0}}-{{p}_{m}}<1$ then the increase in the profit is less than the cost i.e., ${{p}_{0}}-{{p}_{m}}>{{\left( {{p}_{0}}-{{p}_{m}} \right)}^{2}}$. 

Another important paper is Blanchard and Kiyotaki (1989) AER, which is the workhorse of the DSGE model. see (here).