A Wilks' theorem for grouped data