Have a look at the answer in Why can't model parameters be variables? Let me know if something is not clear