<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>panel data &#8211; Aptech</title>
	<atom:link href="https://www.aptech.com/blog/tag/panel-data/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.aptech.com</link>
	<description>GAUSS Software - Fastest Platform for Data Analytics</description>
	<lastBuildDate>Mon, 10 Mar 2025 17:11:24 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>Panel data, structural breaks and unit root testing</title>
		<link>https://www.aptech.com/blog/panel-data-structural-breaks-and-unit-root-testing/</link>
					<comments>https://www.aptech.com/blog/panel-data-structural-breaks-and-unit-root-testing/#comments</comments>
		
		<dc:creator><![CDATA[Eric]]></dc:creator>
		<pubDate>Sat, 23 Feb 2019 08:35:14 +0000</pubDate>
				<category><![CDATA[Econometrics]]></category>
		<category><![CDATA[Panel data]]></category>
		<category><![CDATA[panel data]]></category>
		<category><![CDATA[unit root]]></category>
		<guid isPermaLink="false">https://www.aptech.com/?p=19541</guid>

					<description><![CDATA[In this blog, we extend  our <a href="https://www.aptech.com/blog/unit-root-tests-with-structural-breaks/">analysis of unit root testing</a> with <a href="https://www.aptech.com/structural-breaks/">structural breaks</a> to <a href="https://www.aptech.com/blog/introduction-to-the-fundamentals-of-panel-data/">panel data</a>. Using panel data unit roots tests found in the GAUSS <a href="https://github.com/aptech/tspdlib">tspdlib</a> we consider if a panel of international current account balances collectively shows unit root behavior.
]]></description>
										<content:encoded><![CDATA[<p><img src="https://www.aptech.com/wp-content/uploads/2019/02/gblog-sb-02202018-1.png" alt="US Current Account Balance" /></p>
<h3 id="introduction">Introduction</h3>
<p>In this blog, we extend <a href="https://www.aptech.com/blog/unit-root-tests-with-structural-breaks/" target="_blank" rel="noopener">last week's</1> analysis of unit root testing with <a href="https://www.aptech.com/structural-breaks/" target="_blank" rel="noopener">structural breaks</a> to <a href="https://www.aptech.com/blog/introduction-to-the-fundamentals-of-panel-data/" target="_blank" rel="noopener">panel data</a>.</p>
<p>We will again use the quarterly current account to GDP ratio but focus on a panel of data from five countries:  United States, United Kingdom, Australia, South Africa, and India. </p>
<p>Using panel data unit roots tests found in the <a href="https://docs.aptech.com/gauss/tspdlib/docs/tspdlib-landing.html" target="_blank" rel="noopener">GAUSS tspdlib library</a> we consider if the panel collectively shows unit root behavior.</p>
<h2 id="testing-for-unit-roots-in-panel-data">Testing for unit roots in panel data</h2>
<h3 id="why-panel-data">Why panel data</h3>
<p>There are a number of reasons we utilize <a href="https://www.aptech.com/blog/introduction-to-the-fundamentals-of-panel-data/" target="_blank" rel="noopener">panel data</a> in econometrics (Baltagi, 2008). Panel data:</p>
<ul>
<li>Capture the idiosyncratic behaviors of individual groups with models like the fixed effects or random effects models.</li>
<li>Contain more information, more variability, and more efficiency.</li>
<li>Can detect and measure statistical effects that pure time-series or cross-section data can't. </li>
<li>Provide longer time-series for unit-root testing, which in turn leads to standard asymptotic behavior.</li>
</ul>
<h3 id="panel-data-unit-root-testing">Panel data unit root testing</h3>
<p>Today we will test for unit roots using the panel Lagrangian Multiplier (LM) unit-root test with structural breaks in the mean (Im, K., Lee, J., Tieslau, M., 2005):</p>
<ul>
<li>The panel LM test statistic averages the individual LM test statistics which are computed using the pooled likelihood function. </li>
<li>The asymptotic distribution of the test is robust to structural breaks. </li>
<li>The test considers the null unit root hypothesis against the alternative that at least one time series in the panel is stationary. </li>
</ul>
<h2 id="testing-our-panel">Testing our panel</h2>
<h3 id="setting-up-the-test">Setting up the test</h3>
<p>The panel LM test can be run using the <strong>GAUSS</strong> <a href="https://docs.aptech.com/gauss/tspdlib/docs/pdlm.html" target="_blank" rel="noopener">PDLM</a> procedure found in the GAUSS <strong>tspdlib</strong> library. The procedure has two required inputs and four additional optional arguments:</p>
<hr />
<dl>
<dt>y_test</dt>
<dd>T x N matrix,  the panel data to be tested.</dd>
<dt>model</dt>
<dd>Scalar,  indicates the type of model to be tested.<br>    1 = break in level.<br>    2 = break in level and trend.</dd>
<dt>nbreak</dt>
<dd>Scalar,  optional input, the number of breaks to allow. <br>    1 = one break.<br>    2 = two breaks. Default = 0.</dd>
<dt>pmax</dt>
<dd>Scalar,  optional input, maximum number of lags for Dy. 0 = no lags. Default = 8.</dd>
<dt>ic</dt>
<dd>Scalar,  optional input, the information criterion used to select lags. <br>    1 = Akaike. <br>    2 = Schwarz. <br>    3 = t-stat significance. Default = 3.</dd>
<dt>trimm</dt>
<dd>Scalar,  optional input, data trimming rate. Default = 0.10
<hr /></dd>
</dl>
<p>The <code>PDLM</code> procedure has five returns:</p>
<hr />
<dl>
<dt>Nlm</dt>
<dd>Vector,  the minimum test statistic for each cross-section.</dd>
<dt>Ntb</dt>
<dd>Vector,  location of break(s) for each cross-section.</dd>
<dt>Np</dt>
<dd>Scalar,  number of lags selected by chosen information criterion for each cross-section.</dd>
<dt>PDlm</dt>
<dd>Scalar,  panel LM statistic with N(0, 1).</dd>
<dt>pval</dt>
<dd>Scalar,  p-value of <em>PDlm</em>.</dd>
</dl>
<hr />
<h3 id="running-the-test">Running the test</h3>
<p>The test is easy to set up and run in GAUSS. We first load the <strong>tspdlib</strong> library and our data. </p>
<pre class="hljs-container hljs-container-solo"><code class="lang-gauss">library tspdlib;

// Load data
ca_panel = loadd("panel_ca.dat");
y_test = ca_panel[., 2:cols(ca_panel)];
</code></pre>
<p>Next, we specify that we want to run the model with level breaks and we call the <code>PDLM</code> procedure separately for the one break and two break models. We will keep all other parameters at their default values:</p>
<pre class="hljs-container hljs-container-solo"><code class="lang-gauss">// Specify to run model with 
// level breaks
model = 1;

// Run first with one break
nbreak = 1;

// Call PD LM with one level break
{ Nlm, Ntb, Np, PDlm, pval } = PDLM(y_test, model, nbreak);

// Run next with two breaks
nbreak = 2;

// Call PD LM with level break
{ Nlm, Ntb, Np, PDlm, pval } = PDLM(y_test, model, nbreak);</code></pre>
<h3 id="results">Results</h3>
<table style="border-collapse: collapse">
<tr>
<th>Country</th><th>Cross-section<br> test statistic</th><th>Break<br> location</th><th>Number of<br> lags</th><th>Conclusion</th>
</tr>
<tr><th colspan="5">Two break model</th></tr>
<tr>
<td>United States</td><td>-3.3067</td><td>1993 Q1, 2004 Q3</td><td>12</td><td>Reject the null</td>
</tr>
<tr>
<td>United Kingdom</td><td>-4.6080</td><td>1980 Q4, 1984 Q4</td><td>4</td><td>Reject the null</td>
</tr>
<tr>
<td>Australia</td><td>-3.9522</td><td>1970 Q3, 1977 Q4</td><td>12</td><td>Reject the null</td>
</tr>
<tr>
<td>South Africa</td><td>-5.6735</td><td>1976 Q4, 1983 Q4</td><td>4</td><td>Reject the null</td>
</tr>
<tr style="border-bottom: 2px solid #444;">
<td>India</td><td>-5.6734</td><td>1975 Q4, 2004 Q2</td><td>9&lt;</td><td>Reject the null</td>
</tr>
<tr style="border-top: 1px inset #444;"><td>Full Panel</td><td>-6.6339526</td><td>N/A</td><td>N/A</td><td>Reject the null</td>
</tr>
<tr><td colspan="5"> </td></tr>
<tr><th colspan="5">One break model</th></tr>

<tr>
<td>United States</td><td>-3.0504</td><td>1993 Q1</td><td>12&lt;</td><td>Reject the null</td>
</tr>
<tr>
<td>United Kingdom</td><td>-4.1213</td><td>1984 Q4</td><td>4</td><td>Reject the null</td>
</tr>
<tr>
<td>Australia</td><td>-3.1625</td><td>1980 Q2</td><td>12</td><td>Reject the null</td>
</tr>
<tr>
<td>South Africa</td><td>-5.1271</td><td>1979 Q4</td><td>4</td><td>Reject the null</td>
</tr>
<tr>
<td>India</td><td>-2.8001</td><td>1976 Q2</td><td>9</td><td>Reject the null</td>
</tr>
<tr style="border-top: 2px solid #444;"><td>Full Panel</td><td>-8.9118730</td><td>N/A</td><td>N/A</td><td>Reject the null</td>
</tr>
</table>
<p>Research on the presence of unit roots in current account balances has had mixed results. These results bring to the forefront the question of current account balance sustainability (Clower &amp; Ito, 2012). </p>
<p>Our panel tests with structural breaks unanimously reject the null hypothesis of unit roots for all cross-sections, as well as the combined panel. This adds support, at least for our small sample, to the idea that current account balances are sustainable and mean-reverting. </p>
<h2 id="conclusions">Conclusions</h2>
<p>Today we've learned about conducting panel data unit root testing in the presence of structural breaks using the LM test from  <a href="https://onlinelibrary.wiley.com/doi/abs/10.1111/j.1468-0084.2005.00125.x">(Im, K., Lee, J., Tieslau, M., 2005)</a>. After today you should have  a better understanding of:</p>
<ol>
<li>Some of the advantages of using panel-data.</li>
<li>How to test for unit roots in panel data using the LM test with structural breaks.</li>
<li>How to use the <a href="https://github.com/aptech/tspdlib">GAUSS tspdlib library</a> to test for unit roots with structural breaks.</li>
</ol>
<p>Code and data from this blog can be found <a href="https://github.com/aptech/gauss_blog/tree/master/time_series/panel-unitroot-2.22.19" target="_blank" rel="noopener">here</a>.</p>
<h3 id="further-reading">Further Reading</h3>
<ol>
<li><a href="https://www.aptech.com/blog/panel-data-basics-one-way-individual-effects/" target="_blank" rel="noopener">Panel Data Basics: One-way Individual Effects</a></li>
<li><a href="https://www.aptech.com/blog/how-to-aggregate-panel-data-in-gauss/" target="_blank" rel="noopener">How to Aggregate Panel Data in GAUSS</a></li>
<li><a href="https://www.aptech.com/blog/introduction-to-the-fundamentals-of-panel-data/" target="_blank" rel="noopener">Introduction to the Fundamentals of Panel Data</a></li>
<li><a href="https://www.aptech.com/blog/panel-data-stationarity-test-with-structural-breaks/" target="_blank" rel="noopener">Panel Data Stationarity Test With Structural Breaks</a></li>
<li><a href="https://www.aptech.com/blog/transforming-panel-data-to-long-form-in-gauss/" target="_blank" rel="noopener">Transforming Panel Data to Long Form in GAUSS</a></li>
</ol>
<h3 id="references">References</h3>
<p>Baltagi, B. (2008). <em>Econometric analysis of panel data</em>. John Wiley &amp; Sons.</p>
<p>Clower, E., &amp; Ito, H. (2012). The persistence of current account balances and its determinants: the implications for global rebalancing.</p>
<p>Im, K., Lee, J., Tieslau, M. (2005). Panel LM Unit-root Tests with Level Shifts. <em>Oxford Bulletin of Economics and Statistics</em> 67, 393–419.</p>]]></content:encoded>
					
					<wfw:commentRss>https://www.aptech.com/blog/panel-data-structural-breaks-and-unit-root-testing/feed/</wfw:commentRss>
			<slash:comments>9</slash:comments>
		
		
			</item>
		<item>
		<title>Apples to Apples: The case for cluster-robust standard errors</title>
		<link>https://www.aptech.com/blog/apples-to-apples-the-case-for-cluster-robust-standard-errors/</link>
					<comments>https://www.aptech.com/blog/apples-to-apples-the-case-for-cluster-robust-standard-errors/#respond</comments>
		
		<dc:creator><![CDATA[Eric]]></dc:creator>
		<pubDate>Sat, 08 Dec 2018 14:45:54 +0000</pubDate>
				<category><![CDATA[Econometrics]]></category>
		<category><![CDATA[cluster-robust]]></category>
		<category><![CDATA[covariance]]></category>
		<category><![CDATA[panel data]]></category>
		<guid isPermaLink="false">https://www.aptech.com/?p=18780</guid>

					<description><![CDATA[Linear regression commonly assumes that the error terms of a model are independently and identically distributed (i.i.d)  However, when datasets contain groups, the potential for correlated error terms within groups arises.  In this blog, we explore how to remedy this issue with clustered error terms. ]]></description>
										<content:encoded><![CDATA[<h3 id="introduction">Introduction</h3>
<p><a href="https://www.aptech.com/resources/tutorials/econometrics/linear-regression/">Linear regression</a> commonly assumes that the error terms of a model are independently and identically distributed (<strong>i.i.d</strong>).  However, when datasets contain groups, the potential for correlated error terms within groups arises. </p>
<h2 id="example-weather-shocks-to-apple-orchards">Example: Weather shocks to apple orchards</h2>
<p>For example, consider a model of the supply of apples from various orchards across the United States. Naturally, we would expect that orchards within Washington may all face similar weather-related &quot;shocks&quot; to their supply. However, we would not expect the weather shocks to the orchards in Washington to be the same as the weather shocks to the orchards in New York. </p>
<p><a href="https://www.aptech.com/wp-content/uploads/2018/12/winter-apples.jpg"><img src="https://www.aptech.com/wp-content/uploads/2018/12/winter-apples.jpg" alt="Weather shock to apple production." width="640" height="267" class="aligncenter size-full wp-image-18825" /></a></p>
<p>When these correlated within-group shocks occur, the i.i.d error term assumption is not valid and traditional error terms can result in misleading inference about coefficient estimates. </p>
<p>In these cases, is important to use error terms that appropriately account for the within-group correlation between error terms. </p>
<div class="alert alert-info" role="alert"><strong>Potential impacts of ignoring clustered error terms:</strong> <br><ul><li>Standard errors that are too small</li><li>Confidence interval bands that are too narrow</li><li>Overly large t-statistics</li><li>Over rejection of the null hypothesis</li></ul></div>
<h2 id="the-model">The Model</h2>
<p>Let's consider our hypothetical apple supply model which makes observations for each individual orchard, $i = 1, 2, \ldots\, N$ at each time period $t = 1, 2, \ldots\, T$:</p>
<p>$$y_{it} = x_{it}\beta + u_{it}$$</p>
<p>We can further aggregate our dataset into state-level groups, $g = 1, 2, \ldots, G$ such that:</p>
<p>$$y_{igt} = x_{igt}\beta + u_{igt}$$</p>
<p>The cluster-robust error term assumes that, $u_{igt}$, is correlated within groups but independent across groups. More formally:</p>
<p>$$E[u_{igt}u_{iht}]   \begin{cases} = 0 & \text{ if }g \neq h \\ \neq 0 & \text{ if }g = h \end{cases} $$ </p>
<p>The cluster-robust error computation allows for this correlation:</p>
<p>$$V_{clu}[\hat{\beta}] = (X'X)^{-1} * \sum_{j=1}^G u_j' u_j  * (X'X)^{-1}$$</p>
<p>where</p>
<p>$$u_j = \sum_{cluster_j} u_{it} x_{it} .$$</p>
<h2 id="estimating-our-model-in-gauss">Estimating our model in GAUSS</h2>
<p>Let's look more formally at our apple production model using the <code>apples_cluster.dat</code> dataset. Using this data we will model the production of apples in relationship to orchard acreage:</p>
<p>$$prod = \beta_0 + \beta_1*acres + u$$</p>
<h3 id="estimating-i-i-d-error-terms">Estimating i.i.d error terms</h3>
<p>First, let's model the data using i.i.d standard errors:</p>
<pre class="hljs-container hljs-container-solo"><code class="lang-gauss">// Specify filename
fname = __FILE_DIR $+ "apples_cluster.dat";

// Estimate model using ols
struct olsmtOut oOut;
oOut = olsmt(fname, "prod ~ acres", oCtl);</code></pre>
<p>This yields the following results:</p>
<pre>                         Standard                 Prob   Standardized  Cor with
Variable     Estimate      Error      t-value     &gt;|t|     Estimate    Dep Var
-------------------------------------------------------------------------------
CONSTANT    0.0296797   0.0283593     1.04656     0.295       ---         ---
acres         1.03483   0.0285833     36.2041     0.000    0.455813    0.455813 </pre>
<h3 id="estimating-cluster-robust-error-terms">Estimating cluster-robust error terms</h3>
<p>Now, we specify <a href="https://www.aptech.com/releases/gauss19/covariance-computations/">cluster-robust errors</a> using two members in the <code>olsmtControl</code> structure:</p>
<hr />
<dl>
<dt>oCtl.cov</dt>
<dd>String, the type of covariance matrix to be computed:</dd>
</dl>
<ul>
<li><code>"iid"</code> for i.i.d errors.</li>
<li><code>"cluster"</code> for cluster-robust errors.</li>
<li><code>"robust"</code> for the Huber/White sandwich estimator. </li>
</ul>
<dl>
<dt>oCtl.clusterId</dt>
<dd>String, the name of the variable containing data groups.</dd>
</dl>
<hr /> 
<div class="alert alert-info" role="alert"><strong>Note:</strong> Because we are using formula strings to specify our model we use <code>oCtl.clusterId</code> to specify our groups. However, if we use data matrices to specify our model the member <code>oCtl.clusterVar</code> to specify our groups.</div>
<p>Our code for estimation now becomes:</p>
<pre class="hljs-container hljs-container-solo"><code class="lang-gauss">// Estimate model using ols
struct olsmtControl oCtl;
oCtl = olsmtControlCreate();

// Set up cluster id variable
oCtl.clusterId = "state";

// Turn on cluster vce
oCtl.cov = "cluster";

// Estimate model 
struct olsmtOut oOut;
oOut = olsmt(fname, "prod ~ acres", oCtl);</code></pre>
<p>Which yields:</p>
<pre>                         Standard                 Prob   Standardized  Cor with
Variable     Estimate      Error      t-value     &gt;|t|     Estimate    Dep Var
-------------------------------------------------------------------------------
CONSTANT    0.0296797   0.0670127    0.442897     0.658       ---         ---
acres         1.03483   0.0505957      20.453     0.000    0.455813    0.455813 </pre>
<h3 id="comparing-results">Comparing results</h3>
<p>There are several key things to note about the two sets of results. </p>
<ol>
<li>Using cluster-robust standard errors has no impact on the coefficient estimates. </li>
<li>The cluster-robust standard errors are larger than i.i.d errors. </li>
</ol>
<p>In this case, the larger standard errors do not impact our conclusions regarding the significance of the estimated coefficients, but this may not always be true.</p>
<h3 id="conclusions">Conclusions</h3>
<p>In today's discussion of <a href="https://www.aptech.com/releases/gauss19/covariance-computations/">cluster-robust standard errors</a> we have learned :</p>
<ol>
<li>What types of models may introduce within-cluster correlation in error terms.</li>
<li>The potential impacts of ignoring within-cluster correlations in error terms.</li>
<li>How to estimate cluster-robust error terms. </li>
</ol>
<p>Code and data from this blog can be found <a href="https://github.com/aptech/gauss_blog/tree/master/econometrics/cluster-robust-12.10.2018">here</a>.</p>
<p>    <!-- MathJax configuration -->
    <style>
        .mjx-svg-href {
            fill: "inherit" !important;
            stroke: "inherit" !important;
        }
    </style>
    <script type="text/x-mathjax-config">
        MathJax.Hub.Config({ TeX: { equationNumbers: {autoNumber: "AMS"} } });
    </script>
    <script type="text/javascript">
window.MathJax = {
  tex2jax: {
    inlineMath: [ ['$','$'] ],
    displayMath: [ ['$$','$$'] ],
    processEscapes: true,
    processEnvironments: true
  },
  // Center justify equations in code and markdown cells. Elsewhere
  // we use CSS to left justify single line equations in code cells.
  displayAlign: 'center',
  "HTML-CSS": {
    styles: {'.MathJax_Display': {"margin": 0}},
    linebreaks: { automatic: false }
  },
  "SVG": {
    styles: {'.MathJax_SVG_Display': {"margin": 0}},
    linebreaks: { automatic: false }
  },
  showProcessingMessages: false,
  messageStyle: "none",
  menuSettings: { zoom: "Click" },
  AuthorInit: function() {
    MathJax.Hub.Register.StartupHook("End", function() {
            var timeout = false, // holder for timeout id
            delay = 250; // delay after event is "complete" to run callback
            var shrinkMath = function() {
              //var dispFormulas = document.getElementsByClassName("formula");
              var dispFormulas = document.getElementsByClassName("MathJax_SVG_Display");
              if (dispFormulas){
                // caculate relative size of indentation
                var contentTest = document.getElementsByTagName("body")[0];
                var nodesWidth = contentTest.offsetWidth;
                // if you have indentation
                var mathIndent = MathJax.Hub.config.displayIndent; //assuming px's
                var mathIndentValue = mathIndent.substring(0,mathIndent.length - 2);
                for (var i=0; i<dispFormulas.length; i++){
                  var dispFormula = dispFormulas[i];
                  var wrapper = dispFormula;
                  //var wrapper = dispFormula.getElementsByClassName("MathJax_Preview")[0].nextSibling;
                  var child = wrapper.firstChild;
                  wrapper.style.transformOrigin = "center"; //or top-left if you left-align your equations
                  var oldScale = child.style.transform;
                  //var newValue = Math.min(0.80*dispFormula.offsetWidth / child.offsetWidth,1.0).toFixed(2);
                  var newValue = Math.min(dispFormula.offsetWidth / child.offsetWidth,1.0).toFixed(2);
                  var newScale = "scale(" + newValue + ")";
                  if(newValue != "NaN" && !(newScale === oldScale)){
                    wrapper.style.transform = newScale;
                    wrapper.style["margin-left"]= Math.pow(newValue,4)*mathIndentValue + "px";
                    var wrapperStyle = window.getComputedStyle(wrapper);
                    var wrapperHeight = parseFloat(wrapperStyle.height);
                    wrapper.style.height = "" + (wrapperHeight * newValue) + "px";
                    if(newValue === "1.00"){
                      wrapper.style.cursor = "";
                      wrapper.style.height = "";
                    }
                    else {
                      wrapper.style.cursor = "zoom-in";
                    }
                  }

                }
            }
            };
            shrinkMath();
            window.addEventListener('resize', function() {
              clearTimeout(timeout);
              timeout = setTimeout(shrinkMath, delay);
            });
          });
  }
}
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-AMS_SVG"></script></p>

]]></content:encoded>
					
					<wfw:commentRss>https://www.aptech.com/blog/apples-to-apples-the-case-for-cluster-robust-standard-errors/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
