3
$\begingroup$

I have on variable that is number of visitors. I am trying to investigate if a recent increase in another variable has caused or related to an increase in the number of visits.

I have run some simple t-test that show significance in the increase in the number of visitors. But I feel this only half answer my question. It could be that the visitors just increased. I have checked for seasonality and that is not an issue. A correlation analyses on the data shows a correlation between .25. Is there a better analysis to do or a transformation I should make (maybe log)?

Here are the visitors by week:

Time                visitors
2019-05-13 0:00:00  11339
2019-05-20 0:00:00  11667
2019-05-27 0:00:00  11983
2019-06-03 0:00:00  11263
2019-06-10 0:00:00  11389
2019-06-17 0:00:00  11240
2019-06-24 0:00:00  11091
2019-07-01 0:00:00  11520
2019-07-08 0:00:00  11506
2019-07-15 0:00:00  11405
2019-07-22 0:00:00  11262
2019-07-29 0:00:00  10707
2019-08-05 0:00:00  11347
2019-08-12 0:00:00  9150
2019-08-19 0:00:00  11387
2019-08-26 0:00:00  11049
2019-09-02 0:00:00  11675
2019-09-09 0:00:00  10895
2019-09-16 0:00:00  10552
2019-09-23 0:00:00  10902
2019-09-30 0:00:00  12145
2019-10-07 0:00:00  12632
2019-10-14 0:00:00  11980
2019-10-21 0:00:00  12148
2019-10-28 0:00:00  12774
2019-11-04 0:00:00  12232
2019-11-11 0:00:00  13556
2019-11-18 0:00:00  12227
2019-11-25 0:00:00  11969

and here is the variable that has increased. I am trying to determine if the increase at the end of Sept has led to increased visits.

