Econometrics blog

Apr 1, 2021

Caption above image & figure's note

 The floatrow package offers the \floatfoot macro for notes in addition to a float's \caption.

---------------------------------------------------------------------------

\documentclass{article}

\usepackage[capposition=top]{floatrow}

\begin{document}

\begin{figure}
% \centering% default with `floatrow`
\rule{1cm}{1cm}% placeholder for `\includegraphics`
\caption{A figure}
\floatfoot{A note}
\end{figure}

\end{document}
--------------------------------------------------

Output: 


 

Mar 21, 2019

Horizontal spacing in Latex

There are a number of horizontal spacing macros for LaTeX:
  1. \, inserts a \thinspace (equivalent to .16667em) in text mode, or \thinmuskip (equivalent to 3mu) in math mode;
  2. \! inserts a negative \thinmuskip in math mode;
  3. \> inserts \medmuskip (equivalent to 4.0mu plus 2.0mu minus 4.0mu) in math mode;
  4. \; inserts \thickmuskip (equivalent to 5.0mu plus 5.0mu) in math mode;
  5. \: is equivalent to \> (see above);
  6. \enspace inserts a space of .5em in text or math mode;
  7. \quad inserts a space of 1em in text or math mode;
  8. \qquad inserts a space of 2em in text or math mode;
  9. \kern <len> inserts a skip of <len> (may be negative) in text or math mode (a plain TeX skip);
  10. \hskip <len> (similar to \kern);
  11. \hspace{<len>} inserts a space of length <len> (may be negative) in math or text mode (a LaTeX \hskip);
  12. \hphantom{<stuff>} inserts space of length equivalent to <stuff> in math or text mode. Should be \protected when used in fragile commands (like \caption and sectional headings);
  13. \  inserts what is called a "control space" (in text or math mode);
  14. inserts an inter-word space in text mode (and is gobbled in math mode). Similarly for \space and { }.
  15. ~ inserts an "unbreakable" space (similar to an HTML &nbsp;) (in text or math mode);
  16. \hfill inserts a so-called "rubber length" or stretch between elements (in text or math mode). Note that you may need to provide a type of anchor to fill from/to; see What is the difference between \hspace*{\fill} and \hfill?;
Your usage should work in math mode, so try $\:$.

Try this in Latex document":
\documentclass{article}
\setlength{\parindent}{0pt}% Just for this example
\begin{document}

There are a number of horizontal spacing macros for LaTeX:

\begin{tabular}{lp{5cm}}
  \verb|a\,b|                    & a\,b \\
  \verb|$a\,b$|                  & $a\,b$ \\
  \verb|a\thinspace b|           & a\thinspace b \\
  \verb|$a\thinspace b$|         & $a\thinspace b$ \\
  \verb|$a\!b$|                  & $a\!b$ \\
  \verb|$a\mkern-\thinmuskip b$| & $a\mkern-\thinmuskip b$ \\
  \verb|$a\>b$|                  & $a\>b$ \\
  \verb|$a\mkern\medmuskip b$|   & $a\mkern\medmuskip b$ \\
  \verb|$a\;b$|                  & $a\;b$ \\
  \verb|$a\mkern\thickmuskip b$| & $a\mkern\thickmuskip b$ \\
  \verb|$a\:b$|                  & $a\:b$ \\
  \verb|$a\mkern\medmuskip b$|   & $a\mkern\medmuskip b$ \\
  \verb|a\enspace b|             & a\enspace b \\
  \verb|$a\enspace b$|           & $a\enspace b$ \\
  \verb|a\quad b|                & a\quad b \\
  \verb|$a\quad b$|              & $a\quad b$ \\
  \verb|a\qquad b|               & a\qquad b \\
  \verb|$a\qquad b$|             & $a\qquad b$ \\
  \verb|a\hskip 1em b|           & a\hskip 1em b \\
  \verb|$a\hskip 1em b$|         & $a\hskip 1em b$ \\
  \verb|a\kern 1pc b|            & a\kern 1pc b \\
  \verb|$a\kern 1pc b$|          & $a\kern 1pc b$ \\
  \verb|a\hspace{35pt}b|         & a\hspace{35pt}b \\
  \verb|$a\hspace{35pt}b$|       & $a\hspace{35pt}b$ \\
  \verb|axyzb|                   & axyzb \\
  \verb|a\hphantom{xyz}b|        & a\hphantom{xyz}b \\
  \verb|$axyzb$|                 & $axyzb$ \\
  \verb|$a\hphantom{xyz}b$|      & $a\hphantom{xyz}b$ \\
  \verb|a{ }b|                   & a{ }b \\
  \verb|$a{ }b$|                 & $a{ }b$ \\
  \verb|a\space b|               & a\space b \\
  \verb|$a\space b$|             & $a\space b$ \\
  \verb|a\ b|                    & a\ b \\
  \verb|$a\ b$|                  & $a\ b$ \\
  \verb|a~b|                     & a~b \\
  \verb|$a~b$|                   & $a~b$ \\
  \verb|a\hfill b|               & a\hfill b \\
  \verb|$a\hfill b$|             & $a\hfill b$
