Pets try to copy their owners in every way possible, and since they live and grow older as they gain more experience, they also have levels just like heroes. Pets increase their levels entirely by growing older. This is the graph you get if you plot levels against age:
The trend-line passes through the top points for each level (the maximum age to have the level before it increases) and the curve is followed on despite the miscorrelation with higher level points. This is because as age increases, it becomes more approximate as it says 'about *** months' or something similar, so these points can just be used as a rough guideline. The main point is that it conclusively proves that pet levels are decided entirely by age. Now we just need the formula. It seems to be a power curve of some sort.