similaritytransform SciMax Toolbox simplified_output

SciMax Toolbox >> simple_linear_regression

simple_linear_regression

Maxima Function

Calling Sequence

simple_linear_regression (x)
simple_linear_regression(xoption_1)

Description

Simple linear regression, y_i=a+b x_i+e_i, where e_i are N(0,sigma) independent random variables. Argument x must be a two column matrix or a list of pairs.

Options:

The output of function simple_linear_regression is an inference_result Maxima object with the following results:

  1. 'model: the fitted equation. Useful to make new predictions. See examples bellow.

  2. 'means: bivariate mean.

  3. 'variances: variances of both variables.

  4. 'correlation: correlation coefficient.

  5. 'adc: adjusted determination coefficient.

  6. 'a_estimation: estimation of parameter a.

  7. 'a_conf_int: confidence interval of parameter a.

  8. 'b_estimation: estimation of parameter b.

  9. 'b_conf_int: confidence interval of parameter b.

  10. 'hypotheses: null and alternative hypotheses about parameter b.

  11. 'statistic: value of the sample statistic used for testing the null hypothesis.

  12. 'distribution: distribution of the sample statistic, together with its parameter.

  13. 'p_value: p-value of the test about b.

  14. 'v_estimation: unbiased variance estimation, or residual variance.

  15. 'v_conf_int: variance confidence interval.

  16. 'cond_mean_conf_int: confidence interval for the conditioned mean. See examples bellow.

  17. 'new_pred_conf_int: confidence interval for a new prediction. See examples bellow.

  18. 'residuals: list of pairs (prediction, residual), ordered with respect to predictions. This is useful for goodness of fit analysis. See examples bellow.

Only items 1, 4, 14, 9, 10, 11, 12, and 13 above, in this order, are shown by default. The rest remain hidden until the user makes use of functions items_inference and take_inference.

Example:

Fitting a linear model to a bivariate sample. Input %i4 plots the sample together with the regression line; input %i5 computes y given x=113; the means and the confidence interval for a new prediction when x=113 are also calculated.

(%i1) load("stats")$
(%i2) s:[[125,140.7], [130,155.1], [135,160.3], [140,167.2],
                                                [145,169.8]]$
(%i3) z:simple_linear_regression(s,conflevel=0.99);
           |               SIMPLE LINEAR REGRESSION
           |
           |   model = 1.405999999999985 x - 31.18999999999804
           |
           |           correlation = .9611685255255155
           |
           |           v_estimation = 13.57966666666665
           |
(%o3)      | b_conf_int = [.04469633662525263, 2.767303663374718]
           |
           |          hypotheses = H0: b = 0 ,H1: b # 0
           |
           |            statistic = 6.032686683658114
           |
           |            distribution = [student_t, 3]
           |
           |             p_value = 0.0038059549413203
(%i4) plot2d([[discrete, s], take_inference(model,z)],
        [x,120,150],
        [gnuplot_curve_styles, ["with points","with lines"]] )$
(%i5) take_inference(model,z), x=133;
(%o5)                         155.808
(%i6) take_inference(means,z);
(%o6)                     [135.0, 158.62]
(%i7) take_inference(new_pred_conf_int,z), x=133;
(%o7)              [132.0728595995113, 179.5431404004887]
similaritytransform SciMax Toolbox simplified_output