Issue in producer stats, Packet Count coming less compare to Packet Lost

Hey All

I am using api producer.getStats() as in documentation link

I am calling above api in each 5 second interval and getting packetCount and packetsLost. Calculating packet transfer and packets lost in last 5 second interval (doing subtraction from previous packetCount and packetsLost). and calculating packet lost percentage. But some time getting packet loss percentage greater then 100% because packet lost is higher as compare to packet count in last 5 second. Which is not correct.
So I am looking correct solution to calculate packet lost percentage. Kindly help me in this issue.