R-bloggers

2012-09-27

New comet might blaze brighter than the full Moon

New comet might blaze brighter than the full Moon

2012-09-17

Great article in FT regarding QE3 and FX

A few words regarding the CFA Level I

Currently, I've been studying for the CFA. While the material, at least for Level I, is not hard to grasp, the sheer breadth of topics is daunting. It seems as though if you put in the time you'll grasp it. The trick is for you to 1) forget your social life, 2) Get comfy with your calculator, 3) Do all EOCs, Blue Boxes, QBank questions over and over again (there is no point only reading...). For the past month and half in which I went through the first reading, I have not been able to enjoy a day out (and I don't see myself relaxing anytime before December). Well, I guess this is what they call delayed gratification.

While I don't intend to inundate you with obscure trivia from the CFAI curriculum, I hope after I sit for the exam in December, I'll have the chance to write a few R scripts for the topics I found interesting like portfolio management, equity, and FI. Till then though, I guess I'll be writing about whatever catches my fancy.

On an aside, It seems this blog is in the nether reaches of the interwebz. So, if you are a human reading this: HELLO!

PS: Some weekend I'll sit down and finish the first series of R posts I intended to do. 

2012-09-15

A Useful Function for Sweave Users: Sweatex()

This function is courtesy of AC Davison at EPFL.

Here you go:
options(width=65, digits=7)
options(show.signif.stars=FALSE)
# ps.options(horizontal=FALSE)
set.seed(1234)

Sweatex <- function(filename,extension='Rnw',command='latex',silent=FALSE,preview=TRUE,bibtex=FALSE)
{  
        #check if latex path is present, otherwise adds it to current path for the GUI
        latex.path <- dirname(options('latexcmd')[[1]])
        path <- as.character(Sys.getenv("PATH"))
        if (regexpr(latex.path,path)==-1) {Sys.putenv("PATH"= paste(path,":",latex.path, sep=""))}

        if (command=='latex') command='simpdftex latex --maxpfb'
    extension<-paste('.',extension,sep='')
        Sweave(paste(filename,extension,sep=''))
    if (bibtex)
    {  # this does latex+bibtex+latex (if you need latex one more time, uncomment last row)
        system(paste(command,' ',filename,sep=''),intern=silent)
        system(paste('bibtex',' ',filename,sep=''),intern=silent)
        system(paste(command,' ',filename,sep=''),intern=silent)
        system(paste(command,' ',filename,sep=''),intern=silent)
    }
    else system(paste(command,' ',filename,sep=''),intern=silent)
        if (preview) 
        {
                system(paste(options('pdfviewer')[[1]],' ',filename,'.pdf',sep=''))
        }
            
}

2012-09-14

QE3 and ESM

Well, this week has been packed with "good" news. I say "good" because we can always see the negative consequences of policy decisions. Yet in this case, I hope the positive out weighs the negative.

QE3 will be underway. The Fed announced Thursday that the long-awaited and expected quantitative easing. Fed plans on $40 billion in open-ended purchases of mortgage backed securities. Three rounds of super open market operations. On the same day it was reported that initial claims data rose 15,000 to 382,000.

So in other words, cheap money (borrowing from the future at zero percent fed funds rate) and razor thin yields. I guess if anyone wants any sort of respectable return will purchase junk bonds (Invest in Egypt!).

I can't help but notice that most of the economic policy makers have studied extensively the Japanese crisis from the last decade. Of course, they popooed the actions of the Japanese Central Bank. I guess that is how the world turns.

In other news, the German Federal Constitutional Court ruled in favor of the rescue facility (ESM). Yet required that Germany retain some control. Meanwhile, Germany objected to the European Commission's proposal to grant the European Central Bank supervisory power over all eurozone banks.

We certainly live in crazy times...

Here is a Yahoo's economic calendar:
Economic Calendar

2012-09-05

CV/Resume LaTeX Template

The first script I compiled when I first began LaTeX was a CV/Resume. Probably because of the Ego. Yet it was a learning experience for the sole fact that when it came to my CV, I was quite exacting in my specification and this required me to learn new functions. Here is a modified "fun" copy of my CV for those interested. Nothing special.

This template was based on Laura Taalman's CV Template. I condensed my version more than Laura's template. There is also numerous other academic LaTeX template hosted at the link.


Rensselaer Career Development Center also hosts numerous resume templates.
Here is the compiled copy.

The script is below.
\documentclass[letterpaper]{article}
%\documentstyle[letterpaper]{article}
\oddsidemargin=-.15in
%\evensidemargin=.15in
\textwidth=6.65in
\topmargin=-1in
\textheight=10.5in
\parindent=0in

\usepackage{relsize}

\newenvironment{xitemize}{%
  \smaller
  \itemize
}{%
  \enditemize
}

\pagestyle{empty}

\begin{document}

\begin{center}
{\Large Mohamed~A.~Elgeneidy} \\[.5pc]
%(+20) 10.6663.9119 $\;$ elgeneidy\verb|@|gmail.com $\;$ Cairo, Egypt \\[3.5pc]
elgeneidy\verb|@|gmail.com \\ Cairo, Egypt \\[1.5pc]
\end{center}
{\large \bf Objective} \\*[-.8pc]
\underline{\hspace{6.65in}} \\
To collaborate and work within a dynamic team to drive social innovation and transformation in various fields including education, health, environment and enterprise development.\\
\\[0.5pc]
{\large \bf Education} \\*[-.8pc]
\underline{\hspace{6.65in}} \\
{\bf Bachelor of Science in Economics}\hfill \textit{2009-05}\\
Georgia Institute of Technology \\[0.5pc]
\\
{\large \bf Experience} \\*[-.8pc]
\underline{\hspace{6.65in}} \\
{\bf Senior Officer},
{\bf Awesome Inc} \hfill {\it 2010-01/present\/} \\
Being Laid Back.
Accomplishments:
\begin{itemize}\itemsep-1pt
%\item{Study and collection of data to determine standard and actual food cost processing including raw material purchases, inventory and output}
\item{Professional PES 2012 Player. Team of Choice: Bayern/Atletico}
\item{Gran Turismo Professional}
\item{Using Big Words Like Esoteric}
\item{Leading inter--departmental team to streamline recreation}
\end{itemize}      \\
\\
\\
{\bf Principal},
{\bf AMG--Quanticks} \hfill {\it 2010-01/2011-05\/} \\
Entrepreneurial venture for the advancement of market data delivery systems and
statistical analysis of equity markets in the MENA region. Project: Streaming server
for NASDAQ--OMX trading engine (EGX) to deliver real-time trading,
quotes and depth with algorithmic indices to client subscribers. \\
(Windows x64, MS Visual C++ 2008)\\*[0.1pc]
%Accomplishments:
%\begin{itemize}\itemsep-1pt
%\item{Developing low-latency market data server; designed to read once, feed a real-time queue and process the feed}
%\item{Building Level II book}
%\item{Exploring viability of microstructure models for equities listed on EGX}
%\item{Marketing \& business strategy}
\end{itemize}  \\
\\
{\bf Research Assistant},
{\bf Georgia Tech School of Industrial Engineering} \hfill {\it 2009-01/2009-12\/} \\
Bayesian multivariate extreme value thresholding; Environmental Risk Analysis\\
\\
{\bf Outreach Worker},
{\bf The Salvation Army Katrina Aid Today} \hfill {\it 2007-02/2007-12\/} \\
\\

\bigskip
{\large \bf Skills} \\*[-.8pc]
\underline{\hspace{6.65in}} \\
{\bf Professional Skills}
%\begin{description}\itemsep2pt
%\smaller\item[OS] MS Windows NT, XP, 7 %{\setlength\itemindent{25pt}
%\item[Software] Eclipse IDE, SQL, MS/Open Office
%\item[Scripting] R, \LaTeX, HTML
%\end{description}%
%\begin{table}[h]
\begin{flushleft}%flushleft
\begin{tabular}{l||c}
  % after \\: \hline or \cline{col1-col2} \cline{col3-col4} ...
%   & Good & Very Good & Excellent \\
%   \hline
  \bf{OS} & MS Windows NT, XP, 7\\
  \bf{Software} & SQL, MS Office Suite \\
%  \bf{Programming} & C \\
  \bf{Scripting} & R, LaTeX, HTML \\
\end{tabular}
\end{flushleft}
%\end{table}
\\
{\bf Language}\\
English/Arabic
\\
\\[0.5pc]
{\large \bf Miscellaneous} \\*[-.8pc]
\underline{\hspace{6.65in}} \\*[-1.5pc]
\begin{description}\itemsep2pt
\item[Activities] M\&M Mentoring Program (Mentor), Women's Leadership Conference, Economics Club, Organ Transplant \& Donation Initiative (OTDI)
\item[Honors] Dean's List (5x), OMED Towers Award (3x), Babcock \& Wilcox Scholarship, HOPE Scholarship
%\item[Technical Interests] Financial Econometrics, Data Structures

\item[Place of Birth] Cairo, Egypt
\item[Marital Status] Single
\item[Military Status] Postponed
\end{description}
\\
References available upon request

\end{document}

2012-09-04

Organ Transplantation Project/NGO + LaTeX survey/questionnaire script

Here is a survey script (courtesy of: svenhartenstein.de). I've been working with a group of physicians setting up a start-up NGO to raise awareness and research regarding organ transplantation in Egypt. This issue has societal and religious taboo, so we are treading lightly for the moment. Yet I believe this survey script may be of some use for others.

You'll find below the script and here is a compiled copy

If you are interested in the cause, or would like to help, here is the contact information:
Facebook: Organ Transplantation and Donation Inititive
Twitter: OTDI-Egypt
Email: otdieg@gmail.com
\documentclass[a4paper,10pt,BCOR10mm,oneside,headsepline]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage{wasysym}% provides \ocircle and \Box
\usepackage{enumitem}% easy control of topsep and leftmargin for lists
\usepackage{color}% used for background color
\usepackage{forloop}% used for \Qrating and \Qlines
\usepackage{ifthen}% used for \Qitem and \QItem
\usepackage{typearea}
\areaset{17cm}{26cm}
\setlength{\topmargin}{-1cm}
\usepackage{scrpage2}
\pagestyle{scrheadings}
\ihead{OTDI Transplant Questionnaire}
\ohead{\pagemark}
\chead{}
\cfoot{}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Beginning of questionnaire command definitions         %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% OTDI
%% Mohamed Elgeneidy
%% elgeneidy@gmail.com
%%
%% Please be warned that this is NOT a full-featured framework for
%% creating (all sorts of) questionnaires. Rather, it is a small
%% collection of LaTeX commands that I found useful when creating a
%% questionnaire. Feel free to copy and adjust any parts you like.
%% Most probably, you will want to change the commands, so that they
%% fit your taste.
%%
%% Also note that I am not a LaTeX expert! Things can very likely be
%% done much more elegant than I was able to. If you have suggestions
%% about what can be done better please send me an email.

%% \Qq = Questionaire question. Oh, this is just too simple. It helps
%% making it easy to globally change the appearance of questions.
\newcommand{\Qq}[1]{\textbf{#1}}

%% \QO = Circle or box to be ticked. Used both by direct call and by
%% \Qrating and \Qlist.
\newcommand{\QO}{$\Box$}% or: $\ocircle$

%% \Qrating = Automatically create a rating scale with NUM steps, like
%% this: 0--0--0--0--0.
\newcounter{qr}
\newcommand{\Qrating}[1]{\QO\forloop{qr}{1}{\value{qr} < #1}{---\QO}}

%% \Qline = Again, this is very simple. It helps setting the line
%% thickness globally. Used both by direct call and by \Qlines.
\newcommand{\Qline}[1]{\rule{#1}{0.6pt}}

%% \Qlines = Insert NUM lines with width=\linewith. You can change the
%% \vskip value to adjust the spacing.
\newcounter{ql}
\newcommand{\Qlines}[1]{\forloop{ql}{0}{\value{ql}<#1}{\vskip0em\Qline{\linewidth}}}

%% \Qlist = This is an environment very similar to itemize but with
%% \QO in front of each list item. Useful for classical multiple
%% choice. Change leftmargin and topsep accourding to your taste.
\newenvironment{Qlist}{%
  \renewcommand{\labelitemi}{\QO}
  \begin{itemize}[leftmargin=1.5em,topsep=-.5em]
}{%
  \end{itemize}
}

%% \Qtab = A "tabulator simulation". The first argument is the
%% distance from the left margin. The second argument is content which
%% is indented within the current row.
\newlength{\qt}
\newcommand{\Qtab}[2]{
  \setlength{\qt}{\linewidth}
  \addtolength{\qt}{-#1}
  \hfill\parbox[t]{\qt}{\raggedright #2}
}

%% \Qitem = Item with automatic numbering. The first optional argument
%% can be used to create sub-items like 2a, 2b, 2c, ... The item
%% number is increased if the first argument is omitted or equals 'a'.
%% You will have to adjust this if you prefer a different numbering
%% scheme. Adjust topsep and leftmargin as needed.
\newcounter{itemnummer}
\newcommand{\Qitem}[2][]{% #1 optional, #2 notwendig
  \ifthenelse{\equal{#1}{}}{\stepcounter{itemnummer}}{}
  \ifthenelse{\equal{#1}{a}}{\stepcounter{itemnummer}}{}
  \begin{enumerate}[topsep=2pt,leftmargin=2.8em]
  \item[\textbf{\arabic{itemnummer}#1.}] #2
  \end{enumerate}
}

%% \QItem = Like \Qitem but with alternating background color. This
%% might be error prone as I hard-coded some lengths (-5.25pt and
%% -3pt)! I do not yet understand why I need them.
\definecolor{bgodd}{rgb}{0.8,0.8,0.8}
\definecolor{bgeven}{rgb}{0.9,0.9,0.9}
\newcounter{itemoddeven}
\newlength{\gb}
\newcommand{\QItem}[2][]{% #1 optional, #2 notwendig
  \setlength{\gb}{\linewidth}
  \addtolength{\gb}{-5.25pt}
  \ifthenelse{\equal{\value{itemoddeven}}{0}}{%
    \noindent\colorbox{bgeven}{\hskip-3pt\begin{minipage}{\gb}\Qitem[#1]{#2}\end{minipage}}%
    \stepcounter{itemoddeven}%
  }{%
    \noindent\colorbox{bgodd}{\hskip-3pt\begin{minipage}{\gb}\Qitem[#1]{#2}\end{minipage}}%
    \setcounter{itemoddeven}{0}%
  }
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% End of questionnaire command definitions               %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\begin{center}
  \textbf{\huge OTDI Transplant Questionnaire}
\end{center}\vskip1em

\noindent This form is voluntary. You may ignore it, complete parts of it, or
fill it out fully. It is inteded solely for assessing professional opinion with
regard to organ donation in Egypt.
\\
\Qitem{ \Qq{Professional speciality}: \Qline{8cm} }

\Qitem{ \Qq{Age:} \Qline{1.5cm}}
\section*{Questionnaire}

%%\Qitem{ \Qq{Rate your knowledge of the criteria of brain death diagnosis? (i.e.: testing for brain stem reflexes, methods to demonstrate absence of breathing, etc.)}

\Qitem{ \Qq{Rate your knowledge of the criteria of brain death diagnosis. (i.e., testing for brain stem reflexes, methods to demonstrate absence of breathing, etc.)} \\ \Qtab{3cm}{no prior knowledge \Qrating{5} expert knowledge}}
\Qitem{ \Qq{Are you aware of the differences between the diagnosis of brain stem death and whole brain death?} \Qtab{1.5cm}{\QO{} Yes
    \hskip0.5cm \QO{} No}}

\Qitem{ \Qq{Do you diagnose brain death in your clinical practice?}
\Qtab{5.5cm}{\QO{} Yes \hskip0.5cm \QO{} No}}

\Qitem{ \Qq{If yes, how many do you diagnose per month?}\hskip0.5cm\Qline{1.5cm}}


\Qitem{ \Qq{Are you aware of current laws regarding organ transplants in Egypt (e.g., 2010:leg.5)?} \Qtab{5.5cm}{\QO{} Yes
    \hskip0.5cm \QO{} No}}

\Qitem{ \Qq{Do you think an Egyptian organ transplant system is feasible in the near future?} \Qtab{5.5cm}{\QO{} Yes
    \hskip0.5cm \QO{} No}}
    
\Qitem{ \Qq{In your professional opinion, what is the greatest obstacle for the development of transplant network in Egypt? (Check all that apply)}
  \begin{Qlist}
  \item Poverty
  \item Lack of education
  \item Religious beliefs
  \item Technical limitations
%  \item Organizational limitations
  \item Organ trade
  \item Other: \Qline{4cm}
  \end{Qlist}
}

\Qitem{ \Qq{According to your personal religious beliefs, do you support organ donation and transplantation?} \Qtab{2cm}{\QO{} Yes \hskip0.5cm \QO{} No \hskip0.5cm \QO{} I don't know}}

\Qitem{ \Qq{How would you rate your level of interest in working with a transplant team?} \\ \Qtab{3cm}{none \Qrating{5} eager}}

\Qitem{ \Qq{Are you willing to receive tranplant treatment if circumstance warranted?} \Qtab{5.5cm}{\QO{} Yes
    \hskip0.5cm \QO{} No}}
    
\Qitem{ \Qq{How would you rate your attitude towards donating your own organs?}
\\ \Qtab{3cm}{never \Qrating{5} under any circumstances}}

\Qitem{ \Qq{According to your professional opinion, would you advise individuals to include organ donation in their living will?}
\Qtab{5.5cm}{\QO{} Yes \hskip0.5cm \QO{} No}}


\Qitem{ \Qq{In your personal opionion, who would be an ideal candidate for organ donation? (Check all that apply)}
  \begin{Qlist}
  \item Live Donor
  \item Cadaver
  \item Brain dead individual on supportive treatment
  \item Other: \Qline{4cm}
  \end{Qlist}
}

\section*{For more information}
If you are interested in receiving updates in the future regarding OTDI's campaign, please fill the form below: \\
\\
\bf{Name:}  \Qline{5.5cm}} \\
\bf{Phone:} \Qline{5.5cm}} \\
\bf{Email:} \Qline{5.5cm}}
\newpage

\section*{About OTDI}
%\textit{Organ Transplant and Donation Initiative (OTDI) is a non-profit startup aimed at building scientific and community dialog in Egypt. Started by a group of young physicians and professionals who are keen on building both policy and technical infrastructure needed for a broad ranged transplant network in Egypt, OTDI's mission is to provide a continuous initiative towards the advocacy of organ transplantation and donation; aimed at both increasing the awareness of the general public and offering up to date scientific opportunities for those involved in the field.}
%Organ Transplant and Donation Initiative (OTDI) is a non-profit startup aimed at building scientific and community dialog in Egypt. Started by a group of young physicians and professionals who are keen on building both policy and technical infrastructure needed for a broad ranged transplant network in Egypt, OTDI's mission is to provide a continuous initiative towards the advocacy of organ transplantation and donation; aimed at both increasing the awareness of the general public and offering up to date scientific opportunities for those involved in the field.
\minisec{What is OTDI?}
\textit{Started by a group of young physicians and professionals, the Organ
Transplantation and Donation Initiative (OTDI) is a non-profit initiative
aiming to raise awareness about, and advocate for, organ donation and
transplantation in Egypt.}
\minisec{Our Vision}
\textit{Save the lives of thousands of Egyptians through organ donation and transplantation.}
\minisec{Our Mission}
\textit{Provide a continuous initiative towards the advocacy of organ transplantation
and donation; aiming at both increasing the awareness of the general public and
offering up to date scientific opportunities for those involved in the field.}
\minisec{Our Goals}
\begin{itemize}\itemsep-1pt
\item{\textit{\textbf{Advocate for organ donation and the new transplant law}}}
\item{\textit{\textbf{Combat the stigma accompanying this controversial issue}}}
\item{\textit{\textbf{Provide opportunities for interns and residents in the transplant field}}}
\item{\textit{\textbf{Raise funds for the cause}}}
\item{\textit{\textbf{Set up a sustainable system that will continue serving the cause}}}
\end{itemize}
\minisec{Contact us}
\vskip.5em
Find us on Facebook: {\bf Organ Transplantation and Donation Initiative}\\
Follow us on Twitter: OTDI-Egypt\\
Email us: otdieg@gmail.com\\
%Organ Transplantation and Donation Initiative  \\
%c/o Newly Incubated Social Enterprises, Nahdet El Mahrousa\\
%17 Qasr El Nil Street, Downtown\\
%Cairo, Egypt\\
%Phone: [DECIDE ON THE PHONE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!]

\end{document}