I see a few possible stats when I search for 'rakeback' and filter for PT4. One of those should give you a starting point. (Most PT3 stats will work but some which use specific database tables, like that rakeback stat, won't work.)
Bad Beat contributions should be stored separate from rake, although it is possible that that may vary by site if your site does not specify the BBJ separately from rake which may mean that it isn't recorded separately.
If you open a
Support Ticket and attach an original hand history file including a hand with a BBJ (and tell us the hand number please) then we'll be able to check that for you.
You can seen BBJ amounts by adding the 'Game Currency Jackpot' stat to a hand report.
If the calculation is different for each stake then you can't do this purely in a stat; you will need to make a new column.
Without knowing which type of "rake" calculation your deal is based on I can't say exactly which columns you should base your new column on, but if it were based on the rake weighted by how much you contributed for example, then you can do something like this:
sum( (cash_hand_player_statistics.amt_bet_ttl / cash_hand_summary.amt_pot) * if[ cash_limit.amt_bb = 1.00, 0.3 * cash_hand_summary.amt_rake, 0 ] )
This will only calculate it where the big blind is 1.00.
To extend that you could replace the "0" at the end with further nested IF statements for other stakes.