I have a dataframe that looks like this:
weekyear Location_Id priceA priceB
1 20101 6367 0.8712934 8
2 20101 6380 0.1712934 8
3 20102 6367 0.8712934 4
4 20102 6380 0.4712934 4
5 20103 6367 0.8712934 1
6 20103 6380 0.8712934 9
I would like to demean priceA and priceB. Each is indexed by location and time. I would like for
priceAnew = priceA_{location,time} - mean(over time)(priceA_{location}) - mean(over location)(priceA_{time})
The notation is clearer here: https://stats.stackexchange.com/questions/126549/do-people-used-fixed-effects-in-lasso
Is there a nonpainful way to do this?