An R implementatin of Wei & Li (2013)