Thursday, December 31, 2009

People's processor

This article talks about China's homegrown CPU, Loongson (dragon chip).

Using Stata with a make file

This blog describes how to run Stata via make files.

This one describes how to use make with LaTeX.

Wednesday, December 30, 2009

Interesting Chinese blog

This Chinese blog is really interesting.

Tuesday, December 29, 2009


RGedit is A plugin for Gedit to run R script.

Something about cloud computing

Here are some helpful discussions on cloud computing, with special emphasis on statistical computing.

Saturday, December 26, 2009

Adding margin note

To add a margin note to a LaTeX document, on can use:
\marginnote{This is a margin note here.}

Monday, December 21, 2009

EpiData, now runs on Linux

EpiData is something I used long time ago for data entry. It was a Windows-only application at the time. Now it has evolved into a multi-platform application, which got my attention again.


This R packages estimates Generalised Linear Mixed Models via MCMC. It provides a number of random error distributions and can be used for multivariate multilevel models (simultaneous equation model).

I will do some tests and compare the results to other packages.

This package has the potential to become the ideal modeling tool for multilevel and multiprocess analysis for Bayesians, just as aML and Sabre for non-Bayesians. I have been hoping the new JAGS can have much improved performance with similar models, but I don't know when the new version (2.0) will be out. I will be interesting to conduct a benchmark test between aML, Sabre, GLLAMM, MCMCglmm, WinBUGS, and JAGS on some complicated multilevel multiprocess statistical models.

Unlike aML and Sabre, MCMCglmm seems to be under active development.

Tuesday, December 15, 2009

6 Different Ways To End Unresponsive Programs In Linux

This article explains how to deal with non-responding programs under Linux. As always, there is more than one way to do it.

Monday, December 14, 2009

A course worthing taking

This Bayesian statistics course seems worth taking.

Random effect logistic model using WinBUGS

Here is an example.

Friday, December 11, 2009

After the Software Wars

This is a really good book, and it is available as a free PDF download.

Thursday, December 10, 2009

Monkey's uncle

This is an interesting blog with information on R, LaTeX, etc.

Demography package

This package seems useful for demographers.

A new demography journal

The Open Demography Journal.


Looks like a minor bug fix release of JAGS is out. I wonder whether the planned new major release will have some facilities to handle skewed distributions.

Wednesday, December 09, 2009

OpenMx with mixture distribution support

A new version of OpenMx is out; this time it comes with mixture distribution, according to this announcement. I can't wait to test the new features out!

Tuesday, December 08, 2009

Chrome for Linux (beta) is out

I wonder why it took so long.


I was finally able to get Sciviews (most of it) work on my Linux machine. As before, I got some error message when opening the R terminal for the first time; by ignoring the error messages and manually install several "sv" packages locally (into my home directory), I was able to get Komodo Edit to communicate with R. But the unit test part of the package still does not work.

I mainly use Emacs (via ESS) with R, but sometimes it seems to be more convenient to have a dedicated window open for R instead of a buffer. It is less important on my new Workstation which with screen resolution of 1920*1200, but old habits die hard.

By the way, ESS has been updating like crazy in the past couple of days, from 5.6 to 5.7, then to 5.71.

By the way, I wish Sciviews can have syntax highlighting for BUGS programs.

Monday, December 07, 2009

Math in OpenOffice

OpenOffice Wiki has a section showing all the math commands.

Saturday, December 05, 2009

Linux on flash drive

If I don't want to carry my Linux mobile workstation around, I can order one of those Linux flash drives.

The animation package

The "animation" package is a good teaching tool to demonstrate some key concepts in a introductory statistics course.

Two more R related web sites

  1. R bloggers
  2. Free statistics e-books
  3. Planet R

Advances in Social Science Research Using R

This seems to be a book worth buying:

It will come out in May 2010.

Cool photo gallary: operating systems

Friday, December 04, 2009

R information

Thursday, December 03, 2009

Initialize ubuntu packages

I did not know this before:


I gave R2admb a test run and found it quite promising. The design is simple: to have a simple interface between R and ADMB so ADMB can get input from R and can send output back to R for further processing. This does not eliminate the trouble of writing a TPL file, but makes everything else much simpler. I hope this package gets polished and get into CRAN soon. I am sure it will help more people to get to know ADMB in the same way as R2WinBUGS help people use WinBUGS and R2jags help people use JAGS.

Wednesday, December 02, 2009

Get the right Linux driver for my Brother printer

I've been having trouble with my Brother HL-5370DW. It prints fine under windows but not under Linux. Eventually I figured out how to solve the problem:
  1. Get the right driver from the Brother driver page:
  2. Download the PPD file instead of any binary files
  3. Feed the PPD file into the system
And how it works flawlessly.

Another benchmark test: Ubuntu vs. FreeBSD vs. OpenSolaris

Tuesday, December 01, 2009

Parallel BUGS

Monday, November 30, 2009

Version control system inside Emacs

Emacs works with version control.

Here is something for using Git inside Emacs:

OpenMX, again

With help from Michael Spiegel, the lead developer of OpenMX, I was able to get it compiled and installed on my 64-bit Ubuntu system. Now it runs beautifully.


to synchronize between different computers:


