source("http://macosa.dima.unige.it/r.R") # If I have not already loaded the library ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- [ continuation fromhere, paragraph(N_3)]To producehistogramsof alreadyclassified data, which are not easy to trace with standard commands, you can use thehistoclascommand. An example: in Italy in 1951, in the age intervals [0,5),[5,10),[10,20),[20,30),[30,40),[40,50),[50,60),[60,75),[75,100) are dead 729,35,77,132,134,285,457,1401,1569 thousand people (if the extremes of the intervals are N the frequencies areN-1) #interv = c(0, 5, 10, 20, 30, 40, 50, 60, 75, 100) freq = c(729,35,77, 132,134,285,457,1401,1569)histoclas(interv,freq)#The mean (brown dot) is about 58.31897#For percentages use PERC For other statistics use the morestat()# If I writenoMean=1; histoclas(interv,freq)the mean is not shown.PERC#15.13 0.73 1.60 2.74 2.78 5.91 9.48 29.07 32.56morestat()#Min. 1st Qu. Median Mean 3rd Qu. Max.#0.00 43.43 66.00 58.32 80.80 100.00#The brown dots are 5^ and 95^ percentiles#The red dot is the mean# If I writenoMean=1; morestat()the mean is not shown.# WithnoGrid=1I have:BF=4; HF=2.5; noGrid=1; noMean=1; histoclas(interv,freq)In addition to the mean, somepercentiles(the 25th, 50th and 75th percentiles, or firstquartile, median, and third quartile) are estimated and thebox-plotis drawn. [ to do this, a lot of data - distributed as the histogram - was generated; the file isdataclas; you do not have to see it; if you want to have an idea of it you can usestr(dataclas)]The percentiles are also called 100-quantilesTheunitary percentage frequenciesare the percentage frequencies divided by the amplitude of each interval, so that the area of each rectangle represents the relative frequency of the outputs that fall in the interval that is the base. The sum of the areas of the rectangles is 1, or 100%.For other percentiles you must usepercentile(n). For example, the width of the box (difference between 75th and 25th percentile, ie distance between 1st and 3th quartile) is:percentile(75) - percentile(25)#37.3752This value [ percentile(75) - percentile(25) = 3^quartile - 1^quartile ] is also an indicator of the data dispersion. Another used index is the standard deviationSd, that is the root mean square. If the data are X1, …, Xn and the mean is M,Sdis√(((X1-M)^2+ … +(Xn-M)^2)/n)In this case:Sd(dataclas)#30.05867Often in place ofSdwe use√Var(variance), where Var = (X1-M)^2+ … +(Xn-M)^2Another example: thoracic circumference of 3-year-old European children (1970)# 3th percentile is 48.9, 10th is 49.9, 25th is 51, 50th is 52.4, # 75th is 54.1, 90th is 55.8, 97th is 57.9 # To make the histogram I assume that minimum and maximum are 47 and 60interv = c(47, 48.9, 49.9, 51.0, 52.4, 54.1, 55.8, 57.9, 60) freq = c( 3, 7, 15, 25, 25, 15, 7, 3 ) BF=5.5; HF=3 histoclas(interv,freq) morestat()If I have aset of dataXXX I can compute the percentiles withPercentile(XXX,n):data = c(1,2,2,3,3,3,4,4,4,4,4,5,5,6,7,8,8) median(data); Percentile(data,50); Percentile(data,15); Percentile(data,90)If we want to give an index of the dispersion of the data:#4 4 2.4 7.4Percentile(data,75)-Percentile(data,25)or:#2Sd(data)# For histogram and boxplot use: histogram(data); morestat()#1.963332