Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6768167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:02:36+00:00 2026-05-26T15:02:36+00:00

I have some data, say (in reality, I have a large amount of data):

  • 0

I have some data, say (in reality, I have a large amount of data):

x   y
0.1 0.267
0.2 0.254
0.3 0.182
0.4 0.173
0.5 0.121
0.6 0.089
0.7 0.070
0.8 0.056
0.9 0.031

This data roughly follows a trend curve that I plot with ggplot stat_smooth(). stat_smooth creates a grey area that it is 95% confident that the trendline will fall inside.

What I wish to do instead is create a grey area around where the trendline will be is create a grey area around where the data points will fall with 95% confidence assuming a normal distribution around the trendline.

Another way of saying it, is I want a smooth_lines connecting the tops and bottoms of the error bars and to shade inbetween in ggplot. How should I go about doing this?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T15:02:36+00:00Added an answer on May 26, 2026 at 3:02 pm

    What you are looking for is essentially called a prediction interval. Here is one way to do it in ggplot2

    library(ggplot2)
    
    # RUN REGRESSION AND APPEND PREDICTION INTERVALS
    lm_fit  = lm(total_bill ~ tip, data = tips)
    tips_with_pred = data.frame(tips, predict(lm_fit, interval = 'prediction'))
    
    # PLOT WITH REGRESSION LINE, CONFIDENCE INTERVAL AND PREDICTION INTERVAL
    p0 <- ggplot(tips_with_pred, aes(x = tip, y = total_bill)) + 
      geom_point() +
      geom_smooth(method = 'lm', aes(fill = 'confidence'), alpha = 0.5) +
      geom_ribbon(aes(y = fit, ymin = lwr, ymax = upr, fill = 'prediction'),
        alpha = 0.2) +
      scale_fill_manual('Interval', values = c('green', 'blue')) +
      opts(legend.position = c(0.20, 0.85))
    

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some data, let's say the number of sells of the month. I
Let's say I have some simple data y = [[datetime.datetime( 2012,1,1,1,1), 2.1], [datetime.datetime( 2012,1,1,1,2),
I have two notepads and each notepad contains some data. Let's say Notepad 1
Say you have a simple class with some storage data structure (list, vector, queue,
I've got some financial data to store and manipulate. Let's say I have 2
Say I have some data like this: number_stream = [0,0,0,7,8,0,0,2,5,6,10,11,10,13,5,0,1,0,...] I want to process
Say I have some data stored in an audit table, where triggers on the
Let's say I have some data, either in a SQL Server 2008 table or
Let's say I have some data in R that looks like this: c(0.11, NA,
I have some data, lets say: var dat = JSON.stringify(frm.serializeArray()) I want to submit

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.