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
The Concordance Correlation Coefficient (Lin, 1989), abbreviated as CCC or ρ
Javascript Program
_{c}, evaluates the degree to which pairs of observations fall on the 45 degree line (the line of no difference) through the origin of a 2 dimensional plot of the two measurements. Although it can be used to compare any two measuremenets of the same thing, it is particularly suitable to test a measurement against a gold standard.
There are plenty of references easily available (see references), so the rationale and details of calculations will not be repeated here. The wikipedia provides an excellent introduction, and the algorithm and symbols used on this page are based on Chapter 812 of PASS Sample Size Software, both readily accessible on the www.
The data is a matrix of 2 columns. Each row represents a case being measured. The two columns, separated by white space, are the paired measurements. If a gold standard is being compared, the gold standard is in the first (left) column. The default example data on this page are generated from the computer and not real. There are only 30 pairs, too few for proper evaluation, but easier to demonstrate in this example. The data are shown in the table to the right. It represents 30 paired measurements of blood pressure. The first column (v1) is the gold standard, intra-arterial catheter, and the right (v2) the measurement being compared, external electronic cuffed manometer.
Step 1 evaluates the basic parameters, in this example sample size n=30 pairs, mean μ Step 2 evaluates precisions and accuracies in detail - Precision, the variability of the relationship, is represented by the Pearson's correlation coefficient ρ=0.87
- Scale Shift, the ratio between the two Standard Deviations, ω = σ
_{v2}/ σ_{v1}= 1.01 - Effect Size, ratio of the difference between the two means and their combined variations, υ=abs(μ
_{v2}- μ_{v1}) / sqrt(σ_{v1}σ_{v2}) = 0.08 - Accuracy, a combination of scale shift and effect size, χ
_{a}=υ^{2}+ω+1/ω=0.997
Step 3 calculates Lin's Coefficient of Concordance and its 95% confidence interval - The Coefficient of Concordance is a combination of precision and accuracy, so that
Lin's Coefficient of Concordance ρ_{c}= ρυ = 0.86 - The 95% confidence intervals are calculated according to the complex algorithm described in the
Pass Manual, so that
95% Confidence Interval (2 tail) = 0.74 to 0.93, and 95% Confidence Interval (1 tail) = >0.76 or <0.93
According to McBride (see references)
The one tail lower border is usually used. In this example, the one tail lower border is 0.76, so the immediate interpretation is that the manometer measurement has a poor agreement with the gold standard intra-arterial measurement. A more detailed examination shows that the accuracy is high (χ ## ReferencesLin's Coefficient of Concordance
- McBride GB (2005) A proposal for strength-of-agreement criteria for Lin's Concordance Correlation Coefficient. NIWA Client Report: HAM2005-062. (PDF) [ https://www.medcalc.org/download/pdf/McBride2005.pdf]
- Lin L.I-K (1989) A concordance correlation coefficient to evaluate reproducibility. Biometrics 45:255-268. PubMed
- Lin L.I-K (2000) A note on the concordance correlation coefficient. Biometrics 56:324-325.
- [ https://en.wikipedia.org/wiki/Concordance_correlation_coefficient]
- Chapter 812 Lin's Concordance Correlation Coefficient. PASS Sample Size Software NCSS.com 812-1 NCSS, LLC. [ https://ncss-wpengine.netdna-ssl.com/wp-content/themes/ncss/pdf/Procedures/PASS/Lins_Concordance_Correlation_Coefficient.pdf]
- [https://services.niwa.co.nz/services/statistical/concordance An on line calculator]
- Morgan C J, Aban I. Methods for evaluating the agreement between diagnostic tests. Journal of Nuclear Cardiology (June 2016), Volume 23, Issue 3, pp 511-513 [ https://link.springer.com/article/10.1007/s12350-015-0175-7]
- [https://cran.r-project.org/web/packages/epiR/epiR.pdf] R package EpiR pdf p.28 for procedure epi.ccc which is Li's coefficient
This panel provides 3 algorithms for calculating Lin's Coefficient of Concordance
- Command codes in R from the epiR package provided by the R archive. Users may prefer this because the codes are short, and all the information provided
- The algorithm adapted from the software provided by PASS. This is the same program as that in the Javascript program. It is displayed here to double check the arithmatic of the Javascript program
- Shor code fragment reflecting the basic formula as described by Wikipedia, to ensure all the results are the same
The data to be used in all 3 algorithms
dat = (" 127 134 118 120 135 142 123 115 112 117 119 123 125 125 109 111 106 122 110 115 111 109 125 127 119 118 140 139 115 111 110 110 122 122 119 115 134 137 105 105 117 112 111 113 114 115 126 119 113 115 129 127 130 129 130 130 115 120 131 126 ") mx = read.table(textConnection(dat),header=FALSE) n = nrow(mx) y = mx[,1] # col 1 x = mx[,2] # col 2 Algorithm 1. Program from CRAN package epiR. Description of the epiR package is in https://cran.r-project.org/web/packages/epiR/epiR.pdf, and the function ccc in page 28.
for those intereste, the actual source codes are in https://rdrr.io/cran/epiR/src/R/epi.ccc.R
#install.packages("epiR") # if not install already library(epiR) res <- epi.ccc(x,y) resThe results are > res $rho.c est lower upper 1 0.8648005 0.7365011 0.9330389 $s.shift [1] 0.9921876 $l.shift [1] -0.08382324 $C.b [1] 0.9964686 $blalt mean delta 1 130.5 7 2 119.0 2 3 138.5 7 4 119.0 -8 5 114.5 5 6 121.0 4 7 125.0 0 8 110.0 2 9 114.0 16 10 112.5 5 11 110.0 -2 12 126.0 2 13 118.5 -1 14 139.5 -1 15 113.0 -4 16 110.0 0 17 122.0 0 18 117.0 -4 19 135.5 3 20 105.0 0 21 114.5 -5 22 112.0 2 23 114.5 1 24 122.5 -7 25 114.0 2 26 128.0 -2 27 129.5 -1 28 130.0 0 29 117.5 5 30 128.5 -5 $sblalt est delta.sd lower upper 1 0.7666667 4.782752 -8.607354 10.14069 $nmissing [1] 0 Algorithm 2. Algorithm adapted from PASS. This is the same algorithm as that in the Javascript program on this page, repeated here to check the arithematics
# PASS n = nrow(mx) y = mx[,1] # col 1 x = mx[,2] # col 2 print() n = nRow(mx) meanx = mean(x) meany = mean(y) sdx = sd(x) sdy = sd(y) r = cor(x, y, method = "pearson") print(paste("n=",n)) print(paste("mean x=",meanx, " SDx=",sdx)) print(paste("mean y=",meany, " SDy=",sdy)) print(paste("Pearson Correlation Coefficient (Precision, rho)=",r)) w = sdy / sdx; # scale shift v = abs(meanx - meany) / sqrt(sdx * sdy) # effect size chiA = 2 / (v^2 + w + 1/w) # accuracy rc = r * chiA # Lin's coefficient print(paste("Scale Shift omega=",w)) print(paste("Effect Size upsilon=",v)) print(paste("Accuracy chi=",chiA)) print(paste("Lin's Coefficient of Concordance=",rc)) # 95% confidence interval using Fisher's transformation zt = log((1 + rc) / (1 - rc)) / 2 a = 1 / (n - 2) b = ((1 - r^2) * rc^2) / ((1 - rc^2) * r^2) c = (2 * rc^3 * (1 - rc) * v^2) / (r * (1 - rc^2)^2) d = (rc^4 * v^4) / (2 * r^2 * (1 - rc^2)^2) varzt = a * (b + c - d) sezt = sqrt(varzt) z = 1.65 # one tail z of p=0.05 uz1 = zt + z * sezt lz1 = zt - z * sezt uc1 = (exp(2 * uz1) - 1) / (exp(2 * uz1) + 1) lc1 = (exp(2 * lz1) - 1) / (exp(2 * lz1) + 1) print(paste("95% Confidence Interval (1 tail) = >",lc1, " or <", uc1)) z = 1.96; # two tail z of p=0.025 uz2 = zt + z * sezt; lz2 = zt - z * sezt; uc2 = (exp(2 * uz2) - 1) / (exp(2 * uz2) + 1) lc2 = (exp(2 * lz2) - 1) / (exp(2 * lz2) + 1) print(paste("95% Confidence Interval (2 tail) = <=",lc2, " to ", uc2))The results are [1] "n= 30" [1] "mean x= 120.766666666667 SDx= 9.3391402296938" [1] "mean y= 120 SDy= 9.26617876826889" [1] "Pearson Correlation Coefficient (Precision, rho)= 0.867865264380953" > [1] "Scale Shift omega= 0.992187561206874" [1] "Effect Size upsilon= 0.082414342037823" [1] "Accuracy chi= 0.996584883709398" >[1] "Lin's Coefficient of Concordance= 0.864901403578517" [1] "95% Confidence Interval (1 tail) = > 0.762248991583839 or < 0.925115552803494" [1] "95% Confidence Interval (2 tail) = <= 0.736664402708045 to 0.933096358406987" > Algorithm 3: Calculations according to https://en.wikipedia.org/wiki/Concordance_correlation_coefficient Wikipedia. This is to check that the algorithm as adapted from PASS is the same as that described in the Wikipedia
meanx = mean(x) meany = mean(y) sdx = sd(x) sdy = sd(y) r = cor(x, y, method = "pearson") rhoc = (2 * r * sdx * sdy) / (sdx^2 + sdy^2 + (meanx - meany)^2) rhoc # Lin's coefficientThe result is as follows. Pleasr note that it is essentially the same as that from algorithm 1 except for rounding errors rhoc # Lin's coefficient [1] 0.8649014The same results are obtained from all 3 algorithms, except for minor diffrences in rounding errors
x = mx[,1] # col 2 y = mx[,2] # col 1 minx = min(x) maxx = max(x) miny = min(y) maxy = max(y) # Plot Data plot( # Command 1: Draw dots x = x, # x variable = average y = y, # y variable = difference pch = 16, # size of dot xlab = "col 1", # x label ylab = "col 2" # y lable ) lines(x = c(minx, maxx), y=c(miny,maxy)) # Command 2: Draw lineThe result plot is as follows |