Hi Abhishek,
For the benefit of all lets understand basics. This is a bit technical, but if u put in effort, u will understand it well.
Lets take an e.g.

Yield = Total Int. Earned / Average Int Earning Assets of Current year and Last year.
Rationale - We earn Int. on Int. Earning assets (Loans + Investments). However, the Int. earning assets (Loans + Investments) would have accumulated over a period of 1 year on which we earned this int. It is incorrect to say that the Int. was earned on the Assets as on 1st day of year or last day of the year. Therefore Averaging these Assets is better. In my e.g. I am taking only 1 years figure for the sake of simplicity
Yield = 9.5 / 100 = 9.5%
Cost of Funds = Total Int. Paid for the year / Avg. Borrowings
Same rationale for Avg borrowings as discussed above, but for sake of simplicity I am taking 1 years figure)
Cost of Funds = 6.4 / 80 = 8%
NIMâs = Net Int. Income / Avg. Int. Earning Assets
NIMâs = [ Total Int. earned (-) Total Int. Paid ] / Avg. Int. Earning Assets
NIMâs = [ Total Int. Earned / Avg. Int. Earning Assets ] (-) [ Total Int Paid / Avg. Int. Earning Assets ]
NIMâs = Yield (-) [ Total Int Paid / Avg. Int Earning Assets ]
NIMâs = 9.5% (-) [ 6.4 / 100 ]
NIMâs = 9.5% (-) 6.4% = 3.1%
Now, lets see what is Spread
Spread = Yield (-) Cost of Funds
Spread = Yield (-) [ Total Int. paid / Avg Borrowings for the year ]
Spread = 9.5% (-) [ 6.4 / 80 ]
Spread = 9.5% (-) 8%
Spread = 1.5%
So, if you see carefully, the only difference between Spreads and NIMâs is the last part of the equation (As highlighted in Bold below). Also note that this equation is deducted from the Yield to arrive at the NIMâs or Spreads.
[ Total Int Paid / Avg. Int Earning Assets ] Vs [ Total Int. paid / Avg Borrowings for year ]
[ 6.4 / 100 ] Vs [ 6.4 / 80 ]
Even in the above equation, Numerator (Total Int Paid) is the same, hence the only difference will be the Avg Int. Earning Assets Vs Avg Borrowings.
Rs 100 (Avg Int Earning Assets) Vs Rs 80 (Avg Borrowing).
NIMâs = 3.1% Spreads = 1.5%
So, When Avg Int. Earning Assets are > Avg Borrowings - We will get Higher NIMâs than Spreads &
When Avg Int. Earning Assets < Avg Borrowings - We will get higher Spreads than NIM
Now coming to your Point on Why HDFC has higher NIMâs Compared to PNB Housing, inspite of similar spreads.
NIMâs = Yields (-) [ Int Paid / Avg Int. Earning Assets ]
When can NIMâs of one company be higher than the other.
3 possibilities -
1st When Yields are higher than itâs peer
2nd When Absolute Int paid is lower (which depends on the rate of borrowings) than itâs peer
3rd When Avg. Int. Earning Assets are higher than itâs peer.
This is a homework for you and other community members to get these figures.