<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://eclr.humanities.manchester.ac.uk/index.php?action=history&amp;feed=atom&amp;title=GMM_over</id>
		<title>GMM over - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://eclr.humanities.manchester.ac.uk/index.php?action=history&amp;feed=atom&amp;title=GMM_over"/>
		<link rel="alternate" type="text/html" href="http://eclr.humanities.manchester.ac.uk/index.php?title=GMM_over&amp;action=history"/>
		<updated>2026-04-26T18:56:12Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.30.1</generator>

	<entry>
		<id>http://eclr.humanities.manchester.ac.uk/index.php?title=GMM_over&amp;diff=4278&amp;oldid=prev</id>
		<title>Rb at 08:41, 8 February 2022</title>
		<link rel="alternate" type="text/html" href="http://eclr.humanities.manchester.ac.uk/index.php?title=GMM_over&amp;diff=4278&amp;oldid=prev"/>
				<updated>2022-02-08T08:41:24Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 08:41, 8 February 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot; &gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This code illustrates an overidentified (number of moments &amp;gt; number of parameters) 2-step GMM estimation.&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This code illustrates an overidentified (number of moments &amp;gt; number of parameters) 2-step GMM estimation.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;This code requires numgrad.m in your working directory. This is a function to calculate numerical gradients.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Rb</name></author>	</entry>

	<entry>
		<id>http://eclr.humanities.manchester.ac.uk/index.php?title=GMM_over&amp;diff=4277&amp;oldid=prev</id>
		<title>Rb at 08:40, 8 February 2022</title>
		<link rel="alternate" type="text/html" href="http://eclr.humanities.manchester.ac.uk/index.php?title=GMM_over&amp;diff=4277&amp;oldid=prev"/>
				<updated>2022-02-08T08:40:35Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 08:40, 8 February 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l15&quot; &gt;Line 15:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 15:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;clear all;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;clear all;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;clc;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;clc;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;cd &amp;#039;C:\Users\&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;msassrb2\Dropbox (The University of Manchester)\ECON80021\201920\GMM&lt;/del&gt;&amp;#039;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;cd &amp;#039;C:\Users\&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;YOUR_WORKING_DIRECTORY&lt;/ins&gt;&amp;#039;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;% Load data --- monthly December 1946 to February 1991&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;% Load data --- monthly December 1946 to February 1991&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Rb</name></author>	</entry>

	<entry>
		<id>http://eclr.humanities.manchester.ac.uk/index.php?title=GMM_over&amp;diff=4276&amp;oldid=prev</id>
		<title>Rb: Created page with &quot;This code illustrates an overidentified (number of moments &gt; number of parameters) 2-step GMM estimation.   &lt;source&gt; %=========================================================...&quot;</title>
		<link rel="alternate" type="text/html" href="http://eclr.humanities.manchester.ac.uk/index.php?title=GMM_over&amp;diff=4276&amp;oldid=prev"/>
				<updated>2022-02-08T08:40:00Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;This code illustrates an overidentified (number of moments &amp;gt; number of parameters) 2-step GMM estimation.   &amp;lt;source&amp;gt; %=========================================================...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This code illustrates an overidentified (number of moments &amp;gt; number of parameters) 2-step GMM estimation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
