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 enter image description here

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.

  • 1
    $\begingroup$ 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. $\endgroup$
    – Nick Cox
    Commented Dec 20, 2016 at 11:43
  • $\begingroup$ Thanks for input. I have changed the focus from stata and done some language corrections. $\endgroup$ Commented Dec 20, 2016 at 12:18

1 Answer 1


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$.

There are basically two routes to address this problem:

a) For static situations, the idea is to control confounders and re-build / test the causal structure that controls the variables. Keywords are path analysis, structural equation models, Pearl et al.'s book Causal inference

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.


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.