No, that equation has to be modified for raises.
Your opponent doesn't have to match the cost of your raise since part of that represents a call of his bet or raise. The reward when you get called and draw out is not the dead money + the size of your bet, it is the dead money + the amount your opponent has to call.
For example, suppose it is blind vs. blind with $100 stacks, you 3-bet to $9, and your opponent 4-bet to $25. You are considering pushing, which risks $91 compared with folding. Your opponent would only have to call another $75. So, if you get called and lose, the cost of the semibluff was $91. If you get called and win, you gain the $34 pot plus your opponent's $75 call, a total of $109.
The equity of pushing relative to folding in this example is P(fold) x $34 + P(call)(wins x $109 - losses x $91).