The following table summarizes our ceded premiums and RIF ceded through the Reinsurance  Transactions and other  reinsurance arrangements (excluding Smart Home transactions). Unless otherwise noted, direct RIF includes the amounts ceded  through reinsurance. (1)  Insurance in force on captives as a percentage of total insurance in force. (2)  RIF on captives as a percentage of total RIF . (3)  RIF ceded under QSR transactions and included in primary RIF . Net Investment Income. Our mortgage insurancenet investment income decreased in 2012 compared to 2011, and in  2011 compared to 2010, primarily due to a decline in our total investment balance resulting from negative cash flows, as well as  a shift from higher yielding securities in our investment portfolio to lower yielding investments. Our allocation to short-term  and short duration investments remains high in anticipation of elevated near -term claim payments in our mortgage insurance  segment. This allocation, combined with certain sales of securities and subsequent reinvestment of longer duration securities in  the low interest rate environment, has resulted in a lower yield profile for the portfolio.  All periods include an allocation to the  mortgage insurance segment of net investment income from Radian Group based on relative GAAP  equity of the mortgage  insurance segment, which decreased in both 2012 and 2011. Net Gains on Investments. The components of the net gains on investments for the periods indicated are as follows:  104 Year Ended December 31, (In millions) 2012 2011 2010 Net unrealized (losses) gains related to change in fair value of  trading securities and other investments . . . . . . . . . . . . . . . . . . . $ (32.7 ) $ 67.8 $ (1.5 ) Net realized gains on sales . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136.4 58.4 85.5 Net gains on investments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . $ 103.7 $ 126.2 $ 84.0 At or For the Year Ended December 31, ($ in thousands) 2012 2011 2010 First-Lien Captives Premiums ceded to captives. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . $ 23,416 $ 28,816 $ 83,384 % of total premiums. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2% 4.1% 10.2% Insurance in force (1) subject to captives. . . . . . . . . . . . . . . . . . . . . . . . 6.5% 8.9% 10.6% RIF (2) subject to captives. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.3% 8.8% 10.4% Initial Quota Share Reinsurance (“QSR”) Transaction  Ceded premiums written . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . $ 52,151 % of premiums written. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.9% Ceded premiums earned  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . $ 16,088 % of total premiums. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2% Ceding commissions earned . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . $ 13,038 RIF included in QSR (3) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . $ 1,525,840 Second QSR Transaction Ceded premiums written . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . $ 9,648 % of premiums written. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1% Ceded premiums earned  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . $ 504 % of total premiums. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 0.1% Ceding commissions earned . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . $ 3,377 RIF included in QSR (3) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368,429