%=========================================================================&lt;br /&gt;
%&lt;br /&gt;
% Program to estimate level effect in interest rates by GMM&lt;br /&gt;
%&lt;br /&gt;
% Code based on Martin, Hurn and Harris, Econometric Time Series Modelling&lt;br /&gt;
% Specification, Estimation and Testing&lt;br /&gt;
% https://www.cambridge.org/features/econmodelling/chapter10.htm&lt;br /&gt;
%=========================================================================&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
clear all;&lt;br /&gt;
clc;&lt;br /&gt;
cd &amp;#039;C:\Users\msassrb2\Dropbox (The University of Manchester)\ECON80021\201920\GMM&amp;#039;&lt;br /&gt;
&lt;br /&gt;
% Load data --- monthly December 1946 to February 1991&lt;br /&gt;
%     3 month maturity&lt;br /&gt;
% extracted from the datafile provided by &lt;br /&gt;
% Martin, Hurn and Harris&lt;br /&gt;
% https://www.cambridge.org/features/econmodelling/chapter10.htm&lt;br /&gt;
&lt;br /&gt;
[rt, ~, ~] = xlsread(&amp;#039;US3monthRate.xlsx&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
drt = trimr(rt,2,0) - trimr(rt,1,1); % creates \Delta r_{t+1}&lt;br /&gt;
r1t = trimr(rt,1,1);                 % creates r_t&lt;br /&gt;
r2t = trimr(rt,0,2);&lt;br /&gt;
t   = length(drt);&lt;br /&gt;
&lt;br /&gt;
%% It is typically good practice to visualise the data&lt;br /&gt;
tt = seqa(1946+12/12,1/12,t); % Creates year sequence&lt;br /&gt;
&lt;br /&gt;
subplot(1,2,1);&lt;br /&gt;
plot(tt,r1t);&lt;br /&gt;
title(&amp;#039;r_t&amp;#039;)&lt;br /&gt;
box off&lt;br /&gt;
axis tight&lt;br /&gt;
&lt;br /&gt;
subplot(1,2,2);&lt;br /&gt;
plot(tt,drt);&lt;br /&gt;
title(&amp;#039;\Delta r_{t+1}&amp;#039;)&lt;br /&gt;
box off&lt;br /&gt;
axis tight&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
%% Estimate the model in the first stage with idendity weighting matrix&lt;br /&gt;
&lt;br /&gt;
ops  = optimset(&amp;#039;LargeScale&amp;#039;,&amp;#039;off&amp;#039;,&amp;#039;Display&amp;#039;,&amp;#039;off&amp;#039;);&lt;br /&gt;
b0   = [0.1;0.1;0.1;1.0];&lt;br /&gt;
w0 = eye(6);&lt;br /&gt;
bgmm1 = fminunc(@(b) qw(b,drt,r1t,r2t,w0),b0,ops);&lt;br /&gt;
&lt;br /&gt;
disp(&amp;#039;First Stage GMM estimates&amp;#039;)&lt;br /&gt;
disp(bgmm1)&lt;br /&gt;
&lt;br /&gt;
%% Now estimate the optimal weighting matrix&lt;br /&gt;
% using Newey-West estimator&lt;br /&gt;
lmax = 5;   % lag for the NW estimate &lt;br /&gt;
d = meqn(bgmm1,drt,r1t,r2t);&lt;br /&gt;
&lt;br /&gt;
% this will calculate Newey-West VCM using lmax lags&lt;br /&gt;
s   = d&amp;#039;*d;&lt;br /&gt;
tau = 1;&lt;br /&gt;
while tau &amp;lt;= lmax&lt;br /&gt;
    wtau = d((tau+1):size(d,1),:)&amp;#039;*d(1:(size(d,1)-tau),:);&lt;br /&gt;
    s    = s + (1.0-tau/(lmax+1))*(wtau + wtau&amp;#039;);&lt;br /&gt;
    tau  = tau + 1;&lt;br /&gt;
end&lt;br /&gt;
w1 = s./t;&lt;br /&gt;
&lt;br /&gt;
% Use this as the weighting matrix for the next pass to the optimisation&lt;br /&gt;
% function&lt;br /&gt;
&lt;br /&gt;
%% 2nd Stage &lt;br /&gt;
&lt;br /&gt;
bgmm2 = fminunc(@(b) qw(b,drt,r1t,r2t,w1),bgmm1,ops);&lt;br /&gt;
&lt;br /&gt;
disp(&amp;#039;Second Stage GMM estimates&amp;#039;)&lt;br /&gt;
disp(bgmm2)&lt;br /&gt;
&lt;br /&gt;
%% Further Iterations&lt;br /&gt;
% You could run further iterations&lt;br /&gt;
% 1) Re-calculate d&lt;br /&gt;
% 2) Re-calculate the optimal weighting matrix w based on the new d&lt;br /&gt;
% 3) Re-estimate using the new w&lt;br /&gt;
%&lt;br /&gt;
% For now we stop here&lt;br /&gt;
bgmm = bgmm2;&lt;br /&gt;
obj = qw(bgmm,drt,r1t,r2t,w1);&lt;br /&gt;
&lt;br /&gt;
%% Calculate standard errors&lt;br /&gt;
% Compute optimal weigthing matrix at GMM estimates&lt;br /&gt;
% using Newey-West estimator&lt;br /&gt;
lmax = 5;   % lag for the NW estimate &lt;br /&gt;
d = meqn(bgmm,drt,r1t,r2t);&lt;br /&gt;
&lt;br /&gt;
% this will calculate Newey-West VCM using lmax lags&lt;br /&gt;
s   = d&amp;#039;*d;&lt;br /&gt;
tau = 1;&lt;br /&gt;
while tau &amp;lt;= lmax&lt;br /&gt;
    wtau = d((tau+1):size(d,1),:)&amp;#039;*d(1:(size(d,1)-tau),:);&lt;br /&gt;
    s    = s + (1.0-tau/(lmax+1))*(wtau + wtau&amp;#039;);&lt;br /&gt;
    tau  = tau + 1;&lt;br /&gt;
end&lt;br /&gt;
s = s./t;&lt;br /&gt;
&lt;br /&gt;
% Compute standard errors of GMM estimates&lt;br /&gt;
dg = numgrad(@meaneqn,bgmm,drt,r1t,r2t);&lt;br /&gt;
v  = dg&amp;#039;*inv(s)*dg;&lt;br /&gt;
cov = inv(v)/t;&lt;br /&gt;
se = sqrt(diag(cov));&lt;br /&gt;
&lt;br /&gt;
disp(&amp;#039; &amp;#039;);&lt;br /&gt;
disp([&amp;#039;The value of the objective function  = &amp;#039;, num2str(obj) ]);&lt;br /&gt;
disp([&amp;#039;J-test                               = &amp;#039;, num2str(t*obj) ]);&lt;br /&gt;
disp(&amp;#039;Estimates     Std err.   t-stats&amp;#039;);&lt;br /&gt;
disp( [ bgmm  se  bgmm./se ])&lt;br /&gt;
disp([&amp;#039;Newey-West estimator with max lag    = &amp;#039;, num2str(lmax) ]);&lt;br /&gt;
disp(&amp;#039; &amp;#039;);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
%% Inference t-tests&lt;br /&gt;
&lt;br /&gt;
% Test of gam = 0.0&lt;br /&gt;
stat = (bgmm(4) - 0.0)/se(4);&lt;br /&gt;
disp([&amp;#039;Test of (gam=0.0) = &amp;#039;, num2str(stat) ]);&lt;br /&gt;
disp([&amp;#039;p-value           = &amp;#039;, num2str(2*(1-normcdf(abs(stat)))) ]);&lt;br /&gt;
disp(&amp;#039; &amp;#039;);&lt;br /&gt;
&lt;br /&gt;
% Test of gam = 0.5&lt;br /&gt;
stat = (bgmm(4) - 0.5)/se(4);&lt;br /&gt;
disp([&amp;#039;Test of (gam=0.5) = &amp;#039;, num2str(stat) ]);&lt;br /&gt;
disp([&amp;#039;p-value           = &amp;#039;, num2str(2*(1-normcdf(abs(stat)))) ]);&lt;br /&gt;
disp(&amp;#039; &amp;#039;);&lt;br /&gt;
&lt;br /&gt;
% Test of gam = 1.0&lt;br /&gt;
stat = (bgmm(4) - 1.0)/se(4);&lt;br /&gt;
disp([&amp;#039;Test of (gam=1.0) = &amp;#039;, num2str(stat) ]);&lt;br /&gt;
disp([&amp;#039;p-value           = &amp;#039;, num2str(2*(1-normcdf(abs(stat)))) ]);&lt;br /&gt;
disp(&amp;#039; &amp;#039;);&lt;br /&gt;
&lt;br /&gt;
% Test of gam = 1.5&lt;br /&gt;
stat = (bgmm(4) - 1.5)/se(4);&lt;br /&gt;
disp([&amp;#039;Test of (gam=1.5) = &amp;#039;, num2str(stat) ]);&lt;br /&gt;
disp([&amp;#039;p-value           = &amp;#039;, num2str(2*(1-normcdf(abs(stat)))) ]);&lt;br /&gt;
disp(&amp;#039; &amp;#039;);&lt;br /&gt;
&lt;br /&gt;
%% Inference - Overidentifying restrictions&lt;br /&gt;
J = t*obj;&lt;br /&gt;
Jdof = size(s,1)-size(b0,1);&lt;br /&gt;
disp([&amp;#039;J-Test of overidentifying restrictions = &amp;#039;, num2str(J) ]);&lt;br /&gt;
disp([&amp;#039;p-value                                = &amp;#039;, num2str(1-chi2cdf(J,2)) ]);&lt;br /&gt;
disp(&amp;#039; &amp;#039;);&lt;br /&gt;
&lt;br /&gt;
%% Plot volatility function for alternative values of gam&lt;br /&gt;
tt = seqa(1946+12/12,1/12,t);&lt;br /&gt;
figure(1)&lt;br /&gt;
&lt;br /&gt;
subplot(2,2,1);&lt;br /&gt;
plot(tt,drt./r1t.^0.0);&lt;br /&gt;
title(&amp;#039;$\gamma=0.0$&amp;#039;)&lt;br /&gt;
box off&lt;br /&gt;
axis tight&lt;br /&gt;
&lt;br /&gt;
subplot(2,2,2);&lt;br /&gt;
plot(tt,drt./r1t.^0.5);&lt;br /&gt;
title(&amp;#039;$\gamma=0.5$&amp;#039;)&lt;br /&gt;
box off&lt;br /&gt;
axis tight&lt;br /&gt;
&lt;br /&gt;
subplot(2,2,3);&lt;br /&gt;
plot(tt,drt./r1t.^1.0);&lt;br /&gt;
title(&amp;#039;$\gamma=1.0$&amp;#039;)&lt;br /&gt;
box off&lt;br /&gt;
axis tight&lt;br /&gt;
&lt;br /&gt;
subplot(2,2,4);&lt;br /&gt;
plot(tt,drt./r1t.^1.5);&lt;br /&gt;
title(&amp;#039;$\gamma=1.5$&amp;#039;)&lt;br /&gt;
box off&lt;br /&gt;
axis tight&lt;br /&gt;
&lt;br /&gt;
%&lt;br /&gt;
%------------------------- Functions -------------------------------------%&lt;br /&gt;
%&lt;br /&gt;
%-------------------------------------------------------------------------%&lt;br /&gt;
% Define the moment equations &lt;br /&gt;
%-------------------------------------------------------------------------%&lt;br /&gt;
function dt = meqn(b,drt,r1t,r2t)&lt;br /&gt;
    &lt;br /&gt;
        ut = drt - b(1) - b(2)*r1t;&lt;br /&gt;
        zt = [ones(size(ut,1),1),r1t,r2t];&lt;br /&gt;
        dt = repmat(ut,1,3).*zt;&lt;br /&gt;
        dt = [dt,repmat((ut.^2 - (b(3)^2)*r1t.^(2*b(4)) ),1,3).*zt];&lt;br /&gt;
   &lt;br /&gt;
end&lt;br /&gt;
%-------------------------------------------------------------------------%&lt;br /&gt;
% Defines the mean of the moment conditions  &lt;br /&gt;
%-------------------------------------------------------------------------%&lt;br /&gt;
function ret = meaneqn(b,drt,r1t,r2t)&lt;br /&gt;
&lt;br /&gt;
        ret = (mean(meqn(b,drt,r1t,r2t)))&amp;#039;;&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
%-------------------------------------------------------------------------%&lt;br /&gt;
% GMM objective function with  user defined &lt;br /&gt;
% weighting matrix, w&lt;br /&gt;
%-------------------------------------------------------------------------%   &lt;br /&gt;
function ret = qw(b,drt,r1t,r2t,w)&lt;br /&gt;
        &lt;br /&gt;
    t = length(drt);&lt;br /&gt;
    d = meqn(b,drt,r1t,r2t);&lt;br /&gt;
    g = mean(d)&amp;#039;;&lt;br /&gt;
&lt;br /&gt;
    ret = g&amp;#039;*inv(w)*g;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rb</name></author>	</entry>

	</feed>