Statistics - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Statistics and Data Analysis : Statistics Package : Regression : Statistics/PolynomialFit

Statistics

  

PolynomialFit

  

fit a polynomial to data

 

Calling Sequence

Parameters

Description

Options

Notes

Examples

Compatibility

Calling Sequence

PolynomialFit(d, X, Y, v, options)

PolynomialFit(d, XY, v, options)

Parameters

d

-

posint; degree of polynomial model function

X

-

Vector; values of independent variable

Y

-

Vector; values of dependent variable

XY

-

Matrix; values of independent and dependent variables

v

-

name; (optional) independent variable name

options

-

(optional) equation(s) of the form option=value where option is one of output, summarize, svdtolerance or weights; specify options for the PolynomialFit command

Description

• 

The PolynomialFit command fits a univariate polynomial to data by minimizing the least-squares error.  Consider a model polynomial px of independent variable x and a dependent variable y.  Given k data points, where each point is a pair of numerical values for x,y, this command finds coefficients of px such that the sum of the k residuals squared is minimized.  The ith residual is the value ypx at the ith data point.

• 

The first parameter d is the degree of px.

• 

In the first calling sequence, the second parameter X is a Vector containing the k values of the independent variable x, and the third parameter Y is a Vector containing the k values of the dependent variable y. In the second calling sequence XY is a Matrix with two columns, where the first column corresponds to X and the second column to Y. For X, Y, and XY, one can also use lists or Arrays; for details, see the Input Forms help page.

• 

By default, the PolynomialFit command returns a Vector of dimension d+1 containing the coefficients of the polynomial resulting in the best fit, ordered from lowest to highest degree.  If the optional parameter v is provided, then a polynomial in this variable name is returned instead.

• 

By default, either the least-squares polynomial or a Vector containing the parameter values is returned, depending on the input arguments. Additional results or a solution module that allows you to query for various settings and results can be obtained with the output option.  For more information, see the Statistics/Regression/Solution help page.

• 

Weights for the data points can be supplied through the weights option.

Options

  

The options argument can contain one or more of the options shown below.  These options are described in more detail on the Statistics/Regression/Options help page.

• 

output = name or string --  Specify the form of the solution.  The output option can take as a value the name solutionmodule, or one of the following names (or a list of these names): AtkinsonTstatistic, confidenceintervals, CookDstatistic, degreesoffreedom, externallystandardizedresiduals, internallystandardizedresiduals, leastsquaresfunction, leverages, parametervalues, parametervector, residuals, residualmeansquare, residualstandarddeviation, residualsumofsquares, rsquared, rsquaredadjusted, standarderrors, tprobability, tvalue, variancecovariancematrix. For more information, see the Statistics/Regression/Solution help page.

• 

summarize = identical( true, false, embed ) -- Display a summary of the regression model

• 

svdtolerance = realcons(nonnegative) -- Set the tolerance that determines whether a singular-value decomposition is performed.

• 

weights = Vector -- Provide weights for the data points.

Notes

• 

The underlying computation is done in floating-point; therefore, all data points must have type realcons and all returned solutions are floating-point, even if the problem is specified with exact values.  For more information about numeric computation in the Statistics package, see the Statistics/Computation help page.

• 

The PolynomialFit command uses various methods implemented in a built-in library provided by the Numerical Algorithms Group (NAG).  Normally, a method using QR decomposition is applied.  If it is determined that the system does not have full rank, then a singular-value decomposition (SVD) is performed. The svdtolerance option allows you to specify when an SVD should be performed.  See the Statistics/Regression/Options help page for additional details.

Examples

withStatistics:

XVector1,2,3,4,5,6,datatype=float:

YVector2,3,4,3.5,5.8,7,datatype=float:

PolynomialFit2,X,Y

1.960000000000000.1649999999999990.110714285714286

(1)

PolynomialFit2,X,Y,v

1.96000000000000+0.164999999999999v+0.110714285714286v2

(2)

Use the summarize=true option to return a summary of the regression:

lsPolynomialFit2,X,Y,v,summarize=true:

Summary:
----------------
Model: 1.9600000+.16500000*v+.11071429*v^2
----------------
Coefficients:
              Estimate  Std. Error  t-value  P(>|t|)
Parameter 1    1.9600    1.1720      1.6724   0.1930
Parameter 2    0.1650    0.7667      0.2152   0.8434
Parameter 3    0.1107    0.1072      1.0325   0.3778
----------------
R-squared: 0.9252, Adjusted R-squared: 0.8753

ls

1.96000000000000+0.164999999999999v+0.110714285714286v2

(3)

Use the output=solutionmodule option to see the full results.

mPolynomialFit2,X,Y,output=solutionmodule

m:=moduleexportResults,Settings;end module

(4)

m:-Results

residualmeansquare=0.429238095238095,residualsumofsquares=1.28771428571429,residualstandarddeviation=0.655162647926525,degreesoffreedom=3,parametervalues=1.960000000000000.1649999999999990.110714285714286,parametervector=1.960000000000000.1649999999999990.110714285714286,standarderrors=1.171990573665980.7667482580068000.107226158093964,confidenceintervals=1.76980025750745..5.689800257507462.27513724548285..2.605137245482840.230527496478056..0.451956067906628,rsquared=0.925169145624351,rsquaredadjusted=0.875281909373919,residuals=0.2357142857142860.2671428571428570.5485714285714290.8914285714285710.2471428571428570.0642857142857140,leverages=0.8214285714285720.3071428571428570.3714285714285710.3714285714285710.3071428571428570.821428571428572,variancecovariancematrix=1.373561904761900.8370142857142860.1073095238095240.8370142857142860.5879028911564630.08048214285714280.1073095238095240.08048214285714280.0114974489795918,internallystandardizedresiduals=0.8513943978432960.4898606875576461.056104119396911.716169194019980.4531866253875550.232198472139079,externallystandardizedresiduals=0.7982573178275230.4169943516423311.0879453019028910.37123092690660.3833809722980480.191316224811661,CookDstatistic=1.111471045041060.03545852305230700.2196913158044330.5801223807960790.03034796924225740.0826714000443752,AtkinsonTstatistic=1.712071210300520.2776377607337470.8363102061252447.972428631368750.2552577372751900.410327588921895,tvalue=1.67236839957606,0.215194489556356,1.03253056607013,tprobability=0.193045057943908,0.843415034784358,0.377768512636454

(5)

Compatibility

• 

The XY parameter was introduced in Maple 15.

• 

For more information on Maple 15 changes, see Updates in Maple 15.

• 

The Statistics[PolynomialFit] command was updated in Maple 2016.

• 

The summarize option was introduced in Maple 2016.

• 

For more information on Maple 2016 changes, see Updates in Maple 2016.

See Also

CurveFitting

Statistics

Statistics/Computation

Statistics/Regression

Statistics/Regression/InputForms

Statistics/Regression/Options

Statistics/Regression/Solution

 


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam