# What statistical test method is most suitable for testing how variable A affects variable B over time?

I'm doing an analysis on how one variable affects another variable over time and I am not sure how I should test this. Our more exactly, I don't know which type of statistical test method I should use. The data looks like this SO... I want to test IF and HOW the variable "sweibr" is affecting the variable "swedendebt" over time. Further,I also want to test how the relationship between the variables changes when sweibr goes from positive to negative. ( I have made a dummyvariable on sweibr for this).

I would be thankful if someone could help me solve this.

• I think this is off-topic as being focused on Stata. If you can re-focus it to bring out the statistical question there's scope for it to remain here. Please see advice in the Help Center on software-specific questions. Note that data posted as images can't be copied easily by others. For your future questions: the standard of English here is, I regret to say, poor. If your first language is not English, fine, but you need help from someone local who knows it better. If your first language is English, this needs more care in presentation. We are willing to edit a bit, but not everything. Dec 20, 2016 at 11:43
• Thanks for input. I have changed the focus from stata and done some language corrections. Dec 20, 2016 at 12:18

Let's call your variables $x$ and $y$. You want to know if $y$ causally depends on $x$.
Just to recapitulate that standard approaches like regressions look for correlations between $x$ and $y$. If we have a correlation, it is not clear in which direction the causality goes, or even if causality exists at all. There could be a third variable (confounder) that controls $x$ and $y$.
b) For time-series, however, the situation is much more convenient because one can use a (presumed) property of causality, which is that the cause precedes the effect. There are a number of methods that test for temporal precedence, i.e. if $y_t$ depends on $x_{t-1}$. The most basic approach is Granger causality (see discussion here), which is implemented, e.g., in R here.