2
$\begingroup$

I have a panel data set that covers 20 earnings dates for 50 companies. I would like to know if I should scale data by the ticker or just scale the data without grouping. What would be the pros and cons to each approach.

My DV is the stock move on the earnings date and my independent variables are EPS Surprise and Revenue Surprise.

The reason I like grouping by ticker and then scaling the data set is (for example) NFLX (Netflix) will usually have earning surprises that range from -100%:100% while KO (Coca Cola) will have earnings surprises that range from -5%:5%.

To clarify, here is a toy data set. The first dataframe is the raw data, the second data frame is grouped by ticker and then scaled and the third is not grouped and then scaled. My question again is, when should I group by a variable and scale rather than not group and scale?

The end goal will be to build a prediction model. In my real data set I have much more variables such as volatility, beta, P/E, P/S etc...

Note* I added R code below

Raw Data Frame (Panel Data)

 ticker       move    EPS.Surp   Rev.Surp
1    NFLX  8.1020701 -15.2696361 -1.5580548
2    NFLX  4.2980923 -11.9710573 10.4673573
3    NFLX  9.4955246  54.5460546 16.5437769
4    NFLX -8.6181125 -45.2619571  2.2685455
5      GS  0.8988735   5.9303073  1.6376293
6      GS -2.6680112   0.3207252  0.8509929
7      GS  1.5005094  -0.8304341 -1.1515227
8      GS  0.2684115  -3.7049273 -0.6800127
9    AAPL  1.5619276  11.4245512 -1.4972607
10   AAPL  3.9140220 -14.5338353 10.8324545
11   AAPL  4.2795825  -7.9250778 14.5513257
12   AAPL -3.8515053  -4.8476398 14.6462691

Scaled Data frame with grouping

df.group.scaled = df.raw %>% group_by(ticker) %>% mutate_if(is.numeric, scale)

ticker    move  EPS.Surp  Rev.Surp
 1 NFLX    0.579   -0.256    -1.04 
 2 NFLX    0.119   -0.178     0.435
 3 NFLX    0.748    1.40      1.18 
 4 NFLX   -1.45    -0.968    -0.573
 5 GS      0.486    1.36      1.13 
 6 GS     -1.44    -0.0268    0.527
 7 GS      0.812   -0.312    -1.01 
 8 GS      0.145   -1.02     -0.648
 9 AAPL    0.0229   1.40     -1.46 
10 AAPL    0.650   -0.958     0.157
11 AAPL    0.748   -0.359     0.645
12 AAPL   -1.42    -0.0795    0.657

Scaled data without grouping

df.scaled = df.raw %>% mutate_if(is.numeric, scale)

ticker         move    EPS.Surp   Rev.Surp
1    NFLX  1.291247353 -0.54877776 -0.9921123
2    NFLX  0.535994859 -0.40502916  0.6802366
3    NFLX  1.567907726  2.49371676  1.5252716
4    NFLX -2.028424891 -1.85581163 -0.4599550
5      GS -0.138895639  0.37509352 -0.5476952
6      GS -0.847074978  0.13063382 -0.6570911
7      GS -0.019445148  0.08046751 -0.9355767
8      GS -0.264069340 -0.04479989 -0.8700048
9    AAPL -0.007251006  0.61452690 -0.9836578
10   AAPL  0.459740448 -0.51671233  0.7310099
11   AAPL  0.532319861 -0.22870962  1.2481856
12   AAPL -1.082049245 -0.09459810  1.2613892
$\endgroup$
3
  • $\begingroup$ Why do you want to scale it? $\endgroup$
    – carlo
    Commented Oct 28, 2019 at 9:35
  • $\begingroup$ Maybe you can clarify your precise goal. Is it to create a prediction model so you can predict stock price on the earnings date based on the surprises? As @carlo said, why do you want to scale things? $\endgroup$
    – LSC
    Commented Oct 28, 2019 at 11:44
  • $\begingroup$ My DV is "move". I would like to model the relationship between Eps and Rev surprise with the "move". I dont have to scale, however, I am currently scaling due to the difference in standard deviations across different assests. Ie. NFLX eps surprise has a much larger surprise than GS. The end goal will be to make a prediction with current data $\endgroup$ Commented Oct 28, 2019 at 16:06

1 Answer 1

-1
$\begingroup$

better solution is to scale the data 'normally' and add column that will contain values scaled with group by, for neural any algorithm it will be next feature and you will not lose any information...

also when scalling with group by it would be wise to keep mean and variance of previous values in separate columns...

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.