supsmu

supsmu smooths scatterplots using Friedman's supersmoother algorithm.

Syntax

Description

This function implements the supersmoother. This is basically the function supsmu written in MALTAB by Douglas M. Schwarz.

Email: dmschwarz=ieee*org, dmschwarz=urgrad*rochester*edu Real_email = regexprep(Email,{'=','*'},{'@','.'}) See the section "More About" of this file for the details of of the modifications which have been made.

example

smo =supsmu(x, y) Example of use of supsmu with all the default options.

example

smo =supsmu(x, y, Name, Value) Example of use of option Span.

Examples

expand all

  • Example of use of supsmu with all the default options.
  • x = linspace(0,1,201);
    y = sin(2.5*x) + 0.05*randn(1,201);
    smo = supsmu(x,y);
    plot(x,y,'o',x,smo)

  • Example of use of option Span.
  • x = linspace(0,1,201);
    y = sin(2.5*x) + 0.05*randn(1,201);
    smo = supsmu(x,y,'Span',0.3);
    smo1 = supsmu(x,y,'Span',0.5);
    smo2 = supsmu(x,y,'Span',0.7);
    plot(x,y,'o',x,[smo; smo1; smo2])
    legend({'Original data' 'span=0.3' 'span=0.5' 'span=0.7'},'Location','best')
    Click here for the graphical output of this example (link to Ro.S.A. website).

    Input Arguments

    expand all

    x — x values for smoothing. Vector.

    Predictor variable containing the abscissa values specified as a vector of length n, where n is the number of observations.

    Data Types: single| double

    y — y values for smoothing. Vector.

    Response variable which has to be smoothed, specified as a vector of length n, where n is the number of observations.

    Data Types: single| double

    Name-Value Pair Arguments

    Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

    Example: 'Weights',1:n , 'Span',0.2 , 'Period',1 , 'Alpha',5 , 'Unsorted',5

    Weights —weights for the observations.vector.

    Row or column vector of positive numbers of length n containing the weights associated to each observations. If w is not specified we assume $w=1$ for $i=1, 2, \ldots, n$.

    Example: 'Weights',1:n

    Data Types: double

    Span —fraction of the observations in the span.scalar.

    This option sets the width of a fixed-width smoothing operation relative to the number of data points, 0 < Span < 1.

    Setting this to be non-zero disables the supersmoother algorithm. Default is 0 (use supersmoother).

    Example: 'Span',0.2

    Data Types: double

    Period —Sets the period of periodic data.scalar.

    Default is Inf (infinity) which implies that the data is not periodic.

    Can also be set to zero for the same effect.

    Example: 'Period',1

    Data Types: double

    Alpha —Sets a small-span penalty to produce a greater smoothing effect.0 < Alpha < 10, where 0 does nothing and 10 produces the maximum effect.

    Default = 0. This parameter controls the smoothness of the fitted curve. Values up to 10 indicate increasing smoothness.

    Example: 'Alpha',5

    Data Types: double

    Unsorted —Sorted or unsorted data.boolean.

    If the data points are not already sorted in order of the x values then setting this to true will sort them.

    Default is false.

    Example: 'Unsorted',5

    Data Types: true

    Output Arguments

    expand all

    smo —smoothed values. Vector

    A vector with the same dimension of y containing smoothed values, that is the y values on the fitted curve.

    More About

    expand all

    Additional Details

    The supersmoother algorithm computes three separate smooth curves from the input data with symmetric spans of 0.05*n, 0.2*n and 0.5*n, where n is the number of data points. The best of the three smooth curves is chosen for each predicted point using leave-one-out cross validation. The best spans are then smoothed by a fixed-span smoother (span = 0.2*n) and the prediction is computed by linearly interpolating between the three smooth curves. This final smooth curve is then smmothed again with a fixed-span smoother (span = 0.05*n).

    According to comments by Friedman, "For small samples (n < 40) or if there are substantial serial correlations between observations close in x-value, then a prespecified fixed span smoother (span > 0) should be used. Reasonable span values are 0.2 to 0.4." This function is basically equal to the function supsmu written in MALTAB by Douglas M. Schwarz.

    Email: dmschwarz=ieee*org, dmschwarz=urgrad*rochester*edu Real_email = regexprep(Email,{'=','*'},{'@','.'}) The following modifications with respect to the original function have been made:


    [1] In case of constant values of x over a span program was producng NA. Modifications have been done in the subroutinesto cope with this case.


    [2] The formula for the cross validation residuals in presence of constant values has been introduced.


    [3] All the Mlint suggestions have been incorporated.


    [4] The help has been put inside the FSDA style.


    [5] A series of examples which explore the different options has been added.


    References

    Friedman, J. H. (1984). A Variable Span Smoother. Tech. Rep. No. 5, Laboratory for Computational Statistics, Dept. of Statistics, Stanford Univ., California.

    See Also

    | |

    This page has been automatically generated by our routine publishFS