# Correlation between two time series data: absolute values vs difference?

I have a dataset of different brands, their market share and retail price avg. I am trying to perform competitor analysis.

The truncated df is as follows:

> head(df)
week_number brand market_share retail_price_avg
69            1     A   0.04816599         10.04900
122           1     B   0.05816969         10.21648
208           5     A   0.03860459         10.89721
264           5     B   0.05219956         10.95256
354           6     A   0.05061728         10.03644
414           6     B   0.05481481         10.96556


I am trying to compare the correlation between brand A and B. I have other brands too and their market shares sum up to 1. Let's say A is my target brand. I want to see all the brands that lose with A grows and vice versa.

The market share plot is as follows:

I used the simple cor and ccf functions in R. I also played around with calculating the difference between periods and then performing correlation analysis.

I am new to time series data. What is the best way to perform correlation analysis for time series data?

The retail price of one brand influences the market share of other brands. How do I capture that effect?

I played around with gls and dlm (distributed lag models).

Here is the dput info:

> dput(df)
structure(list(week_number = c(1, 1, 5, 5, 6, 6, 7, 7, 8, 8,
9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16,
17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24,
25, 25, 26, 26, 27, 27, 28, 28, 29, 29), brand = structure(c(1L,
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L,
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L,
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L,
2L, 1L, 2L), .Label = c("A", "B"), class = "factor"), market_share = c(0.0481659874027418,
0.0581696924786958, 0.038604591509555, 0.0521995639348468, 0.0506172839506173,
0.0548148148148148, 0.0497025285076847, 0.0585027268220129, 0.0615966199688682,
0.0439181676673338, 0.0508686414198225, 0.0554930633670791, 0.0372380711941429,
0.0613481444079778, 0.0374603174603175, 0.0610793650793651, 0.0389561270801815,
0.0572365103378719, 0.0343292325717634, 0.0608084358523726, 0.0543579164517793,
0.0438370293965962, 0.0365710253998119, 0.0486829727187206, 0.0361913460440689,
0.0526315789473684, 0.0345014060134112, 0.055158987670344, 0.0367647058823529,
0.0610859728506787, 0.0596055261100009, 0.0437049265791989, 0.036927956502039,
0.0525600362483009, 0.0477113624124933, 0.0498653742595584, 0.0442767012167643,
0.0513744930148715, 0.0433369447453954, 0.0540628385698808, 0.0325115728280762,
0.080740660996878, 0.0363719547066224, 0.0633649776964429, 0.0346212285652269,
0.0629476883004124, 0.0323232323232323, 0.0702817650186072, 0.0342857142857143,
0.0518969555035129, 0.0468153258593076, 0.0576567697425157),
retail_price_avg = c(10.049, 10.2164755838641, 10.8972093023256,
10.9525552825553, 10.0364390243902, 10.9655630630631, 10.0299251870324,
10.9746610169492, 8.86196750902527, 10.9957974683544, 10.1938574938575,
10.7052702702703, 11.0024406779661, 10.0444444444444, 11.0266440677966,
10.0233056133056, 11.0249514563107, 10.0759691629956, 11.0316040955631,
9.99188824662813, 8.88328273244782, 9.95708235294117, 10.9991961414791,
10.0891304347826, 11.0618611987382, 10.0161171366594, 11.0147335423197,
10.0019019607843, 10.9883384615385, 10.0065185185185, 8.76390670553936,
10.001888667992, 10.9400613496932, 10.0374353448276, 10.0140406320542,
10.0547732181425, 10.012010178117, 10.0098026315789, 9.888,
9.79386773547094, 11.0190728476821, 8.75341333333333, 11.1245597484277,
9.91765342960289, 10.9081504702194, 9.98486206896552, 10.7347039473684,
8.80298033282905, 9.88103825136612, 9.77646209386281, 9.95631578947368,
10.0010042735043)), row.names = c(69L, 122L, 208L, 264L,
354L, 414L, 500L, 560L, 644L, 704L, 789L, 847L, 933L, 995L, 1074L,
1132L, 1217L, 1275L, 1362L, 1421L, 1504L, 1567L, 1648L, 1706L,
1789L, 1849L, 1937L, 1996L, 2080L, 2142L, 2227L, 2286L, 2367L,
2423L, 2506L, 2566L, 2648L, 2707L, 2789L, 2851L, 2929L, 2987L,
3070L, 3132L, 3215L, 3275L, 3362L, 3421L, 3500L, 3563L, 3642L,
3702L), class = "data.frame")