Monday, June 28, 2010

Ranking of sociology program

Here is a recent ranking of sociology programs.

Thursday, June 24, 2010

A few words describing population projection

Projection in demography is calculating survivors down cohort lines of those living at a given point in time, calculating births in each successive period, and adding a suitable allowance for migration. Of the various ways of looking at population dynamics, the one most convenient for the present purpose is the matrix approach (Chapter 7). Such calculations were used, before Leslie (1945) expressed them in matrix form, by Cannan (1895), Bowley (1924), and especially Whelpton (1936).

----------------------------------------------Page 272, Applied Mathematical Demography

Here is some intro. materials, implemented in Stata. Even though I have been using Stata for a long time, I have never spent any timing learning Mata, too bad.

Wednesday, June 23, 2010

Using World Bank data in R

This R package makes it easy to use data and information from World Bank.

A simple JAGS demo

Here is a simple JAGS demo. The ""gui"" option for the "coda.samples()" function is very convenient, but was not documented in the manual. 

OpenBUGS and rbugs package

I just realized that OpenBUGS 3.10 has a native Linux version and it can be called directly from within R via the package "rbugs". OpenBUGS is probably closer to WinBUGS than JAGS, and it is always nice to alternatives!

It will be fun to do some benchmark test between OpenBUGS and JAGS. 

Tuesday, June 22, 2010

MS small basic

This looks fun.

Making glmmBUGS work with JAGS

To streamline the process of making glmmBUGS to work with JAGS, I made changes to the "writeBugsModel.R" and replaced all "inprod2" with "inprod" and "dflat()" with "dnorm(0.0,1.0E-6)". I will spend some time looking at other sources files and see if anything else should be changed.

JAGS' glm module

I did not realize that new GLM module for JAGS 2.0 can be so effective in reducing the running time. Using the example I posed it yesterday (an example from the glmmBUGS package), without loading the glm module, it took 20.223 minutes to draw 10,000 samples from the posterior distribution; with the glm module loaded, it took 11.869 to get the same results:

Without glm module:
   user  system elapsed
 20.170   0.020  20.223 

With glm module:
   user  system elapsed
 11.040   0.000  11.869 

Dflat() prior

Here is an example of replacing the "dflat()" prior with "dnorm()" prior, yet without much explanation.

Monday, June 21, 2010

A question

I posted a question to the R-Mixed-Model mailing list but have not had any responses yet:
Dear All,

I wonder if anybody has tried to make glmmBUGS work with JAGS. My
attempt was not successful.

Here is the simple example I copied from the glmmBUGS Vignettes:


bacterianew <- bacteria
bacterianew$yInt = as.integer(bacterianew$y == "y")

levels(bacterianew$trt) <- c("placebo", "drug", "drugplus")


bacrag <- glmmBUGS(formula = yInt ~ trt + week, data=bacterianew,
effects = "ID",
                   modelFile="model.bug", family="bernoulli")



startingValues = bacrag$startingValues

With WinBUGS, it runs well:


bacResult1 = bugs(bacrag$ragged, getInits, model.file="model.bug", n.chain=3,
  n.iter=2000, n.burnin=100, parameters=names(getInits()), n.thin=10)

But with JAGS, I got error message "Error in FUN(50L[[1L]], ...) :
invalid first argument"



bacResult = jags(data=bacrag$ragged, n.chain=3, n.iter=2000,

I hope somebody can help me figuring out how to make this work. Many thanks.


Here is the answer from Jens Åströ

Not an expert by any means, but I got it to run by doing this:

1) change inprod2 to inprod in the model file (JAGS does not have
inprod2 function)

2) change ~dflat() to other uninformative prior, e.g.
~dnorm(0.0,1.0E-6) (Jags does not have dflat distribution)

3) specify/compile the model with e.g.

4) update it, update(bac.jags,1000)

5) Collect coda samples,

This seemed to converge well, (gelman.diag(bacResult))

Good luck

It works.

Saturday, June 19, 2010

R-INLA package

Another R package for mixed effect modeling. Looks promising.

Alex, yet another ebook reader

Alex is yet another ebook reader. It Looks promising. Here is a review.

Thursday, June 17, 2010


Mendely is another bibliographic tool that works with Windows, OSX, and Linux. It has some nice features and is particularly suitable for online bibliographic collection and collaboration.

Sunday, June 13, 2010

The BIAS project

The BIAS project has some useful resources and information. And here is a course on spatial analysis using R.

Thursday, June 10, 2010

Wednesday, June 09, 2010

Bayesian propensity score

Why and how, here are more details.

When Linux stopped responding ...

My laptop (running Ubuntu 9.04) stopped responding when I was running update and doing many other things. This post saved my day.

Sunday, June 06, 2010

Using Multilevel Models to Analyze Couple and Family Treatment Data: Basic and Advanced Issues

Rarely published papers make their source code open and well organized. Here is an exception.

Bayesian spatial modeling

Here are some useful resources.

Friday, June 04, 2010

Apple, again

Wow, isn't this fun?