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 8332745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:48:37+00:00 2026-06-09T02:48:37+00:00

I found this code on internet that compares a normal distribution to different student

  • 0

I found this code on internet that compares a normal distribution to different student distributions:

x <- seq(-4, 4, length=100)
hx <- dnorm(x)

degf <- c(1, 3, 8, 30)
colors <- c("red", "blue", "darkgreen", "gold", "black")
labels <- c("df=1", "df=3", "df=8", "df=30", "normal")

plot(x, hx, type="l", lty=2, xlab="x value",
  ylab="Density", main="Comparison of t Distributions")

for (i in 1:4){
  lines(x, dt(x,degf[i]), lwd=2, col=colors[i])
}

I would like to adapt this to my situation where I would like to compare my data to a normal distribution. This is my data:

library(quantmod)
getSymbols("^NDX",src="yahoo", from='1997-6-01', to='2012-6-01')
daily<- allReturns(NDX) [,c('daily')]
dailySerieTemporel<-ts(data=daily)
ss<-na.omit(dailySerieTemporel)

The objectif being to see if my data is normal or not… Can someone help me out a bit with this ? Thank you very much I really appreciate it !

  • 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-06-09T02:48:39+00:00Added an answer on June 9, 2026 at 2:48 am

    If you are only concern about knowing if your data is normal distributed or not, you can apply the Jarque-Bera test. This test states that under the null your data is normal distributed, see details here. You can perform this test using jarque.bera.test function.

     library(tseries)
     jarque.bera.test(ss)
    
        Jarque Bera Test
    
    data:  ss 
    X-squared = 4100.781, df = 2, p-value < 2.2e-16
    

    Clearly, from the result, you can see that your data is not normaly distributed since the null has been rejected even at 1%.

    To see why your data is not normaly distributed you can take a look at the descriptive statistics:

     library(fBasics)
     basicStats(ss)
                         ss
    nobs        3776.000000
    NAs            0.000000
    Minimum       -0.105195
    Maximum        0.187713
    1. Quartile   -0.009417
    3. Quartile    0.010220
    Mean           0.000462
    Median         0.001224
    Sum            1.745798
    SE Mean        0.000336
    LCL Mean      -0.000197
    UCL Mean       0.001122
    Variance       0.000427
    Stdev          0.020671
    Skewness       0.322820
    Kurtosis       5.060026
    

    From the last two rows, one can realize that ss has an excess of kurtosis, and the skewness is not zero. This is the basis of the Jarque-Bera test.

    But if you are interested in compare actual distribution of your data agaist a normal distibuted random variable with the same mean and variance as your data, you can first estimate the empirical density function from your data using a kernel and then plot it, finally you only have to generate a normal random variable with same mean and variance as you data, do something like this:

     plot(density(ss, kernel='epanechnikov'))
     set.seed(125)
     lines(density(rnorm(length(ss), mean(ss), sd(ss)), kernel='epanechnikov'), col=2)
    

    enter image description here

    In this fashion you can generate other curve from another probability distribution.

    The tests suggested by @Alex Reynolds will help you if your interest is to know what possible distribution your data were drawn from. If this is your goal you can take a look at any goodness-of-it test in any statistics texbook. Nevertheless, if just want to know if your variable is normally distributed then Jarque-Bera test is good enough.

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

Sidebar

Related Questions

I have found this line of MatLab code on the internet that displays a
I found some mapkit code on the internet that looks like this: - (void)recenterMap
After a while of searching the internet, I found this piece of code that
How can i check that internet has or not. But i found this code
I found this code in the internet and I modified it for my use,
Hi i have problem with this code, i found it on the internet and
This is some code I found on the internet. I'm not sure how it
I've got this code from an example I found useful around Internet. It uses
Once again I found JavaScript code on the Internet that contains an inline function
I found this handy code on the internet, - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath

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.