0
votes

I want to draw one graph with cdfs of the standardized chi-square distribution with degrees of freedom $df \in {1, 3, 5, 10, 100}$. I know that the standardized chi-square distribution is given by
$$T=\frac{\chi^{2}_{df}-df}{\sqrt{2df}}$$

I tried drawing the chi-square distribution on one plot using lines(),

z_score <- seq(-3,3,by=0.1)
plot((pchisq(z_score,10)-10)/(sqrt(2*10)),type = "l")
lines((pchisq(z_score,5)-5)/(sqrt(2*5)))
lines((pchisq(z_score,100)-100)/(sqrt(2*100)))
lines((pchisq(z_score,3)-3)/(sqrt(2*3)))
lines((pchisq(z_score,1)-1)/(sqrt(2*1)))

but the lines are not adding in. It's not the case of different limits on the axis I think. Can you help me?

enter image description here

2
@G5W z_score is defined in the code. It is > dput(z_score) c(-3, -2.9, -2.8, -2.7, -2.6, -2.5, -2.4, -2.3, -2.2, -2.1, -2, -1.9, -1.8, -1.7, -1.6, -1.5, -1.4, -1.3, -1.2, -1.1, -1, -0.9, -0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.0999999999999996, 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3) - user13696679

2 Answers

1
votes

It is indeed a ylim matter: I tried randomly this command

plot((pchisq(z_score,10)-10)/(sqrt(2*10)),type = "l",ylim=c(-3,0))

and got more than one line. Then you will need to fiddle a little bit to find the best option.

1
votes

Yes, it is the case of different limits on the axis. Look at the y-axis on your plot. It goes from -2.236 to -2.232. Now look at the data that you are trying to plot with your first lines statement.

summary((pchisq(z_score,5)-5)/(sqrt(2*5)))
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
 -1.581  -1.581  -1.581  -1.564  -1.554  -1.486

None of the y-values for the line would appear in the range depicted in your first plot. Everything would be off-screen.