It seems to be something I am looking for: an interface between R and C for Bayesian analysis.

Another juicy programming story

Sunday, November 29, 2009

Silly mistake

I was trying to run and debug a Fortran program within Emacs. Strangely, GDB refused to run and Emacs kept giving me error messages. I figured there might some comparabilities between gfortran, gdb, and emacs and spent quite some time trying to figure out. Finally, it turns out to be a problem with my directory name: Emacs's gdb mode cannot handle directories with spaces in their names.

Now I know.

Portable Ubuntu

Looks interesting:

Can't get the GDB plug-in for Geany to work

I have trouble to get Geany's GDB plug-in to work smoothly. For this, Emacs definitely wins.

Linux editor


Another TeX/LaTeX journal:

Saturday, November 28, 2009

TeX Daemon

This little TeX tool seems interesting:

Friday, November 27, 2009

I like the new Stata web site

much better than the earlier one.

PBSadmb for R

This package bridges ADMB and R. It was once Windows-only and now has matured and become platform-independent. I will check it out and comment more about it.

And here is yet another R to ADMB interface:

Thursday, November 26, 2009

This is also very neat: GDB inside Emacs

ECB with Emacs

The ECB package for Emacs seems useful. Here is a screenshot.

Different ways to setup Emacs window size

Wednesday, November 25, 2009

Coders at Work: Reflections on the Craft of Programming

by Peter Seibel. Really cool book, helpful to even the non-programmers.

Various wasy to improve the "compile" command in Emacs

Tuesday, November 24, 2009

LaTeX to HTML solution

The best solution seems to be TeX4ht.

It converts a manuscript I am working on flawlessly, including tables (using the booktabs package). Wow...

A good introduction of Linux/Unix to students

If I want to teach a class on data analysis using R/Emacs/Linux, I can simply refer students to this site.

Friday, November 20, 2009

Geany and LaTeX

I just realized that Geany can handle LaTeX really well.

Nobel Peace Prize to Linus Torvalds

It makes sense to me.

Another Ubuntu review