\end{tabular}

\end{document}

Jun 4, 2017

Why must we include all exogenous variables in the first stage of IV regression.


Why must we include all exogenous variables in the first stage of IV regression. Stata has the answer below:

http://www.stata.com/support/faqs/statistics/instrumental-variables-regression/


Aug 19, 2016

Install Latex Package on Sublime 3

To use latex in Sublime, we need to install Latex tools on Sublime 3. Here is the instruction to install LaTeXTools. 
https://packagecontrol.io/packages/LaTeXTools
First, you have to install Sublime and Sumatra PDF

Before we need to install LaTexTools, we have to install the package control from here.
https://packagecontrol.io/installation


After installing package control. Open Sublime and click Shift+Ctrl+P to open the Palette. Search for "install package"and look for "LaTeXtools".

If succeeded, you will see latex on the build.

Apr 21, 2016

Converting a Polygon ZM shape file to a regular Shape Polygon

from:http://blog.csdn.net/qb371/article/details/8102109

I tried this on Arcmap 10.4:

  • Locate the following tool - 
    • ArcToolbox > Conversion Tools > To Shapefile > Feature Class To Shapefile (multiple) 
  • Launch the tool and add your Polygon ZM shapefiles to the input features. 
  • Select an 'Output Folder' 
  • Click on the 'Environments...' button at the bottom of the dialog box. To the right of the 'OK' button. 
  • Click on the 'General Settings' text. 
  • You should see two fields marked 'Output has Z Values' and 'Output has M Values'. 
  • Set both fields to 'Disabled'. 
  • Click 'OK' to exit the Environments Settings then click 'OK' to run the tools.

Feb 16, 2016

Remove trailing space in excel

Using the Trim function is easy to remove the trailing space in one cell, but time-consuming to remove trailing spaces in many cells. Here provides a macro to remove all trailing spaces of all cells in a selection.
Step 1: Select the range in which you want to remove trailing spaces from cells.
Step 2: Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.
Step 3: Click Insert > Module, and paste the following macro in the Module Window.
Sub NoSpaces()
Dim c As Range
For Each c In Selection.Cells
c = Trim(c)
Next
End Sub
Step 4: Press the F5 key to run this macro. And all of the trailing spaces of the selection will be removed.

Dec 30, 2015

Generating with matching value


 This is how to generate a variable with number matching:

#delimit;
egen poten_indo = anymatch(digit4n), values(
7201    7207    7113    8419    8003    8311    1804    1703    2902    6114    0906    3906    7305    4401    7208    6111    6406    5503    1605    0802    1212    8007    8538    7407    5205    0801 
);
#delimit cr

Jan 13, 2015

Cubic spline interpolation

We can interpolate missing data by using cubic spline in stata

first, install this package in stata:
ssc install csipolate

this is an example:
 Setup
        . webuse ipolxmpl1

    List the data
        . list, sep(0)

    Create y1 containing a natural cubic spline interpolation of y on
    x for missing values of y
        . csipolate y x, gen(y1)

    List the result
        . list, sep(0)