time                variable
2019-05-13 0:00:00  13
2019-05-20 0:00:00  2
2019-05-27 0:00:00  7
2019-06-03 0:00:00  3
2019-06-10 0:00:00  3
2019-06-17 0:00:00  68
2019-06-24 0:00:00  22
2019-07-01 0:00:00  22
2019-07-08 0:00:00  17
2019-07-15 0:00:00  36
2019-07-22 0:00:00  433
2019-07-29 0:00:00  244
2019-08-05 0:00:00  165
2019-08-12 0:00:00  39
2019-08-19 0:00:00  16
2019-08-26 0:00:00  28
2019-09-02 0:00:00  9
2019-09-09 0:00:00  54
2019-09-16 0:00:00  4
2019-09-23 0:00:00  6
2019-09-30 0:00:00  4204
2019-10-07 0:00:00  1569
2019-10-14 0:00:00  1528
2019-10-21 0:00:00  181
2019-10-28 0:00:00  134
2019-11-04 0:00:00  19
2019-11-11 0:00:00  85
2019-11-18 0:00:00  21
2019-11-25 0:00:00  40
2019-12-02 0:00:00  66```




$\endgroup$
  • $\begingroup$ You could start by making (and the showing us) some plots. First visitors vs. variable (maybe use first some transformation), then maybe a conditioning plot using time as conditioning variable. For an example see stats.stackexchange.com/questions/235442/… $\endgroup$ – kjetil b halvorsen Dec 6 '19 at 4:03
  • $\begingroup$ In the sense of formal hypothesis testing, there's nothing you can test here, partly because your hypothesis was generated using these data, thereby disqualifying the use of these data to test that hypothesis. What you could reasonably do is describe what happened to the numbers of visitors after the surge on 9/30. $\endgroup$ – whuber Dec 6 '19 at 17:24
  • $\begingroup$ Yes I realize the flaws in this design. Unfortunately this was not run as an experiment and its getting handed down to me to determine if there is an impact. $\endgroup$ – user3120266 Dec 6 '19 at 17:36
2
$\begingroup$

It seems to me that your question is more contextual than mathematical. If I understand your data correctly, you are measuring the number of visitors, we'll call this $V$ and measuring some second variable we'll call $X$. I'm not sure where you're running a t-test here, because a t-test requires a categorical variable, which I do not see in your data. However, a regression of $V = \beta X$ seems appropriete here. Are you meaning to refer to the F-test & corresponding p-value on a regression?

All that being said, based on these two variables, you question seems to be "is $X$ causing an increase in $V$" or is the increase in $V$ causing $X$, or, alternativly, is some third variable casuing an increase in both $V$ and $X$. You can't solve discern this mathematically. You can investigate the relationship in the context they appear, but that's really it.

As to your question about transformation, your variable is not linear, but more close to exponential, so a log transformation may be appropriate. You can use the BoxCox method to check if log is the correct transformation or if perhaps a square-root or some other power is better. Log is a pretty safe bet though.

$\endgroup$
  • $\begingroup$ I used a t-test only to see if there was a significant change in 𝑉 4 weeks before the 𝑋 happened and 4 weeks after 𝑋 happened. Yes, my questions is: is in the increase in 𝑋 causing 𝑉. I realize this may not be proven mathematically (unless a true experiment is setup) but hoping to think through the best analysis I can do to determine if there is a likelihood that it is. $\endgroup$ – user3120266 Dec 6 '19 at 17:17
  • $\begingroup$ Ah I see. Well, I stand by what I said above then. I think a regression or time series is probably the way to go. $\endgroup$ – Tanner Phillips Dec 6 '19 at 17:22
  • $\begingroup$ Thanks! I will give that a shot. Do you recommend a boxcox transformation (or some other) to 𝑉 before running the regression. That was my assumption to do but wasnt sure $\endgroup$ – user3120266 Dec 6 '19 at 17:26
  • $\begingroup$ I didn't run the numbers myself, but the Boxcox method is a test to see if you should transform your data, so it would suggest a transformation for you. This youtube video is helpful. It's a little math-heavy, but it should give you the idea. youtube.com/watch?v=vGOpEpjz2Ks $\endgroup$ – Tanner Phillips Dec 6 '19 at 18:43
0
$\begingroup$

I took your 29 values enter image description here and used my tool of choice , which I have helped to develop.

In order to assess the statistical importance of your candidate predictor variable X , one needs to address the question of unusual activity in either the X or the Y variable.

The hypothesis that a possibly change in X at period 21 is dealt with by introducing a candidate level shift series (IL00021VISITORS. The "regression data set" then looks like this enter image description here

Estimating a robust regression where anomalies (pulses , level shifts ) are allowed to be identified and incorporated yielded two pulses ( period 14 & period 27 ) AND a level shift down at period 18 down for 3 periods.

No power transform was needed as the model's residuals were homogeneous over time .

enter image description here

The Actual/Fit and Forecast is here enter image description here and here enter image description here

The statistics are here enter image description here

with equation here enter image description here

The conclusion is that there is a significant change in Y starting at period 21 which coincides with changes in the user-suggested variable X as supported by (II00021VISITORS) . This could be anecdotal as no designed experiment was conducted and there could be a (lurking) third variable as @Tanner Phillips pointed out.

Notice that X itself (the observed # of visitors) was not found to be significant thus it is the change in X to a new level that "caused" the change in Y. This variable (IIL00021VISITORS) was a user-suggested variable based upon the hypothesis that he is trying to test that a significant pervasive effect took place at period 21.

EDITED WITHOUT USER SUGGESTED VARIABLE STARTING AT PERIOD 21

AUTOBOX identified a Level Shift (at or about period 22) using Intervention Detection procedures espoused here and elsewhere http://docplayer.net/12080848-Outliers-level-shifts-and-variance-changes-in-time-series.html . while adjusting for two anomalies (period 14 and period 27)

This lead to enter image description here and enter image description here with the following visual enter image description here

The statistics are here enter image description here with residual plot here (not yet adjusted for pulses or anything) enter image description here . Would the human (you) not do the same !

In this manner the DATA suggests the hypothesis that should be most rejected i.e. the hypothesis that nothing happend in the period 22-29 or equivalently no special effect for period 22-29 thus data driving hypothesis as what had been assumed to be no latent deterministic effect anywhere was soundly rejected while the first analysis (reflected on/criticized by @whuber ) is a HUMAN suggested hypothesis ( after studying the plots and the data and/or being aware due to domain knowledge that a fundamental change might have occurred at period 21 through 29)

This second approach is true Exploratory Data Analysis (EDA) when applied to time series data where hypothesis are found.discovered by a search process sometimes referred to as machine intelligence by examining the residuals for "structure" ( at least by me ! )

Here is the plot of tentative residuals that the software "looked at i.e. examined " to mechanistically generate the level shift hypothesis.enter image description here

For those who winder why the level/step shift was not found at period 21 ... the (imperfect due to grouping rules) classification strategy found that period 21 was closer to the first 20 than it was to the last 8 given that pulses had yet to be identified and the respective values at 14 & 27 were "normal" and to be believed as part of the underlying process.

$\endgroup$
  • $\begingroup$ Your hypothesis testing is inherently circular, because the indicator variable was created after first noting the large number of visitors on 9/30. Any test thereby becomes self-fulfilling. Your usual approach of identifying significant pulses would be more meaningful because it, at least, would suggest the sudden increase (by several orders of magnitude) is significant. $\endgroup$ – whuber Dec 6 '19 at 17:28
  • $\begingroup$ See revisit with the user suggested variable based upon his hypothesis. $\endgroup$ – IrishStat Dec 6 '19 at 17:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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