lsm R code