• Building pairwise regression in excel. Nonlinear Regression in Excel

    28 Oct

    Good afternoon, dear blog readers! Today we will talk about nonlinear regressions. Solution linear regressions can be viewed via LINK.

    This method used mainly in economic modeling and forecasting. Its goal is to observe and identify dependencies between two indicators.

    Main types nonlinear regressions are:

    • polynomial (quadratic, cubic);
    • hyperbolic;
    • sedate;
    • demonstrative;
    • logarithmic

    Various combinations can also be used. For example, for time series analytics in banking sector, insurance, and demographic studies use the Gompzer curve, which is a type of logarithmic regression.

    In forecasting using nonlinear regressions, the main thing is to find out the correlation coefficient, which will show us whether there is a close relationship between two parameters or not. As a rule, if the correlation coefficient is close to 1, then there is a connection, and the forecast will be quite accurate. One more important element nonlinear regressions is the average relative error ( A ), if it is in the interval<8…10%, значит модель достаточно точна.

    This is where we will probably finish the theoretical block and move on to practical calculations.

    We have a table of car sales over a period of 15 years (let's denote it X), the number of measurement steps will be the argument n, we also have revenue for these periods (let's denote it Y), we need to predict what the revenue will be in the future. Let's build the following table:

    For the study, we will need to solve the equation (dependence of Y on X): y=ax 2 +bx+c+e. This is a pairwise quadratic regression. In this case, we apply the least squares method to find out the unknown arguments - a, b, c. It will lead to a system of algebraic equations of the form:

    To solve this system, we will use, for example, Cramer’s method. We see that the sums included in the system are coefficients of the unknowns. To calculate them, we will add several columns to the table (D,E,F,G,H) and sign according to the meaning of the calculations - in column D we will square x, in E we will cube it, in F we will multiply the exponents x and y, in H we square x and multiply with y.

    You will get a table of the form filled with the things needed to solve the equation.

    Let's form a matrix A system consisting of coefficients for unknowns on the left sides of the equations. Let's place it in cell A22 and call it " A=". We follow the system of equations that we chose to solve the regression.

    That is, in cell B21 we must place the sum of the column where we raised the X indicator to the fourth power - F17. Let's just refer to the cell - “=F17”. Next, we need the sum of the column where X was cubed - E17, then we go strictly according to the system. Thus, we will need to fill out the entire matrix.

    In accordance with Cramer's algorithm, we will type a matrix A1, similar to A, in which, instead of the elements of the first column, the elements of the right sides of the system equations should be placed. That is, the sum of the X column squared multiplied by Y, the sum of the XY column and the sum of the Y column.

    We will also need two more matrices - let's call them A2 and A3 in which the second and third columns will consist of the coefficients of the right-hand sides of the equations. The picture will be like this.

    Following the chosen algorithm, we will need to calculate the values ​​of the determinants (determinants, D) of the resulting matrices. Let's use the MOPRED formula. We will place the results in cells J21:K24.

    We will calculate the coefficients of the equation according to Cramer in the cells opposite the corresponding determinants using the formula: a(in cell M22) - “=K22/K21”; b(in cell M23) - “=K23/K21”; With(in cell M24) - “=K24/K21”.

    We get our desired equation of paired quadratic regression:

    y=-0.074x 2 +2.151x+6.523

    Let us evaluate the closeness of the linear relationship using the correlation index.

    To calculate, add an additional column J to the table (let's call it y*). The calculation will be as follows (according to the regression equation we obtained) - “=$m$22*B2*B2+$M$23*B2+$M$24.” Let's place it in cell J2. All that remains is to drag the autofill marker down to cell J16.

    To calculate the sums (Y-Y average) 2, add columns K and L to the table with the corresponding formulas. We calculate the average for the Y column using the AVERAGE function.

    In cell K25 we will place the formula for calculating the correlation index - “=ROOT(1-(K17/L17))”.

    We see that the value of 0.959 is very close to 1, which means there is a close nonlinear relationship between sales and years.

    It remains to evaluate the quality of fit of the resulting quadratic regression equation (determination index). It is calculated using the formula for the squared correlation index. That is, the formula in cell K26 will be very simple - “=K25*K25”.

    The coefficient of 0.920 is close to 1, indicating a high quality of fit.

    The last step is to calculate the relative error. Let's add a column and enter the formula there: “=ABS((C2-J2)/C2), ABS - module, absolute value. Draw the marker down and in cell M18 display the average value (AVERAGE), assign a percentage format to the cells. The result obtained - 7.79% is within the acceptable error values<8…10%. Значит вычисления достаточно точны.

    If the need arises, we can build a graph using the obtained values.

    An example file is attached - LINK!

    Categories:// from 10/28/2017

    Regression in Excel

    Statistical data processing can also be carried out using the Analysis Package add-on in the “Service” menu sub-item. In Excel 2003, if you open SERVICE, we can’t find the tab DATA ANALYSIS, then click the left mouse button to open the tab SUPERSTRUCTURES and opposite the point ANALYSIS PACKAGE Click the left mouse button to put a check mark (Fig. 17).

    Rice. 17. Window SUPERSTRUCTURES

    After that in the menu SERVICE tab appears DATA ANALYSIS.

    In Excel 2007 to install ANALYSIS PACKAGE you need to click on the OFFICE button in the upper left corner of the sheet (Fig. 18a). Next, click on the button EXCEL SETTINGS. In the window that appears EXCEL SETTINGS left-click on the item SUPERSTRUCTURES and in the right side of the drop-down list select the item ANALYSIS PACKAGE. Next click on OK.


    Excel Options Office button

    Rice. 18. Installation ANALYSIS PACKAGE in Excel 2007

    To install the Analysis Package, click on the button GO, located at the bottom of the open window. A window will appear as shown in Fig. 12. Put a tick in front of ANALYSIS PACKAGE. In the tab DATA a button will appear DATA ANALYSIS(Fig. 19).

    From the suggested items, select the item “ REGRESSION" and click on it with the left mouse button. Next, click OK.

    A window will appear as shown in Fig. 21

    Analysis Tool " REGRESSION» is used to fit a graph to a set of observations using the least squares method. Regression is used to analyze the effect on a single dependent variable of the values ​​of one or more independent variables. For example, several factors influence an athlete's athletic performance, including age, height, and weight. It is possible to calculate the degree to which each of these three factors influences an athlete's performance, and then use that data to predict the performance of another athlete.

    The Regression tool uses the function LINEST.

    REGRESSION Dialog Box

    Labels Select the check box if the first row or first column of the input range contains headings. Clear this check box if there are no headers. In this case, suitable headers for the output table data will be created automatically.

    Reliability Level Select the check box to include an additional level in the output summary table. In the appropriate field, enter the confidence level that you want to apply, in addition to the default 95% level.

    Constant - zero Select the checkbox to force the regression line to pass through the origin.

    Output Range Enter the reference to the top left cell of the output range. Provide at least seven columns for the output summary table, which will include: ANOVA results, coefficients, standard error of the Y calculation, standard deviations, number of observations, standard errors for coefficients.

    New Worksheet Select this option to open a new worksheet in the workbook and paste the analysis results, starting in cell A1. If necessary, enter a name for the new sheet in the field located opposite the corresponding radio button.

    New Workbook Select this option to create a new workbook with the results added to a new worksheet.

    Residuals Select the check box to include residuals in the output table.

    Standardized Residuals Select the check box to include standardized residuals in the output table.

    Residual Plot Select the check box to plot the residuals for each independent variable.

    Fit Plot Select the check box to plot the predicted versus observed values.

    Normal probability plot Select the checkbox to plot a normal probability graph.

    Function LINEST

    To carry out calculations, select with the cursor the cell in which we want to display the average value and press the = key on the keyboard. Next, in the Name field, indicate the desired function, for example AVERAGE(Fig. 22).


    Rice. 22 Finding functions in Excel 2003

    If in the field NAME the name of the function does not appear, then left-click on the triangle next to the field, after which a window with a list of functions will appear. If this function is not in the list, then left-click on the list item OTHER FUNCTIONS, a dialog box will appear FUNCTION MASTER, in which, using vertical scrolling, select the desired function, highlight it with the cursor and click on OK(Fig. 23).

    Rice. 23. Function Wizard

    To search for a function in Excel 2007, any tab can be opened in the menu; then to carry out calculations, select with the cursor the cell in which we want to display the average value and press the = key on the keyboard. Next, in the Name field, specify the function AVERAGE. The window for calculating the function is similar to that shown in Excel 2003.

    You can also select the Formulas tab and left-click on the button in the menu “ INSERT FUNCTION"(Fig. 24), a window will appear FUNCTION MASTER, the appearance of which is similar to Excel 2003. Also in the menu you can immediately select a category of functions (recently used, financial, logical, text, date and time, mathematical, other functions) in which we will search for the desired function.

    Other functions Links and Arrays Mathematical

    Rice. 24 Selecting a function in Excel 2007

    Function LINEST calculates statistics for a series using the method of least squares to calculate the straight line that best approximates the available data and then returns an array that describes the resulting straight line. You can also combine the function LINEST with other functions to compute other kinds of models that are linear in unknown parameters (whose unknown parameters are linear), including polynomial, logarithmic, exponential, and power series. Because an array of values ​​is returned, the function must be specified as an array formula.

    The equation for a straight line is:

    (in case of several ranges of x values),

    where the dependent value y is a function of the independent value x, the m values ​​are the coefficients corresponding to each independent variable x, and b is a constant. Note that y, x and m can be vectors. Function LINEST returns an array . LINEST may also return additional regression statistics.

    LINEST(known_values_y; known_values_x; const; statistics)

    Known_y_values ​​is the set of y-values ​​that are already known for the relation.

    If the known_y_values ​​array has one column, then each column in the known_x_values ​​array is treated as a separate variable.

    If the known_y_values ​​array has one row, then each row in the known_x_values ​​array is treated as a separate variable.

    Known_x-values ​​are an optional set of x-values ​​that are already known for the relationship.

    The array known_x_values ​​can contain one or more sets of variables. If only one variable is used, then the known_y_values ​​and known_x_values ​​arrays can have any shape - as long as they have the same dimension. If more than one variable is used, then known_y_values ​​must be a vector (that is, an interval one row high or one column wide).

    If array_known_x_values ​​is omitted, then the array (1;2;3;...) is assumed to be the same size as array_known_values_y.

    Const is a boolean value that specifies whether the constant b is required to be equal to 0.

    If the argument "const" is TRUE or omitted, then the constant b is evaluated as usual.

    If the “const” argument is FALSE, then the value of b is set to 0 and the values ​​of m are selected in such a way that the relation is satisfied.

    Statistics - A boolean value that indicates whether additional regression statistics should be returned.

    If statistics is TRUE, LINEST returns additional regression statistics. The returned array will look like this: (mn;mn-1;...;m1;b:sen;sen-1;...;se1;seb:r2;sey:F;df:ssreg;ssresid).

    If statistics is FALSE or omitted, LINEST returns only the coefficients m and the constant b.

    Additional regression statistics.

    Magnitude Description se1,se2,...,sen Standard error values ​​for coefficients m1,m2,...,mn. seb Standard error value for constant b (seb = #N/A if const is FALSE). r2 Coefficient of determinism. The actual values ​​of y and the values ​​obtained from the equation of the line are compared; Based on the comparison results, the coefficient of determinism is calculated, normalized from 0 to 1. If it is equal to 1, then there is a complete correlation with the model, i.e., there is no difference between the actual and estimated values ​​of y. In the opposite case, if the coefficient of determination is 0, there is no point in using the regression equation to predict the values ​​of y. For more information about how to calculate r2, see the “Notes” at the end of this section. sey Standard error for estimating y. F F-statistic or F-observed value. The F statistic is used to determine whether an observed relationship between a dependent and independent variable is due to chance. df Degrees of freedom. Degrees of freedom are useful for finding F-critical values ​​in a statistical table. To determine the confidence level of the model, you must compare the values ​​in the table with the F statistic returned by the LINEST function. For more information about calculating df, see the “Notes” at the end of this section. Next, Example 4 shows the use of F and df values. ssreg Regression sum of squares. ssresid Residual sum of squares. For more information about calculating ssreg and ssresid, see the “Notes” at the end of this section.

    The figure below shows the order in which additional regression statistics are returned.

    Notes:

    Any straight line can be described by its slope and intersection with the y-axis:

    Slope (m): To determine the slope of a line, usually denoted by m, you take two points on the line and ; the slope will be equal to .

    Y-intercept (b): The y-intercept of a line, usually denoted b, is the y-value for the point at which the line intersects the y-axis.

    The equation of the straight line has the form . If the values ​​of m and b are known, then any point on the line can be calculated by substituting the values ​​of y or x into the equation. You can also use the TREND function.

    If there is only one independent variable x, you can obtain the slope and y-intercept directly using the following formulas:

    Slope: INDEX(LINEST(known_y_values; known_x_values); 1)

    Y-intercept: INDEX(LINEST(known_y_values; known_x_values); 2)

    The accuracy of the approximation using the straight line calculated by the LINEST function depends on the degree of data scatter. The closer the data is to a straight line, the more accurate the model used by the LINEST function. The LINEST function uses least squares to determine the best fit to the data. When there is only one independent variable x, m and b are calculated using the following formulas:

    where x and y are sample means, for example x = AVERAGE(known_x's) and y = AVERAGE(known_y's).

    The LINEST and LGRFPRIBL fitting functions can calculate the straight line or exponential curve that best fits the data. However, they do not answer the question of which of the two results is more suitable for solving the problem. You can also evaluate the TREND(known_y's; known_x's) function for a straight line or the GROW(known_y's; known_x's) function for an exponential curve. These functions, unless new_x-values ​​are specified, return an array of calculated y-values ​​for the actual x-values ​​along a line or curve. You can then compare the calculated values ​​with the actual values. You can also create charts for visual comparison.

    When performing regression analysis, Microsoft Excel calculates, for each point, the square of the difference between the predicted y value and the actual y value. The sum of these squared differences is called the residual sum of squares (ssresid). Microsoft Excel then calculates the total sum of squares (sstotal). If const = TRUE or the value of this argument is not specified, the total sum of squares will be equal to the sum of the squares of the differences between the actual y values ​​and the average y values. When const = FALSE, the total sum of squares will be equal to the sum of squares of the real y values ​​(without subtracting the average y value from the partial y value). The regression sum of squares can then be calculated as follows: ssreg = sstotal - ssresid. The smaller the residual sum of squares, the greater the value of the coefficient of determination r2, which shows how well the equation obtained using regression analysis explains the relationships between variables. The coefficient r2 is equal to ssreg/sstotal.

    In some cases, one or more X columns (let the Y and X values ​​be in columns) have no additional predicative value in other X columns. In other words, removing one or more X columns may result in Y values ​​calculated with the same precision. In this case, the redundant X columns will be excluded from the regression model. This phenomenon is called "collinearity" because the redundant columns of X can be represented as the sum of several non-redundant columns. The LINEST function checks for collinearity and removes any redundant X columns from the regression model if it detects them. Removed X columns can be identified in LINEST output by a factor of 0 and a se value of 0. Removing one or more columns as redundant changes the value of df because it depends on the number of X columns actually used for predictive purposes. For more information on calculating df, see Example 4 below. When df changes due to the removal of redundant columns, the values ​​of sey and F also change. It is not recommended to use collinearity often. However, it should be used if some X columns contain 0 or 1 as an indicator indicating whether the subject of the experiment belongs to a separate group. If const = TRUE or a value for this argument is not specified, LINEST inserts an additional X column to model the intersection point. If there is a column with values ​​of 1 for men and 0 for women, and there is a column with values ​​of 1 for women and 0 for men, then the last column is removed because its values ​​can be obtained from the "male indicator" column.

    The calculation of df for cases where X columns are not removed from the model due to collinearity occurs as follows: if there are k known_x columns and the value const = TRUE or not specified, then df = n – k – 1. If const = FALSE, then df = n - k. In both cases, removing the X columns due to collinearity increases the df value by 1.

    Formulas that return arrays must be entered as array formulas.

    When entering an array of constants as an argument, for example, known_x_values, you should use a semicolon to separate values ​​on the same line and a colon to separate lines. The separator characters may vary depending on the settings in the Language and Settings window in Control Panel.

    It should be noted that the y values ​​predicted by the regression equation may not be correct if they fall outside the range of the y values ​​that were used to define the equation.

    Basic algorithm used in the function LINEST, differs from the main function algorithm INCLINE And CUT. The difference between algorithms can lead to different results with uncertain and collinear data. For example, if the known_y_values ​​argument data points are 0 and the known_x_values ​​argument data points are 1, then:

    Function LINEST returns a value equal to 0. Function algorithm LINEST is used to return suitable values ​​for collinear data, and in this case at least one answer can be found.

    The SLOPE and LINE functions return the #DIV/0! error. The algorithm of the SLOPE and INTERCEPT functions is used to find only one answer, but in this case there may be several.

    In addition to calculating statistics for other types of regression, LINEST can be used to calculate ranges for other types of regression by entering functions of the x and y variables as series of the x and y variables for LINEST. For example, the following formula:

    LINEST(y_values, x_values^COLUMN($A:$C))

    works by having one column of Y values ​​and one column of X values ​​to calculate a cube approximation (3rd degree polynomial) of the following form:

    The formula can be modified to calculate other types of regression, but in some cases the output values ​​and other statistics may need to be adjusted.

    The regression line is a graphical reflection of the relationship between phenomena. You can very clearly build a regression line in Excel.

    To do this you need:

    1.Open Excel

    2.Create data columns. In our example, we will build a regression line, or relationship, between aggressiveness and self-doubt in first-graders. 30 children participated in the experiment, the data is presented in the Excel table:

    1 column - subject number

    2 column - aggressiveness in points

    3 column - self-doubt in points

    3.Then you need to select both columns (without the column name), click tab insert , choose spot , and choose the very first one from the proposed layouts dot with markers .

    4. So we have a template for the regression line - the so-called - scatter plot. To go to the regression line, you need to click on the resulting figure, press tab constructor, find on the panel chart layouts and choose M A ket9 , it also says f(x)

    5. So, we have a regression line. The graph also shows its equation and the square of the correlation coefficient

    6. All that remains is to add the name of the graph and the name of the axes. Also, if desired, you can remove the legend, reduce the number of horizontal grid lines (tab layout , then net ). Basic changes and settings are made in the tab Layout

    The regression line was constructed in MS Excel. Now you can add it to the text of the work.

    Regression and correlation analysis are statistical research methods. These are the most common ways to show the dependence of a parameter on one or more independent variables.

    Below, using specific practical examples, we will consider these two very popular analyzes among economists. We will also give an example of obtaining results when combining them.

    Regression Analysis in Excel

    Shows the influence of some values ​​(independent, independent) on the dependent variable. For example, how does the number of economically active population depend on the number of enterprises, wages and other parameters. Or: how do foreign investments, energy prices, etc. affect the level of GDP.

    The result of the analysis allows you to highlight priorities. And based on the main factors, predict, plan the development of priority areas, and make management decisions.

    Regression happens:

    • linear (y = a + bx);
    • parabolic (y = a + bx + cx 2);
    • exponential (y = a * exp(bx));
    • power (y = a*x^b);
    • hyperbolic (y = b/x + a);
    • logarithmic (y = b * 1n(x) + a);
    • exponential (y = a * b^x).

    Let's look at an example of building a regression model in Excel and interpreting the results. Let's take the linear type of regression.

    Task. At 6 enterprises, the average monthly salary and the number of quitting employees were analyzed. It is necessary to determine the dependence of the number of quitting employees on the average salary.

    The linear regression model looks like this:

    Y = a 0 + a 1 x 1 +…+a k x k.

    Where a are regression coefficients, x are influencing variables, k is the number of factors.

    In our example, Y is the indicator of quitting employees. The influencing factor is wages (x).

    Excel has built-in functions that can help you calculate the parameters of a linear regression model. But the “Analysis Package” add-on will do this faster.

    We activate a powerful analytical tool:

    Once activated, the add-on will be available in the Data tab.

    Now let's do the regression analysis itself.



    First of all, we pay attention to R-squared and coefficients.

    R-squared is the coefficient of determination. In our example – 0.755, or 75.5%. This means that the calculated parameters of the model explain 75.5% of the relationship between the studied parameters. The higher the coefficient of determination, the better the model. Good - above 0.8. Bad – less than 0.5 (such an analysis can hardly be considered reasonable). In our example – “not bad”.

    The coefficient 64.1428 shows what Y will be if all variables in the model under consideration are equal to 0. That is, the value of the analyzed parameter is also influenced by other factors not described in the model.

    The coefficient -0.16285 shows the weight of variable X on Y. That is, the average monthly salary within this model affects the number of quitters with a weight of -0.16285 (this is a small degree of influence). The “-” sign indicates a negative impact: the higher the salary, the fewer people quit. Which is fair.

    

    Correlation Analysis in Excel

    Correlation analysis helps determine whether there is a relationship between indicators in one or two samples. For example, between the operating time of a machine and the cost of repairs, the price of equipment and the duration of operation, the height and weight of children, etc.

    If there is a connection, then does an increase in one parameter lead to an increase (positive correlation) or a decrease (negative) of the other. Correlation analysis helps the analyst determine whether the value of one indicator can be used to predict the possible value of another.

    The correlation coefficient is denoted by r. Varies from +1 to -1. The classification of correlations for different areas will be different. When the coefficient is 0, there is no linear relationship between samples.

    Let's look at how to find the correlation coefficient using Excel.

    To find paired coefficients, the CORREL function is used.

    Objective: Determine whether there is a relationship between the operating time of a lathe and the cost of its maintenance.

    Place the cursor in any cell and press the fx button.

    1. In the “Statistical” category, select the CORREL function.
    2. Argument “Array 1” - the first range of values ​​– machine operating time: A2:A14.
    3. Argument “Array 2” - second range of values ​​– repair cost: B2:B14. Click OK.

    To determine the type of connection, you need to look at the absolute number of the coefficient (each field of activity has its own scale).

    For correlation analysis of several parameters (more than 2), it is more convenient to use “Data Analysis” (the “Analysis Package” add-on). You need to select correlation from the list and designate the array. All.

    The resulting coefficients will be displayed in the correlation matrix. Like this:

    Correlation and regression analysis

    In practice, these two techniques are often used together.

    Example:


    Now the regression analysis data has become visible.

    Regression analysis is one of the most popular methods of statistical research. It can be used to establish the degree of influence of independent variables on the dependent variable. Microsoft Excel has tools designed to perform this type of analysis. Let's look at what they are and how to use them.

    Connecting the analysis package

    But, in order to use the function that allows you to perform regression analysis, you first need to activate the Analysis Package. Only then the tools necessary for this procedure will appear on the Excel ribbon.

    1. Move to the “File” tab.
    2. Go to the “Settings” section.
    3. The Excel Options window opens. Go to the “Add-ons” subsection.
    4. At the very bottom of the window that opens, move the switch in the “Management” block to the “Excel Add-ins” position, if it is in a different position. Click on the “Go” button.
    5. A window of available Excel add-ins opens. Check the box next to “Analysis Package”. Click on the “OK” button.

    Now, when we go to the “Data” tab, on the ribbon in the “Analysis” tool block we will see a new button - “Data Analysis”.

    Types of Regression Analysis

    There are several types of regressions:

    • parabolic;
    • sedate;
    • logarithmic;
    • exponential;
    • demonstrative;
    • hyperbolic;
    • linear regression.

    We will talk in more detail about performing the last type of regression analysis in Excel below.

    Linear Regression in Excel

    Below, as an example, is a table showing the average daily air temperature outside and the number of store customers for the corresponding working day. Let's find out using regression analysis exactly how weather conditions in the form of air temperature can affect the attendance of a retail establishment.

    The general linear regression equation is as follows: Y = a0 + a1x1 +…+ akhk. In this formula, Y means the variable on which we are trying to study the influence of factors. In our case, this is the number of buyers. The value of x is the various factors that influence the variable. The parameters a are the regression coefficients. That is, they are the ones who determine the significance of a particular factor. The index k denotes the total number of these same factors.


    Analysis results analysis

    The results of the regression analysis are displayed in the form of a table in the place specified in the settings.

    One of the main indicators is R-squared. It indicates the quality of the model. In our case, this coefficient is 0.705 or about 70.5%. This is an acceptable level of quality. Dependency less than 0.5 is bad.

    Another important indicator is located in the cell at the intersection of the “Y-intersection” row and the “Coefficients” column. This indicates what value Y will have, and in our case, this is the number of buyers, with all other factors equal to zero. In this table, this value is 58.04.

    The value at the intersection of the columns “Variable X1” and “Coefficients” shows the level of dependence of Y on X. In our case, this is the level of dependence of the number of store customers on temperature. A coefficient of 1.31 is considered a fairly high influence indicator.

    As you can see, using Microsoft Excel it is quite easy to create a regression analysis table. But only a trained person can work with the output data and understand its essence.

    We are glad that we were able to help you solve the problem.

    Ask your question in the comments, describing the essence of the problem in detail. Our specialists will try to answer as quickly as possible.

    Did this article help you?

    The linear regression method allows us to describe a straight line that best fits a series of ordered pairs (x, y). The equation for a straight line, known as the linear equation, is given below:

    ŷ - expected value of y for a given value of x,

    x - independent variable,

    a - segment on the y-axis for a straight line,

    b is the slope of the straight line.

    This concept is presented graphically in the figure below:

    The figure above shows the line described by the equation ŷ =2+0.5x. The y-intercept is the point at which the line intersects the y-axis; in our case, a = 2. The slope of the line, b, the ratio of the rise of the line to the length of the line, has a value of 0.5. A positive slope means the line rises from left to right. If b = 0, the line is horizontal, which means there is no relationship between the dependent and independent variables. In other words, changing the value of x does not affect the value of y.

    ŷ and y are often confused. The graph shows 6 ordered pairs of points and a line, according to the given equation

    This figure shows the point corresponding to the ordered pair x = 2 and y = 4. Note that the expected value of y according to the line at X= 2 is ŷ. We can confirm this with the following equation:

    ŷ = 2 + 0.5х =2 +0.5(2) =3.

    The y value represents the actual point and the ŷ value is the expected value of y using a linear equation for a given value of x.

    The next step is to determine the linear equation that best matches the set of ordered pairs, we talked about this in the previous article, where we determined the form of the equation using the least squares method.

    Using Excel to Define Linear Regression

    In order to use the regression analysis tool built into Excel, you must activate the add-in Analysis package. You can find it by clicking on the tab File -> Options(2007+), in the dialog box that appears OptionsExcel go to the tab Add-ons. In the field Control choose Add-onsExcel and click Go. In the window that appears, check the box next to Analysis package, click OK.

    In the tab Data in a group Analysis a new button will appear Data analysis.

    To demonstrate how the add-in works, let's use data from a previous article, where a guy and a girl share a table in the bathroom. Enter the data from our bathtub example in Columns A and B of the blank sheet.

    Go to the tab Data, in a group Analysis click Data analysis. In the window that appears Data Analysis select Regression as shown in the figure and click OK.

    Set the necessary regression parameters in the window Regression as shown in the picture:

    Click OK. The figure below shows the results obtained:

    These results are consistent with those we obtained by doing our own calculations in the previous article.

    Regression analysis is a statistical research method that allows you to show the dependence of a particular parameter on one or more independent variables. In the pre-computer era, its use was quite difficult, especially when it came to large volumes of data. Today, having learned how to build regression in Excel, you can solve complex statistical problems in just a couple of minutes. Below are specific examples from the field of economics.

    Types of Regression

    This concept itself was introduced into mathematics by Francis Galton in 1886. Regression happens:

    • linear;
    • parabolic;
    • sedate;
    • exponential;
    • hyperbolic;
    • demonstrative;
    • logarithmic.

    Example 1

    Let's consider the problem of determining the dependence of the number of team members who quit on the average salary at 6 industrial enterprises.

    Task. At six enterprises, the average monthly salary and the number of employees who quit voluntarily were analyzed. In tabular form we have:

    For the task of determining the dependence of the number of quitting workers on the average salary at 6 enterprises, the regression model has the form of the equation Y = a0 + a1×1 +…+аkxk, where хi are the influencing variables, ai are the regression coefficients, and k is the number of factors.

    For this task, Y is the indicator of employees who quit, and the influencing factor is salary, which we denote by X.

    Using the capabilities of the Excel spreadsheet processor

    Regression analysis in Excel must be preceded by applying built-in functions to existing tabular data. However, for these purposes it is better to use the very useful “Analysis Pack” add-on. To activate it you need:

    • from the “File” tab go to the “Options” section;
    • in the window that opens, select the line “Add-ons”;
    • click on the “Go” button located below, to the right of the “Management” line;
    • check the box next to the name “Analysis package” and confirm your actions by clicking “Ok”.

    If everything is done correctly, the required button will appear on the right side of the “Data” tab, located above the Excel worksheet.

    Linear Regression in Excel

    Now that we have all the necessary virtual tools at hand to carry out econometric calculations, we can begin to solve our problem. To do this:

    • Click on the “Data Analysis” button;
    • in the window that opens, click on the “Regression” button;
    • in the tab that appears, enter the range of values ​​for Y (the number of quitting employees) and for X (their salaries);
    • We confirm our actions by pressing the “Ok” button.

    As a result, the program will automatically fill a new spreadsheet with regression analysis data. Pay attention! Excel allows you to manually set the location you prefer for this purpose. For example, this could be the same sheet where the Y and X values ​​are located, or even a new workbook specifically designed to store such data.

    Analysis of regression results for R-squared

    In Excel, the data obtained during processing of the data in the example under consideration has the form:

    First of all, you should pay attention to the R-squared value. It represents the coefficient of determination. In this example, R-square = 0.755 (75.5%), i.e., the calculated parameters of the model explain the relationship between the parameters under consideration by 75.5%. The higher the value of the coefficient of determination, the more suitable the selected model is for a specific task. It is considered to correctly describe the real situation when the R-square value is above 0.8. If R-squared is tcr, then the hypothesis about the insignificance of the free term of the linear equation is rejected.

    In the problem under consideration for the free term, using Excel tools, it was obtained that t = 169.20903, and p = 2.89E-12, i.e., we have zero probability that the correct hypothesis about the insignificance of the free term will be rejected. For the coefficient for the unknown t=5.79405, and p=0.001158. In other words, the probability that the correct hypothesis about the insignificance of the coefficient for an unknown will be rejected is 0.12%.

    Thus, it can be argued that the resulting linear regression equation is adequate.

    The problem of the feasibility of purchasing a block of shares

    Multiple regression in Excel is performed using the same Data Analysis tool. Let's consider a specific application problem.

    The management of the NNN company must decide on the advisability of purchasing a 20% stake in MMM JSC. The cost of the package (SP) is 70 million US dollars. NNN specialists have collected data on similar transactions. It was decided to evaluate the value of the shareholding according to such parameters, expressed in millions of US dollars, as:

    • accounts payable (VK);
    • annual turnover volume (VO);
    • accounts receivable (VD);
    • cost of fixed assets (COF).

    In addition, the parameter is used: the enterprise's salary arrears (V3 P) in thousands of US dollars.

    Solution using Excel spreadsheet processor

    First of all, you need to create a table of source data. It looks like this:

    • call the “Data Analysis” window;
    • select the “Regression” section;
    • In the “Input interval Y” box, enter the range of values ​​of the dependent variables from column G;
    • Click on the icon with a red arrow to the right of the “Input interval X” window and highlight the range of all values ​​​​from columns B, C, D, F on the sheet.

    Mark the “New worksheet” item and click “Ok”.

    Obtain a regression analysis for a given problem.

    Study of results and conclusions

    We “collect” the regression equation from the rounded data presented above on the Excel spreadsheet:

    SP = 0.103*SOF + 0.541*VO – 0.031*VK +0.405*VD +0.691*VZP – 265.844.

    In a more familiar mathematical form, it can be written as:

    y = 0.103*x1 + 0.541*x2 – 0.031*x3 +0.405*x4 +0.691*x5 – 265.844

    Data for MMM JSC are presented in the table:

    Substituting them into the regression equation, we get a figure of 64.72 million US dollars. This means that the shares of MMM JSC are not worth purchasing, since their value of 70 million US dollars is quite inflated.

    As you can see, the use of the Excel spreadsheet and the regression equation made it possible to make an informed decision regarding the feasibility of a very specific transaction.

    Now you know what regression is. The Excel examples discussed above will help you solve practical problems in the field of econometrics.