# Scatter Charts and Regression

Since Version 1.2.1 of flashChart new types of charts is supported, scatter charts. A scatter chart or scattergraph is a type of mathematical diagram using Cartesian coordinates to display values for two variables for a set of data.

The data is displayed as a collection of points, each having the value of one variable determining the position on the horizontal axis and the value of the other variable determining the position on the vertical axis. This kind of plot is also called a scatter plot, scattergram, scatter diagram or scatter graph.

{tab Overview|primary}

A scatter plot can suggest various kinds of correlations between variables with a certain confidence interval. for example, weight and height, weight would be on x axis and height would be on the y axis. Correlations may be positive (rising), negative (falling), or null (uncorrelated). If the pattern of dots slopes from lower left to upper right, it suggests a positive correlation between the variables being studied. If the pattern of dots slopes from upper left to lower right, it suggests a negative correlation. A line of best fit (alternatively called 'trendline') can be drawn in order to study the correlation between the variables. An equation for the correlation between the variables can be determined by established best-fit procedures. For a linear correlation, the best-fit procedure is known as linear regression and is guaranteed to generate a correct solution in a finite time. No universal best-fit procedure is guaranteed to generate a correct solution for arbitrary relationships. A scatter plot is also very useful when we wish to see how two comparable data sets agree with each other. In this case, an identity line, i.e., a y=x line, or an 1:1 line, is often drawn as a reference. The more the two data sets agree, the more the scatters tend to concentrate in the vicinity of the identity line; if the two data sets are numerically identical, the scatters fall on the identity line exactly.

 {flashchart type="scatter_star" width="100%" "title="Arm Span vs. Height" x_legend="Arm Span (m)" y_legend="Height (m)" y_min="1.50" x_min="1.55" y_step="0.10" height="270" legend_fontsize="10" label_fontsize="9" data="1.56,1.57,1.59,1.60,1.61,1.62,1.65,1.70,1.70,1.73,1.73,1.77,1.77,1.78,1.84,1.88,1.88,1.88,1.88,1.88,1.94,1.96,2.00/ 1.62,1.60,1.62,1.55,1.62,1.70,1.66,1.70,1.67,1.85,1.76,1.73,1.76,1.78,1.80,1.88,1.87,1.82,1.81,1.92,1.93,1.84,1.86" show_regression_line="1" x_max="2.01" tooltip="Height: #val#m Arm Span: #x#m" title_style="font-size:12px; font-weight:bold; font-family:Sans-Serif,Arial,Helvetica; color:51698F;" number_format="d" x_axis_steps="0.05"}scatter_1{/flashchart} This scatter chart illustrates the general nature of the correlation between arm span and height - clicking (hiding) "Trend" this may show up not to be obvious). But reading from left to right on the horizontal scale, you can observe that narrow arm spans tend to be associated with people who are shorter, and wider arm spans tend to be associated with people who are taller -- that is, there appears to be an overall positive correlation between arm span and height.

One of the most powerful aspects of a scatter chart, however, is its ability to show nonlinear relationships between variables. Furthermore, if the data is represented by a mixture model of simple relationships, these relationships will be visually evident as superimposed patterns.

{tab Regression|primary}

### Regression

In statistics, regression analysis includes many techniques for modeling and analyzing several variables, when the focus is on the relationship between a dependent variable and one or more independent variables. More specifically, regression analysis helps one understand how the typical value of the dependent variable changes when any one of the independent variables is varied, while the other independent variables are held fixed.

Regression analysis is widely used for prediction and forecasting, where its use has substantial overlap with the field of machine learning. Regression analysis is also used to understand which among the independent variables are related to the dependent variable, and to explore the forms of these relationships. Please read more about regression analysis and related topics at Wikipedia.

If you request a scatter chart with flashChart you may also request for a basic regression analysis. flashChart provides three builtin calculations (all based on the linear regression model) which are described by following functions:

Please select choice in chart menu {flashchart title="Linear Regression" width="500" height="300" legend_fontsize="9" label_fontsize="9" precision="3" create_script="linear_regression" menu="Exponential Regression No1,exponential1_regression|Exponential Regression No2,exponential2_regression" type="scatter_box" show_regression_line="1" show_regression_formula="1" title_style="padding:10px; font-size: 12; color:51698F; font-weight:bold;" data="file" file="data/scatterdata_0.txt" number_format="d"}regression_types{/flashchart} {flashchart title="Exponential Regression 1" width="500" height="300" legend_fontsize="9" label_fontsize="9" precision="3" create_script="exponential1_regression" hide_chart="1" menu="Linear Regression,linear_regression|Exponential Regression No2,exponential2_regression" type="scatter_star" show_regression_line="1" show_regression_formula="1" title_style="padding:10px; font-size: 12; color:51698F; font-weight:bold;" data="file" file="data/scatterdata_1.txt" number_format="d"}regression_types{/flashchart} {flashchart title="Exponential Regression 2" width="500" height="300" legend_fontsize="9" precision="3" label_fontsize="9" create_script="exponential2_regression" hide_chart="1" menu="Linear Regression,linear_regression|Exponential Regression No1,exponential1_regression" type="scatter" show_regression_line="1" show_regression_formula="1" x_step="10" title_style="padding:10px; font-size: 12; color:51698F; font-weight:bold;" data="file" file="data/scatterdata_2.txt" number_format="d"}regression_types{/flashchart}
1. f(x) = ax + b (linear regression)
2. f(x) = abx (exponential regression)
3. f(x) = axb (exponential regression)
With flashChart's parameter show_regression_line set to "1" you will request a regression calculation and a regression line to be created and displayed on your scattter chart.
Additionally you may have with flashChart's parameter show_regression_formula the calculated formula to be displayed as legend (key). This legend will have assigned click-attribute key_onclick="toggle-visibility" (if you click it the regression line will be hidden or displayed).

Together with the regression formula flashChart will also display the calculated coefficient of determination as "R". The coefficient of determination is the proportion of variability in your data that is accounted for by the calculated formula (flashChart's statistical model) and it will range from "0" (no correlation) to "1" (perfect correlation).
"R" (correctly it should read "R2") is a statistic that will give some information about the goodness of fit of a model. In regression, the coefficient of determination is a statistical measure of how well, the regression line approximates the real data points. An "R" of 1.0 indicates that the regression line perfectly fits the data.

{tab Own Regression formula|primary}

### Own Regression formula

Flashchart's supplied regression schemes probably may not fit in any cases your data, therefore Flashchart allows to specify your own regression formula. The sample below shows a scenario where an own statistical model (a formula) is used to better reflect "measured reality". To use your own regression model (formula) you will have to specify parameter formula together with show_regression_line. You will find more information how to specify your own formula in flashCharts's documentation "Tutorial and Reference". More difficult may be finding the proper statistical model that fits your data. In the sample below I've setup a (fictious) measurement which will be described by the "known" model "f(x) = -0.8x3 + 100x2". If you do not know the (expected) behaviour of dependent/independent variables versus your measured data, flashChart may help with a first analysis.

{flashchart type="scatter_box" create_script="scatter_plot" menu="flashChart's Regression,flashchart_regression|Own formula,own_formula" data="file" file="data/scatterdata1.txt" width="500" label_fontsize="9" legend_fontsize="9" number_format="d" title_style="padding:10px; font-size: 12; color:51698F; font-weight:bold;" height="300" x_step="10" x_min="0" x_max="100" title="Law of Diminishing Returns" tooltip="x=#x# y=#val#" y_legend="Earnings" x_legend="Spendings" }test_formula{/flashchart} {flashchart type="scatter_box" create_script="flashchart_regression" menu="Scatter Plot,scatter_plot|Own formula,own_formula" hide_chart="1" precision="5" number_format="d" data="file" file="data/scatterdata1.txt" show_regression_line="1" show_regression_formula="1" width="500" label_fontsize="9" legend_fontsize="9" title_style="padding:10px; font-size: 12; color:51698F; font-weight:bold;" height="300" x_step="10" x_min="0" x_max="100" title="Law of Diminishing Returns" tooltip="x=#x# y=#val#" y_legend="Earnings" x_legend="Spendings" }test_formula{/flashchart} {flashchart type="scatter_box" formula="y=-0.8*x^3+100*x^2" create_script="own_formula" hide_chart="1" precision="5" number_format="d" menu="flashChart's Regression,flashchart_regression|Scatter Plot,scatter_plot" data="file" file="data/scatterdata1.txt" show_regression_line="1" show_regression_formula="1" width="500" label_fontsize="9" legend_fontsize="9" title_style="padding:10px; font-size: 12; color:51698F; font-weight:bold;" height="300" x_step="10" title="Law of Diminishing Returns" tooltip="x=#x# y=#val#" y_legend="Earnings" x_legend="Spendings" }test_formula{/flashchart}

The law of diminishing returns (also law of diminishing marginal returns or law of increasing relative cost) states that in all productive processes, adding more of one factor of production, while holding all others constant, will at some point yield lower per-unit returns. The law of diminishing returns does not imply that adding more of a factor will decrease the total production, a condition known as negative returns, though in fact this is common.

For example, the use of fertilizer improves crop production on farms and in gardens; but at some point, adding more and more fertilizer improves the yield less per unit of fertilizer, and excessive quantities can even reduce the yield. A common sort of example is adding more workers to a job, such as assembling a car on a factory floor. At some point, adding more workers causes problems such as getting in each other's way, or workers frequently find themselves waiting for access to a part. In all of these processes, producing one more unit of output per unit of time will eventually cost increasingly more, due to inputs being used less and less effectively.

{/tabs}

### Visitors

Today: 3
Yesterday: 45
This Week: 560
Last Week: 849
This Month: 2,575
Last Month: 2,574
0183689 28.1% USA 22.7% Germany 4.2% Russia 3.2% France 2.7% Italy 2.5% Indonesia 2.1% Poland

Total:

205

countries

We use cookies on our website. Some of them are essential for the operation of the site, while others help us to improve this site and the user experience (tracking cookies). You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.