This long review ( made several good points.

Thursday, November 19, 2009

Zim: a desktop wiki

Zim is appealing, part because its built-in LaTeX-based equation editor. It is suitable for everyday writing: sorting ideas, recording references, etc.

Here is the most recent version:

Some good Ubuntu tips

Tuesday, November 17, 2009

2009 ranking of sociology deparment

Don't know how meaningful it is:

Sunday, November 15, 2009


Looks promising:

Right now it cannot be build from source because there are some comparabilities between OpenMx and R 2.10.0, but I assume this will be resolved soon.

And the development seems to be quite active.

Saturday, November 14, 2009

Virtual machine

With 8 GB ram and fast core2 extreme processor, it is natural to have a Linux hosting Windows virtual machines on my Precision mobile workstation so I don't have to book back to Windows whenever I need to work with my colleagues using Word. There are several alternatives such as VMware, VirtualBox. It is worthwhile to try them out.

Wow, this is hard to believe

Thursday, November 12, 2009

Numeric library for Mono

Looks promising:

Tuesday, November 10, 2009

MCMC in Python

The Python library "PyMC" looks promising ( Also, here are some demos:

This is convinient

Negative reviews of Ubuntu 9.10

I myself did not experience any of the problems. Everything works flawlessly on my Precision M4400, even the webcam!


The idea of creating an IDE for ADMB is great. The currently one, which is based on Emacs, works well out-of-the-box. For a new Emacs user, it is great - the IDE has been tweaked in the way people who are not used to Emacs key binding can use immediately. But for people who use Emacs on daily basis, and have a long .emacs file, the idea of making heavy changes on the Emacs configuration file (key bindings, etc.) might not be that attractive.

A better solution will be to offer three different sets of configuration files: the one is for completely Emacs newcomers, the second one is for people who have some familiarity with Emacs but are willing to make some changes to their work habit, the third is for those diehard Emacs user who only want a syntax highlighting and maybe a key binding for compiling a .tpl file.

Nov. 19:

Well, it turns out that the "minimal IDE" I was talking about is already there: the ADMB Emacs editing mode. Simply put this file in the include directory and put two lines in the .emacs file, it works like charm. All other customizations are entirely optional. This seems to be a perfect solution.


It is Nov. 10 now and the Photran web site is stilling saying that the new version will be made available by the end of Oct.

Monday, November 09, 2009

Good examaples for copy via ssh

R package for sequence analysis

Saturday, November 07, 2009

ssh with X11

I don't have Stata installed on my new 64-bit machine so I need to use the copy on my older machine via ssh. The simple command of "ssh -X" does the trick!

Friday, November 06, 2009

Why Linux does not need a disk defragmenter?

This is by far the most intuitive discussion I found:

Good tips on Emacs

Thursday, November 05, 2009

Winbugs 1.4 works really well under Ubunti 9.10 64-bit

via Wine. I had trouble getting it running on my 32-bit Ubuntu 9.04 box. I am quite pleased.

After adding ""/home/shige/bin/WinBUGS14/", program="WinBUGS", useWINE=TRUE" to each BUGS call using R2WinBUGS, I was able to run the radon example provided in Gelmam's book.

Wednesday, November 04, 2009

Scivews-K got updated again

With the recent update, I was able to get it working properly.

Interestingly, while it works on my Vista 64-bit, it does not work on my Ubuntu 64-bit. I have no idea what is going on.

64-bit aML

I was able to compile and run aML under 64-bit Ubuntu 9.10. The only problem was "maktab", so I replaced my binary with the one supplied by the official web site. I will do some benchmark and see if these binaries are faster.

Tuesday, November 03, 2009

Advances in Statistical Methods for the Health Sciences

A useful book

Friday, October 30, 2009

Inkscape is a handy tool

Inkscape ( is a free software package for graphics. It reads a large number of graphics formats including eps and pdf, and allows one to modify them and output to a large number of different graphics formats.

Thursday, October 29, 2009

Simple R figures

This comes very handy.

Wednesday, October 28, 2009

Another bayesian book

Bayesian Methods for Data Analysis, Third Edition:

Tuesday, October 27, 2009

Using the "foreign" package for data conversion

I was in a rush to convert a SPSS data into Stata format. Somehow my Stattransfer v.8 for Linux was lost and I did not want pause my work and go back to Windows just to get this one file converted. So fire Emacs+ESS+R, load the "foreign" package, did the file conversion, and it worked!

Literate programming, etc.

Monday, October 26, 2009

Ecological Models and Data in R

Seems to be a good book.

Sunday, October 25, 2009

Skewed distribution coded using WBdev

I have not found similar functions in JAGS

An easy way to get additional distribution in BUGS and JAGS

Also, it seems that the JAGS development is moving right along:

Skewed multivariate distribution

This research has done some research on this topic:


Some of the statements are no longer true (e.g. ADMB being not free), but the overall arguments seem fair.

Work without X

Friday, October 23, 2009

Scivews-K got updated

The problem is, I cannot get it to work, on either Windows or Linux.

Some more Chinese materials...

A Chinese article...

Thursday, October 22, 2009

Here are some Bugs code for joint modeling

Statistical computing matters

Wednesday, October 21, 2009

InferenceR looks interesting

I obtained a free academic copy of the InferenceR, which is a R IDE for Windows. I has several interesting features such as a visual debugger. It is definitely worth some further exploration. Of course, the problem (and the only problem for now) is that it is Windows-only, cannot run it on Linux.

Lots of maps using R

Very helpful!

Tuesday, October 20, 2009

Editing while running R within Emacs

Simply press "Ctrl + g" will return the control back to the user.

Running JAGS via R2jags

I finally figure out how to run WinBUGS examples in JAGS via R2jags. JAGS is preferred over WinBUGS for its cross-platform compatibility and performance (it was written in C++).

Friday, October 16, 2009

Syntax for

" -otld -c file.Rnw" will compile the Rnw file, create a PDF file, and open it automatically.

The optimal way to do sweave

The optimal way to do sweave may be to have a master file in LaTeX, and a separate Rnw file contains all the computations, figures, and tables. That way, it is easy to compile the LaTeX as the writing goes on without the hassle of carrying out the computations (especially when some of them are heavy) every time.

When the computations are finished, one can simply include the generated LaTeX output in the master LaTeX file to get the complete manuscript. Here are the files:
  1. master.tex: the master LaTeX file that contains text materials of a paper;
  2. tables.Rnw: the sweave file for creating all the tables;
  3. tables.tex: the LaTeX output file that can be included in the master file;
  4. figure.Rnw: the sweave file for creating all the figures;
  5. figure.tex: the LaTeX output file that can be included in the master file;
  6. driver.tex: a simple LaTeX driver to view the tables and figures before including them into the master LaTeX file.

Thursday, October 08, 2009

Stata teaching demo

This is where all the Stata teaching demos:

Maple 13

I just realized that CUNY has site license of Maple 13. Good choice, CUNY!

Sunday, September 20, 2009

Childhood obesity

It has been fun to work on the childhood obesity stuff again! We'll see how the grant goes.

Thursday, September 17, 2009

Models for Discrete Longitudinal Data

Free e-book:

Another bayesian book

Spiegelhalter, D., Best, N., Lunn, D. and Thomas, A. (2009) Bayesian Analysis using the BUGS language: A Practical Introduction, Chapman and Hall

Also, the online materials for "Bayesian Modeling Using WinBUGS" books keeps expanding:

Sunday, September 06, 2009

Reading and writing data using Python

Saturday, September 05, 2009

Why do we focus on individuals?

Here is the answer offered by Kenny et al. (2006):

"...First, no doubt much of the attention given to the individual is cultural. The United States is the most individualistic country in the world (Smith & Bond, 1994), and because the United States has dominated social and behavioral research, the prevalence of research concerning individuals is hardly surprising.

A second factor that has contributed to this individualistic orientation is the reliance on standard statistical methods such as analysis of variance (ANOVA) and multiple regression...

The third reason is that psychologists have dominated research in the social and behavioral sciences ..."

Very interesting book:

Kenny, D. A., D. A. Kashy, and W. L. Cook. 2006. Dyadic data analysis. New York, NY: The Guilford Press.

Sunday, August 30, 2009

Saturday, August 29, 2009


An online LaTeX processing system and document repository:

I got the information from this post:

Friday, August 28, 2009

'R' programming

Sunday, August 23, 2009

Saturday, August 22, 2009

NpptoR: R in Notepad++

For those who are scared of Emacs:

Sunday, August 16, 2009

Reproducible Research

This is an important topic for scientists of all disciplines and deserves more attention among social scientists.

GTD: getting things done


Saturday, August 15, 2009


Ubuntuzilla, works like a charm:

Latex for Undergraduates

Useful web site:

High tech, low tech?

Interesting article:

Thursday, August 13, 2009

Workflow applications


Git + Emacs

Thursday, August 06, 2009


I finally figured out how to use the R package "cachesweave". The trick is that the code chunks must follow some order, like the following:


Reshaping data

This post ( explains how to "reshape" data in R using the reshape package. It not only can do what the reshape command in Stata does (the "melt" step), but also a step further (the "cast" step). Quite amazing.

Making LaTeX tables using R, more options

A new package named "estout":

Wednesday, August 05, 2009

Apple may just be worse than Microsoft


Report tool

The R package "reporttools" looks promising. It generate various kinds of descriptive tables, including two-way tabulations, in LaTeX that is suitable for directly inserting into a Sweave document.


The PIDA project ( represents an interesting approach toward Python IDE. It builds upon either VIM or Emacs (my editor of choice) and tries to make Python specific programming easier.

VoIP for blackberry

I am having hard time finding a good VoIP application for my blackberry. Skype does not have one, TruePhone's BB version does not support WIFI, neither does Nimbus. Should have bought an Android instead (really don't like Apple stuff).

Tuesday, August 04, 2009

A R-based course

The foundations of statistics: A simulation-based approach

A complete book with the source code (Sweave) on-line:

Creating maps in R

Saturday, July 25, 2009

Useful information

Work with the cachSweave package

This blog explains how to work with the R package "cacheSweave" to save time by forgo some of the time consuming computations while using Sweave:

Thursday, July 23, 2009

Microsoft contributed code to GPL

Tuesday, June 30, 2009

Endnote and Openoffice

The new Endnote (X3) supports Openoffice. This is a positive development.

Sunday, June 28, 2009

Graph with two axes

In R:

In Stata:

Also, R package "plotrix" has a function "twoord.plot" designed specifically for this.

Friday, June 26, 2009

New releases

While waiting for R 2.9.1, I saw the release notes for Stata 11.

Google scholar search

This google scholar search of "shared latent variable random effects" yields some interesting results.

Monday, June 22, 2009


SabreR consists three components: a Sabre binary, a R wrapper that communicate with the binary file (input and output), and a short R function to print the output.

The developer of SabreR wrote the wrapper in the somewhat unconventional way, which makes table making and simulation difficult.

Saturday, June 20, 2009

Statistical simulation

Chapter 7 of Data Analysis Using Regression and Multilevel/Hierarchical Models by Gelman and Hill offers good description of why use statistical simulation in quantitative research. Their R package ARM provides a good place to get started to program one's own simulation module. Of course, Zelig has already had a impressive collection of models pre-programmed; but custom programming is always more fun.

Thursday, June 11, 2009

Table making in R

Both MEMISC and APSRTABLE can automatically generate publication-quality tables from estimated models in R.

In addition, MEMISC also provides infrastructure for survey data analysis.

Monday, June 08, 2009

Thank Apple for the Linux 'desktop'


Looks like the author of Apophenia library finally fixed the compilation problem under Ubuntu 9.04.

Thursday, June 04, 2009

Interesting article

Wednesday, June 03, 2009

CVS repository for Emacs

The CVS repository for Emacs seems to be broken during the past couple of days. Don't know what is going on there.


An Emacs-based IDE for ADMB:

Sunday, May 31, 2009

Asus and its netbooks, with interesting comments

The comments are really interesting. I have always wondered why Asus chose Xandros instead of Ubuntu for its netbook. Now there seems to be a clue.

Modeling Demographic Processes In Marked Populations

A good book, with quite some Bayesian-related information:

Saturday, May 30, 2009

Low cost Linux desktop

Synchonize Linux laptop and desktop

Useful tips:

Sharing monitor, keyboard, mouse, etc.

It seems that, with the help of this small gadget (, two computers can share all the peripherals.

Thursday, May 28, 2009

Sabre and SabreR

I discovered another multilevel multiprocess software, Sabre (and its R implementation SabreR). It seems to be very efficient and well integrated with R. It is also possible to run it (a parallel version) on a cluster. Looks very promising. I should be able to use it for serious exploration in a day or two.

Unlike aML, Sabre is still under active development, which means that new features, such as more finite mixture modeling capability, hopefully may be incorporated into future releases.

Home page:

Wednesday, May 27, 2009

R2jags is really cool

The package "R2jags" is really cool. Now with JAGS, it is possible to do everything about Bayesian analsys on Linux the same way as on Windows.

Tuesday, May 19, 2009

Another blah blah blah

Just another guy who claims that Linux is not ready:

Monday, May 18, 2009

Access blocked

Access to blogspot in China seems to be blocked again.

Friday, May 15, 2009

More screenshots

My old Ubuntu 8.04 does not look too shabby either :)

Wednesday, May 13, 2009

My desktop

Pretty cool, isn't it?

Tuesday, May 12, 2009

Hibernation and suspension

I am glad to find out that both hibernation and suspension works perfectly on my Sony laptop using Ubuntu 9.04. This is a BIG improvement.

Sunday, May 10, 2009

Upgrading to OpenOffice 3.1

Friday, May 08, 2009

Ubuntu and scim

Build CVS Emacs

  1. cvs -z3 co emacs
  2. ./configure --with-x-toolkit --with-xft

Intel Fortran and aML

I am happy to discover that aML can be successfully compiled on Ubuntu using the non-commercial Intel Fortran compiler v.11.

Wednesday, May 06, 2009

Bayesian materials

Friday, April 17, 2009

Poster using LaTeX

This is the style I like:

Linux on laptop

This article compares performance & experience of five Linux distros on laptop and picks Mint as the best one:

Playing .ape music under Linux

I am pleasantly surprised to find out that Mplayer can play .ape format music.

Monday, April 13, 2009

Rjags on 64-bit Linux

Use this: install.packages("rjags",configure.args="--with-jags-lib=/usr/local/lib")

Sunday, April 12, 2009

Best introduction to Bayesian statistics

Chapter 3 of Scott Lynch's book "Introduction to applied Bayesian statistics and estimation for social scientists" is the best introductory materials of the Bayesian statistics.


Here is a helpful post:

Saturday, April 11, 2009

Rebuild R libraries for the new version

After upgrading to a new version of R, type "update.packages(checkBuilt =TRUE, ask=FALSE)" to rebuild all the libraries currently present in the system.
To install from Gary King's repository, just type "install.packages("Zelig", repos = "")"

To build R, use "./configure --enable-R-shlib" or

./configure --enable-R-shlib CXXFLAGS="-g -O3" CFLAGS="-g -O3"
./configure --enable-R-shlib  --with-blas="-lptf77blas -lpthread -latlas" CXXFLAGS="-g -O3"

With OpenBLAS:

./configure --enable-R-shlib  --with-blas="-lpthread -lopenblas" CXXFLAGS="-g -O3"

Or with Intel MKL:

./configure --enable-R-shlib --enable-threads=posix --with-lapack --with-blas="-I$MKLROOT/include -L$MKLROOT/lib/intel64 -lmkl_gf_lp64 -lmkl_gnu_thread -lmkl_lapack -lmkl_core -liomp5 -lpthread" CXXFLAGS="-g -O3"

In case R cannot find the tcltk files, use this " ./configure --enable-R-shlib --with-tcl-config=/usr/lib/tcl8.5/ --with-tk-config=/usr/lib/tk8.5/". This suddenly became necessary when I tried to compile the release candidate version of R 2.14 today. The solution was provided by this blog post.

This may yield even better results: ./configure --enable-R-shlib --with-tcl-config=/usr/lib/tcl8.5/ --with-tk-config=/usr/lib/tk8.5/ --with-blas="-lptf77blas -lpthread -latlas"

To fulfill build dependency, use "sudo apt-get build-dep r-cran-rgl"





MKL=" -L${MKL_LIB_PATH}   -L${OMP_LIB_PATH} -Wl,--start-group -lmkl_gf_lp64 -lmkl_intel_thread -lmkl_core -Wl,--end-group -liomp5 -lpthread"

./configure --enable-R-shlib --enable-threads=posix --with-blas="$MKL" --with-lapack CXXFLAGS="-g -O3"

Thursday, April 09, 2009

Open source mind mapping

Mind mapping is an important part of research. As far I know, there are two open source options: freemind and xmind. I use both but prefer xmind because it is built on the Eclipse framework and is more elegant than freemind at the moment. If I need more functionalities such as exporting to Word or Powerpoint, I can upgrade to the professional edition with less than $50 per year.

I chose to install it on top my existing Eclipse instead of using the .deb binary file so that I do not have to leave Eclipse just for mind mapping.

Thursday, April 02, 2009

Sams Teach Yourself Emacs in 24 Hours

Good reference for Emacs.

Tuesday, March 31, 2009


Linux Mint is the by far the best Linux distro I have ever tried. It is based on Ubuntu but much polished. After trying Mint, I don't think I will come back to Ubuntu.

Saturday, March 28, 2009

Linux text editors

I finally realized that I need only two text editors under Linux: Emacs for writing LaTeX and programming and MadEdit for anything else.

Friday, March 27, 2009

Looking forward to Jaunty

After several distro upgrades, my Ubuntu installation looks a little unstable. Now, one month away from the release of Januty, my Ubuntu suddenly sopped working on my laptop. This makes it easy for me to decide between "fresh install" and "upgrade" this time.

Monday, March 23, 2009

Differential mortality

differential mortality, methodological issues and biosocial factors

Thursday, March 19, 2009


The new version of LatentGold provides a command line interface. I found the syntax is quite intuitive and easy to learn. The fact that it also has a data viewer/editor is also an advantage, compared to Mplus.

Wednesday, March 18, 2009

Useful Ubuntu tools

Tuesday, March 17, 2009

JAGS guide

Monday, March 16, 2009


Looks interesting:

Sunday, March 15, 2009


I ordered a new thinkpad about a month ago and I leave LA for Beijing next week. I have to cancel the order if I cannot get it before I leave. That is a lose-lose situation for both Lenovo and myself.

Thursday, March 12, 2009

NoteExpress, again

The NoteExpress developer graciously offered me a free license in exchange for suggestions for further improvements. I will prepare a rather detailed report of the kind of problems I encountered in the process preparing my latest manuscript.

Sunday, March 01, 2009


A good bibliography software. As far as I can tell, it has all the functions of Endnote with only a fraction of its price:

It still has some rough edges (the journal templates do not work as expected, for example), but looks promising.

Data Analysis Using Regression and Multilevel/Hierarchical Models

Very good book:

Friday, February 27, 2009


Here is an interesting blog (in Chinese):

Monday, February 23, 2009

OpenWatcome 1.8

The open source compiler project OpenWatcom just let out a new release, v. 1.8. I don't have much experience with this compiler but remember in the old days the Watcom compiler used to beat its competitors including big names like Microsoft, Borland, and Symantic regarding to performance.

It probably will not work with ADMB, but it would be really great if it does.

Debian Lenny looks cool

I am going to find a spare machine and make a test install.

ADMB, again

Dave, the main person behind the open source ADMB project, answered my earlier question about how to estimate mixture growth model using ADMB. His reply is very helpful and illuminating, and the source code can be used as template for other similar models:

I think the "ADMB team" consists mostly of me. So I'll try and answer
your question about finite mixtures and growth models. Until today I had
very little idea what growth models were, but in writing the simulator I
hope I am getting the idea.

Actually finite mixtures are handled directly so it is not necessary to
use the random effects package. This is actually an advantage since it
greatly speeds up the calculations.
To illustrate the ideas I built a simulator to create a data set
something like you describe in

This could be done in R but I used ADMB since it illustrates some of the
techniques which are useful for building the analyzer. since you didn't
identify the growth curves you used I use the von Bertalanfy curve

L_t = Linf * ( 1 - exp(-k*age))

where L_0=0 is assumed. Of course it is a simple matter to switch to a
different curve There are two curves one with Linf=100 and the other
with Linf=120. For both cases k=0.11 (time measured in years).

I generated 2000 samples. First the size measured in 2 month intervals
and then at ages 8,11,15,19

The individuals were generated with a probability of 0.4 of belonging to
group1 (linf=100) and 0.6 of belonging to group 2. After the first
period the individual were changed at random to groups 1 or 2 with a
transition matrix

.8 prob stay in group 1
.2 prob to move from group 2 to group 1
.7 prob to say in group 2
.3 prob to move from group 2 to group 1

The the size data was generator using the appropriate growth curve.
the resulting sizes were then perturbed using multiplicative lognormal
random variables (std dev of .08) which were highly positively
correlated (0.9)

The resulting output was analyzed with a finite mixture model where
the 12 initial measuremeasurements are assumed to come from a mixture of
two multivariate log-normal distributions with a correlation matrix of
the form

1 rho rho^2 .... rho^11
rho 1
rho^2 .......


The model was fit and the Hessian evaluated in under a minute.

these are the parameter estimates for a typical run.

# Number of parameters = 10 Objective function value = -84436.9
Maximum gradient component = 0.0208847
# p1coff:
0.379774 0.620226
# p2coff:
0.482844 0.517158
# Linf:
99.2992 119.646
# k:
0.109928 0.110294
# rho:
# lsigma:

For each individual the conditional probabilities of belonging in either
of the two groups was calculated after observing the first sizes and
again after observing the second group of sizes. this was used to
estimate the transition probabilities. (Of course this could be done in
the model which would be more efficient.)
~ 0.793901 0.206099
0.292103 0.707897
which is almost perfect.

the C++ code for the simulator is


dvector growth_function(const dvector & age,const dvector& theta)
dvector tmp=theta(1)*(1.0-exp(-theta(
2)*age)); // use you own
return tmp; // growth function here

int main(int argc,char * argv[])
int n=2000;
int nm=16;
int iseed=289;
random_number_generator rng(iseed);
dvector p1(1,2); // priori probability that a child is in group 1 or 2
p1(1)=.4; p1(2)=.6;
dvector p2(1,2);
dmatrix M(1,2,1,2); // transition probabilities
M(1,1)=.8; // 1 remains 1
M(2,1)=.3; // 2 moves to 1
M(1,2)=.2; // 1 moves to 2
M(2,2)=.7; // 2 remains 2
dvector choose(1,n);
dvector choose1(1,n);
double sigma=0.08;
double rho=0.9;
dmatrix size(1,n,1,nm);
imatrix group(1,n,1,2);
dvector age(1,nm);
dvector eta(1,nm);
dvector eps(1,nm);
dmatrix theta(1,2,1,2); //parameters for growth curves

choose.fill_randu(rng); // use to pick group that each child belongs to
choose1.fill_randu(rng); // use to pick group that each child belongs to
int i;
for (i=1;i<=n;i++) // loop over children { if (choose(i)age(1,12),theta(group(i,1)));
double rho2=rho*rho;
for (i=1;i<=n;i++) // loop over children and add noise { eta.fill_randn(rng); eps(1)=eta(1); int j; for (j=2;j<=4;j++) // loop over children and add noise { eps(j)=rho*eps(j-1)+sqrt(1.0-rho2)*eta(j);
for (j=6;j<=16;j++) // loop over children and add noise { eps(j)=rho*eps(j-1)+sqrt(1.0-rho2)*eta(j);
size(i)=elem_prod(size(i),exp(sigma*eps)); // lognormal error

ofstream ofs("growth.dat");
ofs << "# nobs" << i="1;i<=" lmin="min(column(sizes,nm));" lmax="max(column(sizes,nm));" sigma="exp(lsigma);" vinv="1.0/(sigma*sigma);" i="1;i<=" j="1;j<=" i="1;i<=" j="1;j<=" ic1="inv(cor1);" ic2="inv(cor2);" is1="ic1*vinv;" is2="ic2*vinv;" lds1="ln_det(is1);" lds2="ln_det(is2);" psum1="sum(p1coff);" p1="p1coff/psum1;" psum2="sum(p2coff);" p2="p2coff/psum2;" lmax="max(column(sizes,nm));">exp(-k(1)*ages)));

FUNCTION get_likelihood
int i;
dvar_matrix res(1,2,1,nm);
for (i=1;i<=n;i++) { res(1)=log(sizes(i))-pred_size(1);
dvar_vector res1a=res(1)(1,12);
dvar_vector res1b=(res(1)(13,16)).shift(1);
dvar_vector res2a=res(2)(1,12);
dvar_vector res2b=(res(2)(13,16)).shift(1);
dvariable l1a=exp(-0.5*res1a*(is1*res1a));
dvariable l1b=exp(-0.5*res1b*(is2*res1b));
dvariable l2a=exp(-0.5*res2a*(is1*res2a));
dvariable l2b=exp(-0.5*res2b*(is2*res2b));

report <<>


Looks promising:

Sunday, February 22, 2009

Interesting article on netbook, Linux, and Windows

VPN command

I need to type these two commands in order to get my VPN working:
  1. sudo /etc/init.d/vpnclient_init start
  2. vpnclient connect sscvpn

Saturday, February 21, 2009

VPN on Linux

I figured out how to get my Ubuntu box talk to UCLA VPN. Now I don't need to switch to Windows to use that service anymore.

Thursday, February 19, 2009

Get back to research

I spent the past several days writing proposal, now it is done and it's time to get back to my research.

Sunday, February 15, 2009


My paper on schizophrenia (Social Science & Medicine) and long-term mortality consequences of famine (Journal of Biosocial Science) are going to see online version soon.

Private blog for research progress

I open a private blog to record the progress of my research:

Friday, February 13, 2009

Dell Latitude ON

This seems to an amazing idea (and product):

I wonder how this work. For example, is it possible to run the usual Linux stuff such as gcc, emacs, bash, etc. on it? Is possible to install more software?

Thursday, February 12, 2009

Emacs again

The most recent CVS update broke Emacs. I follow this instruction ( to get it up and running again. Man, life without Emacs is hard.

Tuesday, February 10, 2009

What if Apple loses the case?

I guess by definition, being "fans" of something or someone means not being able to calculate or reason rationally...

Monday, February 09, 2009

Linux computer

This site is useful:
Linux on laptop:

I did some comparisons and realized that the Emperiorlinux is charging around $500-$900 premium per machine for the same model and the same configuration form Dell and Lenovo. I am not sure their service worth that much. Yeah they got more models than System 76 and LAClinux, but the price is just way too high.

Chinees lanauge article on sociology methodology

Multilevel mixture model

The multilevel mixture model that Bengt and his group have been working on can be of significant importance to demographers, especially those who are obsessed with the idea of "frailty", like myself. I need to do more reading on this. 

Sunday, February 08, 2009

Linux workstation options

I wonder what are options to buy a workstation-level machine powered by Linux (I like Ubuntu). System 7 seems to be selling some pretty powerful desktop computers, but I really do not know how well they perform in real world computation.

Friday, February 06, 2009

CVS Emacs

I noticed today that the version number of the CVS version of Emacs has changed from 23.0.60 to 23.0.90, getting closer to a new major release.

Wednesday, February 04, 2009

Starting value for aML

Feeding aML good starting values is crucial for fast convergence. I followed the suggestions offered by the aML manual for a while. Now I no longer need to struggle with the manual: it becomes a fun game that I am really good at.

The secret is to build up complicated models piece by piece, use estimates from the simpler models as the starting values of the more complicated ones; and use stepwise procedure to get good estimates for the intercepts, then fixed effects, then random effects.

Tuesday, February 03, 2009

Interesting article on Linux vs. Windows

in Chinese:

Monday, February 02, 2009


This is an interesting toy:

Use "label data" to keep track of Stata programs

It is wise to put a label data command at the end of a data-generation or data-modification Stata program file with something like:

label data "Created by ~/project/inter_generation/program/"

To make sure the new data set can be easily matched to the program that created it.

Saturday, January 31, 2009

LaTeX file management using Subversion

Here are several helpful articles on this topic:

Geany is a saver

Again, I find Geany is a very convenient IDE tool to work with single file C programs such as those provided with the Apophenia library. With compiler command of "gcc -Wall -std=c99 -c -lapophenia -lgsl -lgslcblas -lsqlite3 "%f"" and build command of "gcc -Wall -std=c99 -lapophenia -lgsl -lgslcblas -lsqlite3 -o "%e" "%f"", it saved a lot of typing.

C99 vs. C90

In playing with the source code coming with the book "Modeling with Data" on my Ubuntu box, I discovered one thing: code looks like this:

for (int i = 0; i < N; i ++) {

does not work with the default gcc command line options and issues error message of "Error: 'for' loop initial declaration used outside c99 mode".

The way to fix is either to change the code to:

int i;
for (i = 0; i < N; i ++) {

or put a "-std=c99" in the command line switch and do nothing with the source code.


This is the place to look for Linux-based netbook computer:

Some important tips to unleash the full Linux power on EeePC:

Thursday, January 29, 2009

On "average causal effects"

Schafer and Kang compared the following methods of estimating average causal effects:
  1. Simple difference in means;
  2. Regression and ANCOVA;
  3. Regression estimation;
  4. Matching;
  5. Inverse-propensity weighting;
  6. Subclassification;
  7. Weighted residual bias corrections;
  8. Weighted regression estimation;
  9. Regression estimation with propensity-related covariates.
I like No. 9 and plan to begin from there.

Atom Is Going to Hurt Software Industry?

This guy is being ridiculous:

Somebody once said that Linux was goint to hurt the software industry...

Wednesday, January 28, 2009

HP Mini 1000 Mi Edition

For a Linux-based low-cost netbook, this seems to be the way to go:

Just found that that the command line interface was disabled in this version and users cannot install their own application (, are they kidding? 

Monday, January 26, 2009

A Software Populist Who Doesn’t Do Windows

ADMB-RE examples

Finite mixture modeling with ADMB

The one area that ADMB can potentially be of great importance is in those computation-intensive areas such as finite mixture modeling. I remember I used to run Mplus on a dual-core computer for days to estimate the sequential growth mixture model. Once I get some time, I will try to port my Mplus model into ADMB (if it is possible at all) and see how it compares with Mplus regarding computation time.

I hope open-sourcing ADMB does not mean stopping its development, as in the aML case. aML has some basic capabilities for finite mixture modeling, but it seems that the development is not going to continue.

Also, I wish the ADMB team can make available a more comprehensive set of examples, especially those with results that can be compared to other statistical packages such as R, Stata, SAS, even aML. This will certainly help gain more users outside fishery.

Saturday, January 24, 2009

Reading objects into R

This file ( can be tailored to read results of other formats (i.e. aML) into R for further manipulation.

Also the package "X2R" ( However, this package does not seem to work with GCC 4 yet (it worked with MingW fine, which has GCC 3, but not on my Ubuntu, which has GCC 4).

Ubuntu on Dell Mini 9

AD Model Builder, revisted

Following the instruction (, I got ADMB installed and running on my Ubuntu laptop. I have not spent much time on it, but its design philosophy, convert text input into C++ source file and then compile and run the resulted C++ file, seems to be promising, and is certainly advantageous over its competitor with regard to performance. After all, what runs faster than fully optimized C++ code?

It also works on Windows using MingW. 

Here is the interface between ADMB (and a few other languages) and R:

This is an Emacs editing environment for ADMB:, but the Emacs version is quite old. 

This is the ADMB random effect modeling homepage:

Wednesday, January 21, 2009

Obama's inaugural speech

The Frailty Model

This is a very good book:

Unfortunately, the sample programs provided at the web site are limited to the first five chapters and the really fun stuffs such as multifrailty model, multilevel frailty model, correlate frailty model, and joint modeling are not there. This is surprise because none of the stuff is impossible to implement with currently available software.

Monday, January 19, 2009

C vs. Fortran

How to write a lot

A good (although short) book on academic writing, highly recommended:

Data Analysis and Graphics Using R

Good book. 


JAGS ( is a cross-platform version of BUGS, which can only be used on Windows. There are couple of R packages that can be used to bridge JAGS and R to facilitate convergence diagnosis and results presentation. 

Thursday, January 15, 2009

Books to check out tomorrow

  1. Resampling methods : a practical guide to data analysis / Phillip I. Good (QA278.8 .G66 2006)

Tuesday, January 13, 2009

Note taking

I have tried various note taking software and eventually settled with Google Notebook because
  1. It is free;
  2. It is cross-platform;
  3. It is very lightweight;
  4. It is evolving.

Monday, January 12, 2009

Relative distribution as a way to look at famine mortality?

I am not sure. It is difficult to tackle the issue of the differential mortality caused by famine. Maybe it can be reduced to a series of statistical simulations and look at the relative distribution of some health indicators. I need to put more thoughts in this.

Saturday, January 10, 2009

Why R is bad

A funny post:

Wednesday, January 07, 2009

R on New York Times

It generated a great deal of interest on the R mailing list.

Saturday, January 03, 2009

Modeling with Data

Good book for scientific computing:


Demography accepts PDF submission, which is almost the same thing as accepting LaTeX. I am going to make a LaTeX style file based on the one for Political Analysis.

Thursday, January 01, 2009

Exciting new begining

I was quite depressed yesterday because the sex ratio research did not go as well as I expected. But earlier today I have some exciting new results regarding another paper, an extension of my famine research, and the new year does represent an exciting new beginning.