Re #9030. Use chi squared in error calculation