# How to calculate Odds Ratio with R

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?

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


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

• Ok, thanks for the help, I'll read the link. Thanks again
– TheClutch01
Commented Mar 17, 2018 at 20:49
• 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. Commented Mar 17, 2018 at 23:11