Sunday, April 29, 2012

Discussions on Logit, multinomial Logit and conditional Logit models

Simply put, discrete choice models are based on utility maximization theorem.  Logit model means the random component follows Logit distribution.  Multinomial means the expected utilities hij are modeled in terms of characteristics of the individuals.  Conditonal means the expected utility is based on characteristics of choices.

Tuesday, April 24, 2012

How to wrap long equations automatically in Lyx

Here, we met another issue regarding equation editing in Lyx: the long equations do not wrap automatically.  There is a 3-step method to solve this problem.

1.  First make sure you have installed the hm package, which includes breqn package.

2. Change Math tab in document settings to hm~~.  Be sure only let this option checked.

3. Add the following code to the preample:

  \usepackage{breqn}

% Add support for automatic equation breaking
\gdef\wrap@breqn@environ#1#2{
\expandafter\let\csname breqn@oldbegin@#1\expandafter\endcsname\csname #1\endcsname
\expandafter\let\csname breqn@oldend@#1\expandafter\endcsname\csname end#1\endcsname
\expandafter\gdef\csname breqn@begin@#1\endcsname{%
\expandafter\let\csname #1\expandafter\endcsname\csname breqn@oldbegin@#1\endcsname%
\begin{#2}%
}
\expandafter\gdef\csname breqn@end@#1\endcsname{%
\expandafter\let\csname end#1\expandafter\endcsname\csname breqn@oldend@#1\endcsname%
\end{#2}%
\expandafter\let\csname #1\expandafter\endcsname\csname breqn@begin@#1\endcsname%
\expandafter\let\csname end#1\expandafter\endcsname\csname breqn@end@#1\endcsname%
}
\expandafter\let\csname #1\expandafter\endcsname\csname breqn@begin@#1\endcsname
\expandafter\let\csname end#1\expandafter\endcsname\csname breqn@end@#1\endcsname
}
\wrap@breqn@environ{equation}{dmath}
\wrap@breqn@environ{equation*}{dmath*}

Now choose "displayed formula" to create or edit equations.

That's it!

Monday, April 23, 2012

Working paper series: Carbon dioxide emission and environmental policies

Economists have been seeking accurate assessment of effective environmental policies in face of imminent threat of global warming partially resulted from carbon dioxide emissions. In practice, these policies can be classified into two categories: one is to encourage the use of zero emission or less emission production methods by utilizing renewable resources and to stimulate the development of environment-friendly technology, and the other one is to discourage or to punish the excessive carbon dioxide emissions.  (tbc)

Saturday, April 21, 2012

Lyx techniques and miscs

1. load natbib package in the presample

\usepackage[options]{natbib}

How to install a class file in Mac Lyx

