fix loop, helpers for p.e. models

the issue was how as.numeric() worked with factors (apparently,
differently from how it works with strings that are == to the factors).
Fixed by making ordered factor