-1

I'd like to plot, using ggplot / geom_point, a change in scores with typical error as well as confidence intervals. I'd like the confidence interval on each point to be set at .93 for upper and lower CI (which is 90% CI).

I've used the following dummy data:

Dummy data

Here's what I've used thus far and have gotten each point as well as typical error to plot just fine, but my CI attempts have not worked.

ggplot(Testing)+
  geom_point(aes(Change,Athlete), size = 3)+
  theme_classic()+
  xlab("Score Change")+
  scale_x_continuous(limits = c(-12,12))+
  annotate("rect", xmin=-1.8, xmax=1.8, ymin=0, ymax=Inf, alpha = .3)`

Any help to get the CI for each point would be great help.

The plot looks like this so far Plot

jg23
  • 3
  • 3
  • 2
    You need to first calculate the 93% CI (out of curiosity: why 93%?). How to do that depends on your data & model. Can you make your post [reproducible](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) by including sample data and relevant code of your model? Are you fitting a linear model? The base R function `predict` has methods for various model fits that allows you to calculate CIs. It's difficult to provide specific help without any details though. – Maurits Evers Aug 06 '19 at 00:33
  • 1
    No don’t share screenshots of your data as we can’t extract data from images. Review the link I gave in my first comment on how to give a reprex. You also did not answer any of my questions. Confidence intervals are a result of a statistical inference method. What inference method are you using? It looks like you’re trying to estimate the population mean? Please share your code! – Maurits Evers Aug 06 '19 at 01:49
  • Sorry. I was trying for 30-60 minutes last night to do as the directions said, but could not figure it out. I'll make sure I have a better understanding moving forward. I know what I want to do, but maybe don't know the exact terminology. I'm attempting to do this http://www.sportsci.org/jour/04/wghtests.htm I appreciate your responses and will take more time to figure out how I can post better questions. – jg23 Aug 06 '19 at 16:13

1 Answers1

0

First off, I encourage you to review how to ask questions here on SO, and what you can (and should) do in order to provide a minimal reproducible example/attempt, including reproducible sample data.

As I explained in my comments, sharing data as a screenshot is never a good idea as we cannot copy&paste data from an image. Secondly, when posting a new question we expect you to "hang around" to respond to questions asking you to clarify on the issue you're reporting in a timely manner. Stack Overflow is a great place to come to ask for help, but due to the sheer number of posts, SO has a clear set of posting rules that we expect posters to adhere to in order to manage the number of posts. Please familiarise yourself with these rules!

That aside and in response to your question, here is something that should get you started:

  1. First off, let's generate some random sample data.

    set.seed(2018)
    df <- data.frame(
        Athlete = paste("Athlete", 1:9),
        Score_Change = rnorm(9, 0, 5))
    
  2. We can no plot the Score_Change as a function of Athlete; we also show the population mean including 90% confidence interval based on a simple linear model Score_Change ~ 1. This fits a simple intercept-only OLS model to Score_Change.

    ggplot(df, aes(Athlete, Score_Change)) +
        geom_point() +
        geom_smooth(
            aes(x = as.integer(Athlete)),
            method = "lm",
            formula = y ~ 1,
            se = TRUE,
            level = 0.90) +
        coord_flip()
    

enter image description here

Maurits Evers
  • 49,617
  • 4
  • 47
  • 68