Insufficient number of Mac users does not necessarily mean they do not use Mac version of Lyx.  Indeed, the documents like Lyx Wiki (http://wiki.lyx.org/FAQ/MacInstall) regarding Mac installation have many errors, which may hinder some beginners of Lyx user to install and apply a well-made customized layout file.  Here I am discussing some skills of the layout file installation on a Mac.

Generally, there are two steps.  First you have to deal with Latex, and then you should do some work on Lyx. 

1.  Copy the class into /usr/local/texlive/2011/texmf/tex/latex/
You will be promoted to provide the pass code of root access.  Some beginners may wonder how to enter this folder.  For those of you who have such question, please refer to my previous article (http://haoapec.blogspot.com/2012/04/to-install-and-apply-lyx-style-file-in.html)


2.  In terminal, type and run "sudo texhash"

3.  Now let's focus on Lyx.  Go to "Applications", right click "Lyx", and select "Show contents"

4. Navigate to "/Contents/Resources/layouts"

5. Copy your self-made layout file to here.  How to make this file?  Please refer to my previous article (http://haoapec.blogspot.com/2012/04/use-your-own-lyx-class.html)

6. Reconfigure Lyx and restart it. 

Finally you will be able to use this layout.




Use your own Lyx class

 From http://stefaanlippens.net/customLaTeXclassesinLyX

Sometimes, for example when writing an article for a conference, one need to use a custom LaTeX document class, recommended by the conference author guidelines. The procedure to make LyX using this custom document class is non obvious and a bit involved. It is broadly explained in the LyX manual (Part Customization, Chapter 5 Installing New Document Classes, Layouts, and Templates), but here is the short version (for teTeX on Linux or related systems, I don't know about Windows):

    Get the LaTeX document class file, e.g. funkyarticle.cls.
    Put this class file where LaTeX could find it. I use for example the directory ~/texmf/tex/latex/ in my own home directory (it has to be precisely the ~/texmf/tex/latex/ directory structure, otherwise it does not work). That way I don't have to mess with my system (for example in directories as /usr/share/texmf/tex/latex/) as administrator. This pages is more elaborate on installing custom LaTeX stuff
    Run texhash from the command line. This updates (La)TeX's database (it creates ls-R files, e.g. look at ~/texmf/ls-R).
    Make a LyX layout file matching the custom LaTeX class file, e.g. funkyarticle.layout. Put it where LyX can find it, e.g. in ~/.lyx/layouts/.

    The LyX layout file declares how LyX has to format your text (LyX does not use the LaTeX layout system and settings). A very minimal LyX layout file could be this: ((((

    #% Do not delete the line below; configure depends on this
    #  \DeclareLaTeXClass[funkyarticle]{article (funky)}
    
    # Input general definitions
    Input stdclass.inc

)))) just copy the materials within ((( and )))

    For conference articles I use for example something like
(((
    #% Do not delete the line below; configure depends on this
    #  \DeclareLaTeXClass[funkyarticle]{article (funky)}
    
    # Input general definitions
    Input stdclass.inc
    
    MaxCounter      Counter_Section
    
    Style Section
        Align Center
        Font
            Shape SmallCaps
        EndFont
    End
)))
    You can find more elaborate examples to base your layout file on in your global LyX layout directory (/usr/share/lyx/layouts/ in my case, search for *.layout files).

    The second line of the layout file is very important and has to be tailored to your particular case: in \DeclareLaTeXClass[foo]{bar} the foo refers to the LaTeX class file foo.cls and bar is how this class will be called in the LyX interface.
    Start LyX and choose "Edit" > "Reconfigure". Close Lyx.
    Restart LyX. Under "Layout" > "Document" > "Layout" > "Document class" the newly created LaTeX/LyX class should now be selectable (as "article (funky)" in our example)

Some usuful links regarding Mac Lyx

discussing some issues of mac installation:
http://wiki.lyx.org/FAQ/MacInstall

To install and apply a Lyx style-file in a mac

There are some ways to install and apply a style-file in a mac.

 Here
http://slavecache.blogspot.com/2010/09/installing-sty-files-for-latexlyx.html

"for the right directory to drop your files in. Under Mac the appropriate directory is

    /usr/local/texlive/2009/texmf/tex/latex/my_new_styles

Now run sudo texhash (or sudo mktexlsr or texconfig[-sys] rehash) and check with kpsewhich your_style_file if it worked.
LyX should be able to find your sty-files now. "

This website describes how to do it by using absolute path.  But for a mac beginner, he will be very hard to find that path.  We shall change to some other ways.

The following is what I usually use:

1. go to Macintosh HD/Library/Tex  (very easy to do this step)

2. click "root" to enter

3. click "texmf" to enter

4. click "tex" to enter

5. click "latex" to enter

But this is a root directory, which means you cannot make a sub-directory here

Thus we need to find other way out.

6. Go to any other folder rather than here,

7. make a new folder called "my_new_styles"

8. copy your style-file (*.sty) into this folder

9. copy this folder to the place where in step 5 you goes

10.  do "sudo mktexlsr " in terminal

11. reconfig Lyx and restart

Now you can use your new style-file.