Content Disclaimer Copyright @2020. All Rights Reserved. |

**Links : **Home
Index (Subjects)
Contact StatsToDo

MacroPlot Resources
Orientation
Macroplot plotting is controlled by the macros in the text area provided.
Macros
Each macro must occupy its own line. If the first character of a macro is not A-Z, the line will be considered a comment and ignored The first macro, which is obligatory, initializes the plot. The macro is Bitmap Initialize width(in pixels), height(in pixels), red(0-255) blue(0-255), green(0-255) transparency(0-255)Example : Bitmap Initialize 700 500 255 255 255 255 which provides a landscape area 700 pixels wide, 500 pixel high, with white background
The following are default settings when the bitmap is initiated. - Lines are black (0 0 0 255) and 3 pixels in width
- Fill color for bars and dots are black (0 0 0 255), and the fill type is set to fill only (1) (see Fill Type)
- Dots (circl and square) are set to 5 pixels radius (diameter=11 pixels)
- Fonts are set as follows
- Font face is set to sans-serif. Serif, sans-serif, and monospace are available to all browsers, user can use any font available to his/her browser
- Font size is set to 16 pixels high
- Font color, both line and fill are set to black (0 0 0 255), and fill type to 1 (fill only) (see Font Type)
Bitmap, and the coordinates are x=number of pixels from the left border and y=number of pixels from the top border
A central plotting area is also defined - By default, at initialization, as 15% from the left and bottom, 5% from right and top
- defined by user as
**Plot Pixels left top right bottom**, these being number of pixels from the left and top border e.g.**Plot Pixels 105 25 665 425**would be the same as the default setting for a bitmap of 700 pixels wide and 500 pixels high
**Plot Values left top right bottom**, these being the extreme values used in the data e.g.**Plot Values 0 100 10 50**represents x values of 0 on the left to 10 to the right, and y values of 50 at the bottom to 100 to the top
Plot, and the coordinates are the values in the data
This panel lists and describes all macros used in this version of MacroPlot by Javascript. They are divided into the following sub-panels
Color Palettes
- Initialization and settings
- Plotting areas, coordinates used, and drawing of x and y axis
- Drawing lines, bars, dots, text, and other shapes
This sub-panel lists those macros that initialized the bitmap, and set the parametrs for drawing
Axis & Coordinates
## Initialize PlottingBitmap Initialize w h r g b t is the first and obligatory macro, which Initializes the bitmap
- w and h are width and height of the bitmap in number of pixels. The most common dimensions are
- w=700 and h= 500 for landscape orientation
- w=500 and h=700 for portrait orientation
- Both 500 for square bitmap
- r g b t represents red, green, blue and transparency values for the background, each value is 0 for non-existence to 255 for maximum intensity. The most commonly used background is white (255 255 255 255)
- For most plotting programs in StatsToDo the macro used is
**Bitmap Initialize 700 500 255 255 255 255**, a landscape orientation with white background
## Settings for linesThe settings provide parameters for all subsequent plotting until the parameter is reset
## Settings for fillsWhen bars, dots, arcs and wedges are plotted, the interior of these symbols are called fills, and they are set as follows
- t=0: only the outline, defined by the line parameters, are plotted. Fill is ignored
- t=1: only fill is carried out, outline is ignored
- t=2: both outline and fill are plotted
- When the plot is initialized, the default setting for fill type is t=1
## Settings for fontsThese set the font characteristics for text output.Please note: settings for lines and fills for fonts are separate and independent to those for general line and shape plottings
- t=0: only the outline of the font, defined by the thick and LColor parameter is drawn
- t=1: only the fill of the font is drawn
- t=2: both outline and fill are drawn
- When the plot is initialized, the default setting for Font type is t=1
Please Note: When the bitmap is initialized, the default settings, which are suitable for most situations, are automatically set, so users need not worry about these settings unless he/she has a different preference.
This sub-panel presents macros that define the plotting areas, and creating the x and y axis for plotting
Drawings
## Drawing on the bitmapWhen plotting on the initialized bitmap - the horizontal coordinate x is the number of pixels from the left border
- the vertical coordinate y is the number of pixels from the top border
- The macro used begins with the keyword
**Bitmap**
## Drawing on the plotting areaIn most cases, there is a need to draw and label the x and y axis, and drawing coordinates used are the actual values of the data. The macros used for these all begins with the keywordPlot, and are purposes are as follows
- lp defines the left border of the plotting area, in the number of pixels from the left border of the bitmap. In most cases this is 15% of the bitmap's width
- tp defines the top of the plotting area, in the number of pixels from the top border of the bitmap. In most cases this is 5% of the height
- rp defines the right border of the plotting area, in the number of pixels from the left border of the bitmap. In most cases this is 95% of the width (or 5% from the right border of the bitmap)
- bp defines the bottom border of the plotting area, in the number of pixels from the top border of the bitmap. In most cases this is 85% of the height (or 15% from the bottom)
- An example is that is that, in a landscape orientated bitmap of 700 pixels width and 500 pixel height,
**Plot Pixels 105 25 665 425**sets the central area for plotting that is 15% from the left and bottom, and 5% from the top and right. - This macro is usually not necessary if the 5%/15% setting suits the user, as this is the default setting when the bitmap is initialized
Plot Values lv tv rv bv defines the data values to be used in plotting
- lv is the extreme data value for the horizontal variable x on the left
- tv is the extreme data value for the vertical variable y at the top
- rv is the extreme data value for horizontal variable x on the right
- bv is the extreme data value for the vertical variable y at the bottom
Plot Logx 1 sets the horizontal x axis to the log scale. Normal scale is set on initialization, or reset by Plot Logx 0
- lable is a single word text string, using the underscore
**_**to represent spaces if necessary - space is the number of pixels between the bottom of the plot area and the label text string
- lable is a single word text string, using the underscore
**_**to represent spaces if necessary - space is the number of pixels between the left of the plot area and the label text string
## The quickest and easiest way to draw axisThe following 4 macros are sufficient to draw the x and y axis under most circumstances
- y is the y value on which the x axis lie
- nsIntv is the number of small intervals between the vertical line marks, 10 to 20 are recommended
- nbIntv is the number of big intervals between the numerical scales, 5 to 10 are recommended
- len is the length of the mark in pixels, +ve value downwards and negative value upwards. -10 is recommended
- gap is the number of pixels between the numerical scaling text and the y value of the axis, +ve values for text below axis and negative value for text above axis. 3 is recommended
- Line determines the axis line is drawn, 0 for no line, 1 for line
Plot YAxis x nsIntv nbIntv len gap line will mark out and numerate the vertical y axis
- x is the x value on which the y axis lie
- nsIntv is the number of small intervals between the horizontal line marks, 10 to 20 are recommended
- nbIntv is the number of big intervals between the numerical scales, 5 to 10 are recommended
- len is the length of the mark in pixels, +ve value to the right and negative value to the left. 10 is recommended
- gap is the number of pixels between the numerical scaling text and the y value of the axis, +ve values for text to the right of axis and negative value for text to the left of axis. -3 is recommended
- Line determines the axis line is drawn, 0 for no line, 1 for line
Plot AutoXLogScale y len gap line will mark and numerate the x axis if it is in log scale
- The x axis must be set to the log scale by
**Plot Logx 1**. If axis not set to log this macro will abort - y is the y value on which the x axis lie
- len is the length of the mark in pixels, +ve value downwards and negative value upwards. -10 is recommended
- gap is the number of pixels between the numerical scaling text and the y value of the axis, +ve values for text below axis and negative value for text above axis. 3 is recommended
- Line determines the axis line is drawn, 0 for no line, 1 for line
Plot AutoYLogScale x len gap line will mark and numerate the y axis if it is in log scale
- The y axis must be set to the log scale by
**Plot Logy 1**. If axis not set to log this macro will abort - x is the x value on which the x axis lie
- len is the length of the mark in pixels, +ve value downwards and negative value upwards. -10 is recommended
- gap is the number of pixels between the numerical scaling text and the y value of the axis, +ve values for text below axis and negative value for text above axis. 3 is recommended
- Line determines the axis line is drawn, 0 for no line, 1 for line
## Other methods of drawing axisUsers may wish to draw individual part of the axis, and the following macros can be used
- y is the y value where the axis is to be marked
- begin is the value for the first mark
- interval is the interval between marks
- len is the length of the mark line in pixels, +ve downwards, -ve upwards
- x is the x value where the axis is to be marked
- start is the value for the first mark
- interval is the interval between marks
- len is the length of the mark line in pixels, +ve to the right, -ve to the left
- y is the y value for the axis
- start is the first value to be written
- interval is the interval between numerical scales
- gap is the space in pixels between the scale text and the axis, +ve for text below axis, -ve for text above axis
- The number of decimal points in the scale is the same as that of the interval value
- x is the x value for the axis
- start is the first value to be written
- interval is the interval between numerical scales
- gap is the space in pixels between the scale text and the axis, +ve for text to the right of axis, -ve for text to the left of axis
- The number of decimal points in the scale is the same as that of the interval value
Plot XMarkIntv y interval len marks the horizontal x axis with a series of vertical marks
- y is the y value of the axis
- interval is the interval between the marks, beginning at 0 and while in range
- len is the length of the mark line in pixels, +ve downwards, -ve upwards
Plot YMarkIntv x interval len marks the vertical y axis with a series of horizontal marks
- x is the x value of the axis
- interval is the interval between the marks, beginning at 0 and while in range
- len is the length of the mark line in pixels, +ve to the right, -ve to the left
Plot XScaleIntv y interval gap writes the numerical scales for the horizontal x axis
- y is the y value of the axis
- interval is the interval between the numerical scales, beginning at 0 and while in range
- gap is the space in pixels between the scale text and the axis, +ve for text below axis, -ve for text above axis
- The number of decimal points in the scale is the same as that of the interval value
Plot YScaleIntv x interval gap writes the numerical scales for the vertical y axis
- x is the x value of the axis
- interval is the interval between the numerical scales, beginning at 0 and while in range
- gap is the space in pixels between the scale text and the axis, +ve for text to the right of axis, -ve for text to the left of axis
- The number of decimal points in the scale is the same as that of the interval value
This sub-panel describes those macros that draws the plotting objects. Drawing are performed in two environments
- Macros that begins with the keyword
**Bitmap**uses pixel values as coordinates, where x is the number of pixels from the left border, and y the number of pixels from the top border - Macros that begins with the keyword
**Plot**uses actual data values (as defined in the**Plot Values lv tv rv bv**macro, as coordinates
## Drawing linesThe thickness and color of any line drawn is set by theLine macros (see setting sub-panel). The default setting is black line 3 pixels in width
- x1 and x2 are number of pixels from the left border
- y1 and y2 are number of pixels from the top border
- x1 and x2 are data values for the horizontal variable x
- y1 and y2 are data variables for the vertical variable y
Plot PixLine x y hpix vpix draws a line
- x and y are data values for the horizonal x value and verticsl y value. This defines the coordinate at the origin of the line
- hpix is the number of pixels horizontally from the origin, +ve value to the right, -ve value to the left
- vpix is the number of pixels vertically from the origin, +ve value downwards, -ve value upwards
- The line is then drawn between the origin and that defined by hpix and vpix
## Drawing barsThe color and thickness of the outline are defined in theLine macro. The color of the fill is defined in the fill color and Fill Type macro. The default setting is black (0 0 0 255) for both line and fill color, and the Fill type is set to 1, only the fill and no outlines. These settings are suitable for most circumstances, but user can change them is so required.
- w is the half width of the bar, so a VBar is 2w+1 pixels in width, and HBar is 2w+1 pixels in height
- The default value for w is 7 pixels (making width/height of 15 pixels), unless the user changes it
- x is the data value for the horizontal x variable. The is the center of the vertical bar
- y1 and y2 are values for the vertical y variable. They define the vertical ends of the bar
- hshift is the number of pixels the whole bar is shefted horizontally, +ve value to the left and +ve value to the right. In most cases this is 0 (no shift). However, if there are more than 1 bar in the same position, shifting some of them will avoid the bars overlapping and obscuring each other
- The width of the vertical bar is set by default at 7, (width of bar=15 pixels)
- x1 and x2 are data values for the horizontal x variable. They define the horizontal ends of the bar
- y is the value for the vertical y variable, and defines and center of the horizontal bar
- vshift is the number of pixels the whole bar is shefted vertically, -ve value upwards and +ve value downwards. In most cases this is 0 (no shift). However, if there are more than 1 bar in the same position, shifting some of them will avoid the bars overlapping and obscuring each other
- Theheight of the horizontal bar is set by default at 7, (height of bar=15 pixels)
## Drawing dotsThere are only 2 dot types, circle and square. If more than 2 tyoes of dats are required, they can be distinguished by the colours of the outline and fill, and by their sizes. Settingsd for dot parameters are in the settings sub-panel
- x and y are the number of pixels from the left and top border
- Radius is in number of pixels. The diameter of the dot is 2Radius+1 pixels
- x and y are the data values of the horizontal x variable and vertical y variable, as defined by
**Plot Values lv tv rv bv** - Radius is in number of pixels. The diameter of the dot is 2Radius+1 pixels
- hshift is the number of pixels the dot is shifted horizontally, -ve value to the left, +ve value to the right
- vshift is the number of pixels the dot is shifted vertically, -ve value upwards, +ve value downwards
- In most cases there is no shift (0 0), but id there are more than 1 dot in the same position, shifting avoids the dots superimposing over and obscuring each other
Dot Radius r sets the radius of the dot in pixels. The diameter of the dot is 2radius+1 pixels. The default radius is 5
- x and y are the data values of the horizontal x variable and vertical y variable, as defined by
**Plot Values lv tv rv bv** - hshift is the number of pixels the dot is shifted horizontally, -ve value to the left, +ve value to the right
- vshift is the number of pixels the dot is shifted vertically, -ve value upwards, +ve value downwards
- In most cases there is no shift (0 0), but if there are more than 1 dot in the same position, shifting avoids the dots superimposing over and obscuring each other
## Drawing textThe color, outline, fill, font, and weight of text are preset (see settings). The default settinfs are sans-sherif, black fill only, and 16pxs high
- x and y are number of pixels fom the left and top borders, and together being the reference coordinate of the text
- ha is horizontal adjust
- ha=0: the left end of the text is at the x coordinate
- ha=1: the center of the text is at the x coordinate
- ha=2: the right end of the text is at the x coordinate
- va is vertical adjust
- va=0: the top of the text is at the y coordinate
- va=1: the center of the text is at the x coordinate
- va=2: the bottom end of the text is at the x coordinate
- txt is the text to be drawn. It must be a single word with no gaps. Spaces can be represented by the underscore _
- x and y are data values as defined by
**Plot Values lv tv rv bv**, and together being the reference coordinate of the text - ha is horizontal adjust
- ha=0: the left end of the text is at the x coordinate
- ha=1: the center of the text is at the x coordinate
- ha=2: the right end of the text is at the x coordinate
- va is vertical adjust
- va=0: the top of the text is at the y coordinate
- va=1: the center of the text is at the x coordinate
- va=2: the bottom end of the text is at the x coordinate
- txt is the text to be drawn. It must be a single word with no gaps. Spaces can be represented by the underscore _
- hshift is the number of pixels the text is shifted horizontally, -ve value to the left, +ve value to the right
- vshift is the number of pixels the text is shifted vertically, -ve value upwards, +ve value downwards
- In most cases there is no shift (0 0), but if there are other structures in the same position, shifting avoids the text and structures obscuring each other
- x and y are number of pixels fom the left and top borders, and together being the reference coordinate of the text
- ha is horizontal adjust
- ha=0: the left end of the text is at the x coordinate
- ha=1: the center of the text is at the x coordinate
- ha=2: the right end of the text is at the x coordinate
- va is vertical adjust
- va=0: the top of the text is at the y coordinate
- va=1: the center of the text is at the x coordinate
- va=2: the bottom end of the text is at the x coordinate
- txt is the text to be drawn. It must be a single word with no gaps. Spaces can be represented by the underscore _
- x and y are data values as defined by
**Plot Values lv tv rv bv**, and together being the reference coordinate of the text - ha is horizontal adjust
- ha=0: the left end of the text is at the x coordinate
- ha=1: the center of the text is at the x coordinate
- ha=2: the right end of the text is at the x coordinate
- va is vertical adjust
- va=0: the top of the text is at the y coordinate
- va=1: the center of the text is at the x coordinate
- va=2: the bottom end of the text is at the x coordinate
- hshift is the number of pixels the text is shifted horizontally, -ve value to the left, +ve value to the right
- vshift is the number of pixels the text is shifted vertically, -ve value upwards, +ve value downwards
- In most cases there is no shift (0 0), but if there are other structures in the same position, shifting avoids the text and structures obscuring each other
## Other miscellaneous drawingsBitmap Arc x y radius startDeg endDeg rotate draws an arc.
- x and y are number of pixels from the left and top border, and together form the center of the arc
- radius is the radius of the arc, in number of pixels
- startDeg and endDeg are the degrees (360 degrees in full circle) of the arc
- rotate defines the direction of the arc, 0 for clockwise, 1 for anti-clockwise
Bitmap Wedge x y radius startDeg endDeg shift rotate draws a wedge, essentially an arc with lines to the center
- x and y are number of pixels from the left and top border, and together form the center of the wedge
- radius is the radius of the edge, in number of pixels
- startDeg and endDeg are the degrees (360 degrees in full circle) of the wedge
- shift is the number of pixels that the wedge is moved centrifugally (away from the center). This is used in pie charts to separate the wedges of the pie
- rotate defines the direction of the wedge, 0 for clockwise, 1 for anti-clockwise
Plot Curve a b1 b2 b3 b4 b5 x1 x2 draws a polynomial curve
- The curve is y=a + b1x + b2x
^{2}+ b3x^{3}+ b4x^{4}+ b5x^{5}. Where higher power is not needed, 0 is used to represent the the coefficient b - The curve is drawn from data value x from x1 to x2
Plot Normal mean sd height draws a normal distribution curve
- mean and sd (Standard Deviation) are as in the data horizontal variable variable x
- height is the maximum height (where x=mean) of the curve as in the vertical variable y
Plain Colors
Table of colors used on this web site
Patterns of complementary colors
Explanations
This page provides the common tests and description for data with Gaussian (normal) distribution. The procedures, their description, formulae, and how they differed from those offered by R, are divided into the following sections.
Javascript Program
## 1. Basic description1.1. Sample size (n), mean, Standard Deviation, and Standard Error of the mean1.2. 95% confidence for the measurements, and for the mean 1.3. Percentile values at 5% intervals, including the median (50 ## 2. Common measurements of normality2.1. Skewness and its 95% confidence interval. In a normal distribution, the skewnwss is closed to zero(0). A significant skew exists when the 95% confidence interval does not include the 0 value. A positive skew (95% CI >0) means that, when compared with normal stribution, the data is skewed to the right, with a shorten left tail and prolonged right tail, while a negative value (95% CI <0) means the data has a long left tail and short right tail.2.2. Kurtosis and its 95% confidence interval should also be closed to 0 in normal distribution. A positive kurtosis means that, when compared with normal distribution, the data curve is narrower and taller, while a negative value means the data is flattened and widened 2.3. The chi suqare test based on a combination of skewness and kurtosis provides a test whether the data deviates significantly from normal distribution 2.4. Another common and easy test to dtermine significant deviation from normality is whether the 95% confidence of the mean overlaps the median value. In a normal distribution, the mean and median values should be close. If the 95% confidence interval of the mean does not overlap the median, then significant skewness exists ## 3. The goodness of fit test of normality3.1. Depending on the sample size, users can divided the data into groups according to their distances from the mean. The actual number in each group is compared with the expected number if the data is truely normally distributed, and tested against the chi square. The provides a test whether, overall, the data is similar to that expected from normal distribution. The numbers in each group and the expected numbers if the data is normally distributed, are displayed in a table.3.2. The same data is plotted as a frequency bar chart, and compared against the theoretical normal distribution curve.
In addition, the plot by the Javascript program differs from the automatic plot produced by the R program, as the R program does not enforce the data into groups according to Standard Deviation units (z) ## 3. The Komogorov-Smirnov One Sample TestThe data is first sorted in order of magnitude, then the theoretical cumulative probability for normal distribution is compared with the actual probability for each data point. All the differences are summed and tested for statistical significance. A table for cumulative cumulative probabilities, z values and actual measurement values, from the theoretical normal distribution and from the data sampled are tabulated to enable users to examine in details the relationship between the two## 4. The QQ PlotThe QQ plot is a visual display of the relationship between the theoretical normal distribution and the data. A search through Internet shows a variety of QQ charts, and all of them are provided for user to choose. They can be described as follows.- The classical, and the most common presentation is a plot between the cumulative probabilities between the theoretical normal distribution and the data. A line joining 0,0 and 1,1 represent the perfect normal distribution where theoretical and data concur.
A second reference line, in blue, is the regression line using data between the 25^{th}and 75^{th}percentiles is mpre representative of the data. Skewness is represented by the regression coeffieint deviatiates from 1 - Some refrerences use the z values (theoretical and data) instead of probability, as this separates the data better near the extreme of the range of values.
- Other used the actual measurements. This is really the same as the z values as one is a linear transform of the other
- R uses a procedure qqplot and qqline where the horizontal x variable is the theoretical z value, and the vertical y values are the actual data values. An extensive search failed to find reasons for such a plot, as it adds complexity and difficulty in interpretation. The Javascript program also offers this option in order to be compatible with R.
## ReferencesSkewness by Wikipedia https://en.wikipedia.org/wiki/Skewness Kurtosis by Wikipedia https://en.wikipedia.org/wiki/Kurtosis Siegel S, Castellan Jr. NJ (1988) Nonparametric statistics for the behavioral sciences. McGraw Hill Book Company New York ISBN 0-07-100326-6 p. 45-51; p. 51-55. Table of significance from: Massey FJ Jr. (1951) The Kolmogorov-Smirnov test for goodness of fit. Journal of American Statistical Association 40:70 NIST webpage http://www.itl.nist.gov/div898/handbook/eda/section3/eda35b.htm QStat page on standard error of skewness and kurtosis http://statgen.ncsu.edu/qtlcart/manual/node71.html QQ Plot by Wikipedia https://en.wikipedia.org/wiki/Q%E2%80%93Q_plot
MacroPlot Code
This panel presents the tests of normal distribution in R Codes.
# Data dat = c(4.06,2.46,4.03,1.65,-0.86,0.20,2.55,2.31,2.24,1.59,2.83,3.76,1.62,5.14,1.14, 2.39,3.29,3.04,2.10,4.41,2.47,1.54,1.73,1.06,1.09) Section 2. Defining z value to calculate 95% confidence intervals
pcCI = 95 #percent confidence interval zCI = -(qnorm((100 - 95)/200)) # 2 tail z for confidence interval Section 3. Mean, SD, SE, and 95% confidence intervals
n = length(dat) mean = mean(dat) sd = sd(dat) se = sd / sqrt(n) out = c(cat("n=",n," mean=",round(mean,4), " SD=",round(sd,4), " SE=",round(se,4))) out = c(cat(pcCI,"% CI for values=", round(mean - sd * zCI,4), " to ", round(mean + sd * zCI,4))) out = c(cat(pcCI,"% CI for mean=", round(mean - se * zCI,4), " to ", round(mean + se * zCI,4)))The results are as follows n= 25 mean= 2.3136 SD= 1.3501 SE= 0.27 95 % CI for values= -0.3326 to 4.9598 95 % CI for mean= 1.7844 to 2.8428 Section 4. Chi Sq test for normality based on Skewness Kurtosis
skew = sum((dat - mean)^3) / ((n - 1) * sd^3) seSkew = sqrt(6 / n) out = c(cat("skew=", round(skew,4), "SE=", round(seSkew,4), pcCI,"% CI for skew=", round(skew - seSkew * zCI,4), " to ", round(skew + seSkew * zCI,4))) kurt = sum((dat - mean)^4) / ((n - 1) * sd^4) - 3 seKurt = sqrt(24 / n) out = c(cat("kurtosis=", round(kurt,4), "SE=", round(seKurt,4), pcCI,"% CI for kurtosis=", round(kurt - seKurt * zCI,4), " to ", round(kurt + seKurt * zCI,4))) chiSq = n * skew^2 / 6 + n * kurt^2 /24 prob = pchisq(chiSq, df=2, lower.tail=FALSE) out = c(cat("Chi Square=", round(chiSq,4), "p=", round(prob,4)))The results are as follows skew= -0.0309 SE= 0.4899 95 % CI for skew= -0.9911 to 0.9292 kurtosis= -0.0413 SE= 0.9798 95 % CI for kurtosis= -1.9616 to 1.8791 Chi Square= 0.0058 p= 0.9971 Section 5. Percentiles
quantile(dat,c(seq(from = .05, to = .95,by = 0.05)), type = 1)The results are as follows. Please note the values are slightly different to that in the Javascript program, because of rounding calculations for array index. In the Javascript program, values are rounded down (3.5 rounded to 3) but in R it is rounded to the nearest intger (3.5 rounded to 4) 5% 10% 15% 20% 25% 30% 35% 40% 45% 50% 55% 60% 65% 70% 75% 80% 85% 90% 95% 0.20 1.06 1.09 1.14 1.59 1.62 1.65 1.73 2.24 2.31 2.39 2.47 2.55 2.83 3.04 3.29 4.03 4.06 4.41 Section 5.The One sample Komogorov-Smirnov Test for deviation from normality
ks.test(dat, "pnorm", mean=mean(dat), sd=sd(dat)) # Kolmogorove-Smirnov Test # plot cumulative probabilities cpDat <- sort((pnorm((dat-mean(dat)) / sd(dat)))) # vector of cumulative probabilities from data cpExp <- seq(1, n, by=1) for(i in 1:n) cpExp[i] = cpExp[i] / n # vector of cumulative probabilities in theory plot(x=cpExp, y=cpDat, pch = 16, # plot the 2 prbabilities xlab = "Cumulative Probability Expected", ylab = "Cumulative Probability Data") lines(x=c(0,1), y=c(0,1)) # Draw line of no differenceThe results are D = 0.1105, p-value = 0.8876 alternative hypothesis: two-sided Plot not shown here Additional plots Codes for 2 additional plots in R are provided. Please note: Each plots must be run separately, or the latest plot will obscure the previous one
h <- hist(dat) xfit <- seq(min(dat), max(dat), length = 40) yfit <- dnorm(xfit, mean = mean(dat), sd = sd(dat)) yfit <- yfit * diff(h$mids[1:2]) * length(dat) lines(xfit, yfit, col = "black", lwd = 2) Additional Plot 2 QQ Plot. The QQ plot is a standard statistical method of plotting the data against expected values if it is normally distributed. The QQ plot is different to the Kolmogorov-Smirnov (ks) plot, as it uses quartile values while the ks plot uses cumulative probabilities. Both serve the same purpose of allowing user to view how well the data conforms to normal distribution in its entire range, but the axis and the exact values are not the same.
#qqnorm(dat, pch = 1, frame = FALSE) #qqline(dat, col = "steelblue", lwd = 2) qqnorm(dat, pch = 1) qqline(dat) |