Inverse estimation in R