Nov 4, 2014

leading zero in string variable

A typical example might be to convert the following numbers 

> to a standard five-digit number with leading zeros:
> 2 -->  00002
> 33 --> 00033
> 473 --> 00473
> 59724 --> 59724

Display with leading zeros is a matter of format:
di %05.0f 2 

A more fundamental change is: 
gen str5 newvar = string(oldvar,"%05.0f") 

Oct 26, 2014

create label value from variable in stata

buat label value dari country, dari kode negara

we can use command labmask
. labmask kdnn, value(country)

. tabdis kdn, cellvar(kdnn country)

--------------------------------------------------
      kdn |               kdnn             country
----------+---------------------------------------
      001 |        FRANCE                    FRANCE
      003 |        NETHERLANDS       NETHERLANDS
      004 |        GERMANY                GERMANY
      006 |        UTD. KINGDOM       UTD. KINGDOM
      007 |        IRELAND                  IRELAND
      008 |        DENMARK              DENMARK


Sep 29, 2014

LaTeX: Change subsection numbering

If you want to change the subsection numbering, you have to renew the command first as follows:

\renewcommand\thesection{\roman{section}}
\renewcommand\thesubsection{\thesection.\roman{subsection}}
 
with similar commands like \thesubsubsection and so on 
of course, there's also \thechapter (in the book and report class) and \thepart.
Commands to typeset numbers include:
  • \arabic (1, 2, 3, ...)
  • \alph (a, b, c, ...)
  • \Alph (A, B, C, ...)
  • \roman (i, ii, iii, ...)
  • \Roman (I, II, III, ...)
  • \fnsymbol (∗, †, ‡, §, ¶, ...)
  •  
If you want to change numbering in \enumerate, use this:

\usepackage{enumerate}
.
.
.
\begin{enumerate}[(a)] % (a), (b), (c), ...
\item
\end{enumerate}
.
.
.
\begin{enumerate}[a)] % a), b), c), ...
\item
\end{enumerate}


 

Sep 19, 2014

LaTeX: Alligning long equation and manually input equation number


If your equation is too long, you can insert the following comment in the equation environment, with the \\ to break line.

\begin{equation}
\begin{aligned}
 ..... \\
........
 \end{aligned}
\end{equation}

for example:

\begin{equation}\label{e10}
 \begin{aligned}
  \text{ln VA} = lnQ_3 + 1/ \sigma_y lnMP + lnA + \alpha lnK + (1-\alpha + \varepsilon)\\
   \times ln (N-a_0 N^{3/2}) + (1-\rho)/\rho((1+MS)^{-1} ln(N-a_0N^{3/2})).
 \end{aligned}  
\end{equation}


If you want to manually set equation number just put \tag{equation number} in the end of the equation:

\begin{equation}\label{e10a}
\begin{aligned}
 \text{ln VA} = lnQ_3 + 1/ \sigma_y lnMP + lnA + \alpha lnK + (1-\alpha + \varepsilon)\\
   \times ln (N-a_0 N^{3/2}) + (1-\rho)/\rho((1+MS)^{-1} ln(N-a_0N^{3/2})).
   \end{aligned}   \tag{10a}
\end{equation}

LaTeX: Reduce line spacing in enumerate environment


To change enumerate, you must install package enumitem
\usepackage{enumitem}

to change enumerate globally:
\setlist[enumerate]{itemsep=0mm}
 
 to change enumerate locally,
\begin{enumerate}[itemsep=3mm]


 for example:


\documentclass{article}
\usepackage{lipsum}

\usepackage{enumitem}
\setlist[enumerate]{itemsep=-5mm}

\begin{document}

\lipsum[1]
\begin{enumerate}
    \item one
    \item two
\end{enumerate}

\lipsum[2]
\begin{enumerate}[itemsep=5mm]
    \item one
    \item two
\end{enumerate}
\end{document}

Sep 9, 2007

First Lesson in Econometrics

An interesting, short, clear cut paper written by Prof Siegfried of University of Wisconsin . Read it here.