R is the language and operating environment for statistical analysis, drawing. R is a free, free, Open-source software that belongs to the GNU system and is an excellent tool for statistical computing and statistical mapping. It is a suite of data manipulation, computing, and graphical presentation capabilities. Includes: Effective data storage and processing capabilities, a complete array (especially matrix) operator, with a complete system of data analysis tools, for data analysis and display of the powerful graphics capabilities, a set (from the S language) a perfect, simple, efficient programming language (including conditions, loops, custom functions, Input/output function). How to use the Rstudio to do the digital map.
#分位数图, draw T-distribution density with P-value x=seq ( -6,6,length=1000);
Y=dt (x,19) r1=-6;
r2=-2.89; X2=c (R1,R1,X[X<R2&X>R1],R2,R2) y2=c (0,dt (C (R1,X[X<R2&X>R1],R2), 0) plot (x,y,type= "L", Ylab = "Density oft", xlim=c ( -5,5)) Abline (h=0);p Olygon (x2,y2,col= "Red") title ("Tail Probability for T") text (C (-4.1)
, -2,5), C (0.02,-0.07), C ("p-value=0.0047", "t=-2.89")) #对称 # x=seq ( -6,6,length=1000);
Y=dt (x,19) r1=6;
r2=2.89; X2=c (R1,R1,X[X<R2&X>R1],R2,R2) y2=c (0,dt (C (R1,X[X<R2&X>R1],R2), 0) plot (x,y,type= "L", Ylab = "Density oft", xlim=c ( -5,5)) Abline (h=0);p Olygon (x2,y2,col= "Red") title ("Tail Probability for T") text (C (-4.1)
, -2,5), C (0.02,-0.07), C ("p-value=0.0047", "t=-2.89")) #两边 # x=seq ( -6,6,length=1000);
Y=dt (x,19) r1=-6; r2=-2.89;
r3=2.89;
r4=6; X2=c (R1,R1,X[X<R2&X>R1],R2,R2) y2=c (0,dt (C (R1,X[X<R2&X>R1],R2), 0) x3=c (r3,r3,x[x<r4 &X>R3],R4,R4) Y3=c (0,dt (C (R3,X[X<R4&X>R3],R4), 0) plot (x,y,type= "L", ylab= "density oft (19)", Xlim=c ( -5,5)) aBline (h=0);p Olygon (C (X2,X3), C (y2,y3), col= "Red"); Title ("Tail Probability for T") text (c ( -4.1,-2.5), C (0.02,-0.007), C ("p-value=0.0047", "t=-2.89")) text (c (2.5,4.1) , C (0.02,-0.007), C ("p-value=0.9953", "t=2.89")) #正态分布 X=seq ( -5,5,0.01) #得到步长0.01 X-Range plot (X,dnorm (x), type= "L", Xlim=c ( -5,5), Ylim=c (0,2), main= "The Normal density Distribution") #画 curve (d
Norm (x,1,0.5), add=t,lty=2,col= "Blue") lines (X,dnorm (x,0,0.25), col= "green") lines (X,dnorm (x,-2,0.5), col= "Orange") Legend ("TopRight", Legend=paste ("m=", C (0,1,0,-2), "sd=", #m: Mean SD: Variance C (1,0.5,0.25,0.5)), lwd=3, Lty=c (1,2,1,1), Col=c ( "Black", "Blue", "green", "red") #分布函数 set.seed (1) x<-seq ( -5,5,length.out=100) y<-pnorm (x,0,1) plot (x,y,col= " Red ", Xlim=c ( -5,5), ylim=c (0,1), type=" L ", xaxs=" I ", yaxs=" I ", ylab= ' density ', xlab= ', main= ' the Normal cumulative Distribution ") lines (X,pnorm (x,0,0.5), col=" green ") lines (X,pnorm (x,0,2), col=" Blue ") lines (X,pnorm (x,-2,1), col=" Orange ") Legend (" BottoMright ", Legend=paste (" m= ", C (0,0,0,-2)," sd= ", C (1,0.5,2,1)), Lwd=1,col=c (" Red "," green "," Blue "," orange "))
The resulting graphic results are as follows: