1
$\begingroup$

I have a dataset that looks like this:

> scores
         date scores price
1  30/11/2017      1     1
2  01/12/2017      1     0
3  02/12/2017      0     1
4  03/12/2017      1     0
5  04/12/2017      1     1
6  05/12/2017      1     0
7  06/12/2017      1     0
8  07/12/2017      1     1

I would like to calculate the odds ratio but I can't seem to find a way. Is there an easy way to do it?

Thanks in advance

UPDATE

I've used the questionr package and the odds.ratio function and I've obtained this:

> odds.ratio(table(scores$scores, scores$price))
                   OR   2.5 % 97.5 %      p
Fisher's test 2.18493 0.58581 8.4658 0.2374

can you please help me interpret the results? I'm relatively new to this.

EDIT

Basically I'm doing a project for my university. I have binarized sentiment scores for each day (0 if they are under a mean score and 1 if above) and binarized stock price variations (0 if price is lower than previous day, 1 if above). My teacher suggested to run odds ratio to see if sentiment by investor could influence the price variations, so I did it, but I dont know how to interpret them since all I can find about odds ratio are examples with presence/absence of a desease. My guess was that when the sentiment is positive (value of 1, and I will consider this class as the "exposure" class of the medical examples) the stock price has a possibility to increase (value of 1, considered as the "oucome" class) that is 2.1 times bigger than it would be with a negative sentiment (value of 0). But I'm absolutely NOT sold on this interpretation

$\endgroup$
  • $\begingroup$ Ok, thanks for the help, I'll read the link. Thanks again $\endgroup$ – TheClutch01 Mar 17 '18 at 20:49
  • 3
    $\begingroup$ One thing that I wanted to point out here is that these data have been collected over time so they likely exhibit temporal dependence. If this dependence is ignored, subsequent inferences may be invalid. $\endgroup$ – Isabella Ghement Mar 17 '18 at 23:11
1
$\begingroup$

Without more context for the meaning of your variables, it is hard to help you interpret your results. You want to do an odds ratio, but why? Normally, though, you can interpret the odds ratio as an effect size between two groups. In your case, things with price=1 had sales=1 2.1 times as much. Note, however, the large range of vales around your estimate and that it is not statistically significant. Finally, as noted by another user, neglecting to control fir autocorrelation will increase your chances of a type-1 error. I recommend a hierarchical linear model for longitudinal data and test for AR(1) in the level-1 error. If you have more data points, you might be able to use an autoregressive latent trajectory.

$\endgroup$
  • $\begingroup$ Basically I'm doing a prjoject for my university. I have binarized sentiment scores for each day (0 if they are under a mean score and 1 if above) and binarized stock price variations (0 if price is lower than previous day, 1 if above). My teacher suggested to run odds ratio to see if sentiment by investor could influence the price variations, so I did it, but I dont know how to interpret them since all I can find about odds ratio are examples with presence/absence of a desease. My guess was that when the sentiment is positive (value of 1, and I will consider this class as the ... CONT: $\endgroup$ – TheClutch01 Mar 31 '18 at 9:06
  • $\begingroup$ ... "exposure" class of the medical examples) the stock price has a possibility to increase (value of 1, considered as the "oucome" class) that is 2.1 times bigger than it would be with a negative sentiment (value of 0). But I'm absolutely NOT sold on this interpretation $\endgroup$ – TheClutch01 Mar 31 '18 at 9:09
  • $\begingroup$ You will need to control for autocorrelation, either in the residuals, by setting appropriate covariance matrix of the residuals in the lme4 package, or as a paramter, but including an autoregressive parameter in an autoregressive latent trajectory (ALT). See this post: <stats.stackexchange.com/a/30107/147695> amd this link: <rpsychologist.com/r-guide-longitudinal-lme-lmer> for more on creating a multi-level model with autoregressive residuals. As far as I know there is no straightforward procedure for doing an ALT in R, though. $\endgroup$ – Jay Schyler Raadt Apr 1 '18 at 3:34

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.