Debian Codegraph @

addons/ivpanel/doc/ivpanel.tex

raw
1 \documentclass{article}
2 \usepackage{url,verbatim,fancyvrb}
3 \usepackage{pifont}
4 \usepackage[authoryear]{natbib}
5 \usepackage[pdftex]{graphicx}
6 \usepackage{gretl}
7 \usepackage[letterpaper,body={6.3in,9.15in},top=.8in,left=1.1in]{geometry}
8 \usepackage{color,hyperref}
9 %\usepackage[pdftex,hyperfootnotes=false]{hyperref}
10
11 %\usepackage[a4paper,body={6.1in,9.7in},top=.8in,left=1.1in]{geometry}
12
13 \definecolor{steel}{rgb}{0.03,0.20,0.45}
14
15 \hypersetup{colorlinks=true,
16 linkcolor=blue,
17 urlcolor=red,
18 citecolor=steel,
19 bookmarksnumbered=true,
20 plainpages=false
21 }
22
23 \begin{document}
24
25 \setlength{\parindent}{0pt}
26 \setlength{\parskip}{1ex}
27
28 \newcommand{\argname}[1]{\textsl{#1}}
29
30 \title{\textsf{ivpanel}: IV estimation of panel-data models}
31 \author{Allin Cottrell}
32 \date{February 15, 2021}
33 \maketitle
34
35 \section{Introduction}
36
37 This package estimates three variants of panel data models with
38 instrumental variables, namely fixed-effects, the ``between'' model,
39 and random effects (Generalized 2-Stage Least Squares or G2SLS). An
40 extended discussion of these models can be found in chapter 7 of
41 \cite{baltagi05}. The sample script provided with this package
42 replicates results obtained by Baltagi using \textsf{Stata} for
43 each of the three supported models.
44
45 The required arguments to the main public function \texttt{ivpanel()}
46 are as follows:
47
48 \begin{enumerate}
49 \item \argname{y} (series), the dependent variable
50 \item \argname{X} (list), the regressors, both exogenous and endogenous
51 \item \argname{Z} (list), the instruments, including any exogenous
52 regressors
53 \end{enumerate}
54
55 Note that exogenous variables in list \argname{X} should be repeated
56 in \argname{Z}, as in gretl's \texttt{tsls} command. The constant is
57 automatically added to \argname{X} and \argname{Z} if it's not already
58 present.
59
60 An optional fourth argument, \argname{case}, can be used to specify
61 the type of model. The argument is an integer switch that takes values
62 1, 2 or 3 (this may be extended in future). A value of 1 means fixed
63 effects, and is implicit if no fourth argument is given; a value of 2
64 means to use the between estimator; and a value of 3 means G2SLS.
65 Leaving aside the constant, all the members of \argname{X} and
66 \argname{Z} must be time-varying when the fixed effects case is
67 selected.
68
69 An optional final boolean argument, \argname{quiet}, controls the
70 printing of output: if \argname{quiet} is set to a non-zero value,
71 printing is suppressed.
72
73 \section{The ivpanel bundle}
74
75 By way of return value, \texttt{ivpanel()} offers a gretl bundle
76 containing the items shown in Table~\ref{tab:bun}.
77
78 \begin{table}[htbp]
79 \centering
80 \begin{tabular}{llp{.6\textwidth}}
81 \textit{name} & \textit{type} & \textit{description} \\[4pt]
82 \texttt{case} & scalar & the value of the \argname{case} argument on input \\
83 \texttt{nobs} & scalar & the total number of observations used \\
84 \texttt{coeff} & matrix & column vector of coefficients \\
85 \texttt{stderr} & matrix & column vector of standard errors \\
86 \texttt{vcv} & matrix & the coefficient covariance matrix \\
87 \texttt{uhat} & matrix & the vector of residuals \\
88 \texttt{yhat} & matrix & the vector of fitted values \\
89 \texttt{SSR} & scalar & sum of squared residuals \\
90 \texttt{sigma} & scalar & standard error of the regression \\
91 \texttt{df} & scalar & degrees of the freedom for the regression \\
92 \texttt{rsq} & scalar & correlation-based $R^2$ \\
93 \texttt{wald} & scalar & Wald joint $\chi^2$ test for all regressors \\
94 \texttt{modstr} & string & short description of the model \\
95 \texttt{ystr} & string & the name of the dependent variable \\
96 \texttt{Estr} & string & the names of the endogenous regressor(s) \\
97 \texttt{Istr} & string & the names of the (additional) instruments \\
98 \texttt{dims} & matrix & data dimensions (cases 1 and 3 only) \\
99 \texttt{Fpool} & scalar & $F$-test for joint significance of fixed
100 effects (case 1 only)
101 \end{tabular}
102 \caption{Items in ivpanel bundle}
103 \label{tab:bun}
104 \end{table}
105
106 Some comments on the bundle members follow.
107
108 \begin{itemize}
109
110 \item The $R^2$ value, \texttt{rsq}, is calculated as the square of the
111 correlation between the dependent variable and the fitted values.
112
113 \item The \texttt{dims} vector, if present, contains three elements
114 holding, respectively, the number of groups used and the minimum and
115 maximum time-series spans.
116
117 \item The \texttt{Fpool} statistic for fixed effects is calculated as
118 per \cite{wooldridge90}, adjusted for the panel case. The formula is
119 \[
120 \frac{\mbox{SSRr} - \mbox{SSRu}}{\mbox{SSRf}} \times
121 \frac{\mbox{dfd}}{\mbox{dfn}}
122 \]
123
124 where SSRf is the sum of squared residuals from the fixed-effects IV
125 model and the other two SSR values are calculated thus:
126 \begin{enumerate}
127 \item We run the fixed-effects first-stage regressions and save the
128 fitted values; we then use these to replace the endogenous
129 regressors.
130 \item SSRr is then obtained via OLS, and SSRu from a fixed-effects
131 regression. SSRu differs from SSRf in that it uses the ``raw''
132 residuals, without correction as one usually applies with two stage
133 least squares (i.e.\ replacing the first-stage fitted values with
134 the actual data for the endogenous regressors when computing the
135 fitted values).
136 \end{enumerate}
137
138 \end{itemize}
139
140 \section{Sample script}
141
142 The sample script estimates three models of the (log) crime rate
143 across the counties of North Carolina over the years 1981 to 1987,
144 using data from \cite{cornwell94}. The endogenous regressors are
145 \texttt{lpolpc} (log of police per capita) and \texttt{lprbarr} (log
146 of the estimated probability of arrest). The instruments (besides the
147 exogenous regressors) are \texttt{ltaxpc} (log of tax revenue per
148 capita), \texttt{lmix} (log of the offense ``mix'', face-to-face
149 versus other) and a set of year dummies.
150
151 It's perhaps noteworthy that despite the IV approach, the coefficient
152 on \texttt{lpolpc} is positive in all the models, the opposite of what
153 would be expected if the estimator had succeeded in picking up a
154 causal relationship. At least in the fixed effects specification the
155 positive \texttt{lpolpc} coefficient is not statistically significant
156 ($P$-value > 0.4).
157
158 \section{Graphical interface}
159
160 An entry-point for \textsf{ivpanel} can be found under the
161 \textsf{Panel} sub-menu of gretl's \textsf{Model} menu: the label is
162 ``Panel IV model.'' See Figure~\ref{fig:gui}. The specification of the
163 endogenous regressors is implicit: any variables that appear in the
164 ``regressors'' list and not in the ``instruments'' list are taken to
165 be endogenous.
166
167 \begin{figure}[htbp]
168 \centering
169 \includegraphics[scale=0.6]{ivpanel-gui}
170 \caption{Specify arguments for ivpanel}
171 \label{fig:gui}
172 \end{figure}
173
174 \section{Auxiliary printing function}
175
176 The auxiliary public function \dtk{ivp_print()} is provided to
177 ``pretty-print'' the results contained in the bundle provided by
178 \texttt{ivpanel()}; \dtk{ivp_print()} takes a pointer to the
179 bundle as its sole argument.
180
181 \section{Change log}
182
183 2021-02-15: add guard against excessive collinearity.\\
184 2020-09-22: avoid use of deprecated \texttt{isnull} function.\\
185 2015-10-17: first release as addon. \\
186
187 \bibliographystyle{gretl}
188 \bibliography{gretl}
189
190 \end{document}