fanplot

fanplot plots the fan plot for transformation in linear regression

Syntax

  • brushedUnits=fanplot(out)example
  • brushedUnits=fanplot(out,Name,Value)example

Description

example

brushedUnits =fanplot(out) fanplot with all default options.

example

brushedUnits =fanplot(out, Name, Value) fanplot with optional arguments.

Examples

expand all

  • fanplot with all default options.
  • load the wool data

    XX=load('wool.txt');
    y=XX(:,end);
    X=XX(:,1:end-1);
    % FSRfan and fanplot with all default options
    [out]=FSRfan(y,X);
    fanplot(out);
    Total estimated time to complete LMS:  0.39 seconds 
    ------------------------------
    Warning: Number of subsets without full rank equal to 16.8%
    Total estimated time to complete LMS:  0.03 seconds 
    ------------------------------
    Warning: Number of subsets without full rank equal to 16.8%
    Total estimated time to complete LMS:  0.04 seconds 
    ------------------------------
    Warning: Number of subsets without full rank equal to 16.8%
    Total estimated time to complete LMS:  0.02 seconds 
    ------------------------------
    Warning: Number of subsets without full rank equal to 16.8%
    Total estimated time to complete LMS:  0.03 seconds 
    ------------------------------
    Warning: Number of subsets without full rank equal to 16.8%
    
    Click here for the graphical output of this example (link to Ro.S.A. website). Graphical output could not be included in the installation file because toolboxes cannot be greater than 20MB. To load locally the image files, download zip file http://rosa.unipr.it/fsda/images.zip and unzip it to <tt>(docroot)/FSDA/images</tt> or simply run routine <tt>downloadGraphicalOutput.m</tt>

  • fanplot with optional arguments.
  • FSRfan and fanplot with specified lambda

    load('loyalty.txt');
    y=loyalty(:,4);
    X=loyalty(:,1:3);
    % la = vector contanining the most common values of the transformation
    % parameter
    la=[-1 -0.5 0 0.5 1];
    [out]=FSRfan(y,X,'la',la);
    fanplot(out);
    Total estimated time to complete LMS:  0.03 seconds 
    Total estimated time to complete LMS:  0.04 seconds 
    Total estimated time to complete LMS:  0.05 seconds 
    Total estimated time to complete LMS:  0.04 seconds 
    Total estimated time to complete LMS:  0.03 seconds 
    
    Click here for the graphical output of this example (link to Ro.S.A. website). Graphical output could not be included in the installation file because toolboxes cannot be greater than 20MB. To load locally the image files, download zip file http://rosa.unipr.it/fsda/images.zip and unzip it to <tt>(docroot)/FSDA/images</tt> or simply run routine <tt>downloadGraphicalOutput.m</tt>

    Related Examples

    expand all

  • Interactive example 1. FSRfan and fanplot with databrush option.
  • load('loyalty.txt');
    y=loyalty(:,4);
    X=loyalty(:,1:3);
    la=[-1 -0.5 0 0.5 1];
    [out]=FSRfan(y,X,'la',la);
    fanplot(out,'databrush','1');

  • Interactive example 2. FSRfan and fanplot with databrush, persist, label and RemoveLabels options.
  • %Removelabels is a parameter of SelectdataFS function
    load('loyalty.txt');
    y=loyalty(:,4);
    X=loyalty(:,1:3);
    la=[-1 -0.5 0 0.5 1];
    [out]=FSRfan(y,X,'la',la);
    fanplot(out,'databrush',{ 'persist' 'on' 'Label' 'on' 'RemoveLabels' 'off'});

  • Interactive example 3. FSRfan and fanplot with databrush, bivarfit, label and RemoveLabels options.
  • load('loyalty.txt');
    y=loyalty(:,4);
    X=loyalty(:,1:3);
    la=[-1 -0.5 0 0.5 1];
    [out]=FSRfan(y,X,'la',la);
    fanplot(out,'databrush',{ 'bivarfit' '2' 'Label' 'on' 'RemoveLabels' 'off'});

  • Interactive example 4. FSRfan and fanplot with databrush and selectionmode options.
  • %Example of the use of persistent cumulative brush.
    %Every time a brushing action is performed
    %current highlightments are added to previous highlightments
    load('loyalty.txt');
    y=loyalty(:,4);
    X=loyalty(:,1:3);
    la=[-1 -0.5 0 0.5 1];
    [out]=FSRfan(y,X,'la',la);
    fanplot(out,'databrush',{'selectionmode','Brush'});
    fanplot(out,'databrush',{'selectionmode' 'Lasso' 'persist' 'off'})
    fanplot(out,'databrush',{'selectionmode' 'Rect' 'persist' 'on'})

  • fanplot with datatooltip passed as scalar.
  • That is using default options for datacursor (i.e. DisplayStyle=window).

    load('loyalty.txt');
    y=loyalty(:,4);
    X=loyalty(:,1:3);
    la=[-1 -0.5 0 0.5 1];
    [out]=FSRfan(y,X,'la',la);
    fanplot(out,'datatooltip',1);

  • Construct fan plot specifying the confidence level and the xlimits.
  • load('loyalty.txt');
    y=loyalty(:,4);
    X=loyalty(:,1:3);
    la=[0 1/3 0.4 0.5];
    [out]=FSRfan(y,X,'la',la,'init',size(X,2)+2,'nsamp',20000);
    fanplot(out,'xlimx',[100 300],'conflev',0.95);

  • Interactive example 5. Example of the use of multivarfit and xlimx.
  • load('loyalty.txt');
    y=loyalty(:,4);
    X=loyalty(:,1:3);
    la=[0 1/3 0.4 0.5];
    [outs]=FSRfan(y,X,'la',la,'init',size(X,2)+2,'nsamp',20000);
    fanplot(outs,'xlimx',[10 520],'databrush',{'selectionmode' 'Brush' 'multivarfit' '2'})

  • Interactive example 6. Example of the use of FlagSize, namey, namex, lwd,FontSize, SizeAxesNum.
  • load('loyalty.txt');
    y=loyalty(:,4);
    X=loyalty(:,1:3);
    la=[-1 -0.5 0 0.5 1];
    [out]=FSRfan(y,X,'la',la);
    namey='Sales';
    nameX={'Number of visits', 'Age', 'Number of persons in the family'};
    %FlagSize controls how large must be the highlighted points. It is a
    %parametr of selectdataFS.
    fanplot(out,'xlimx',[10 520],'lwd',1.5,'FontSize',11,'SizeAxesNum',11,'nameX',nameX,'namey',namey,'databrush',{'selectionmode' 'Brush'...
    'multivarfit' '2' 'FlagSize' '5'})

  • Interactive example 7. Only one brush specifying labels for y and X.
  • load('loyalty.txt');
    y=loyalty(:,4);
    X=loyalty(:,1:3);
    la=[-1 -0.5 0 0.5 1];
    [out]=FSRfan(y,X,'la',la);
    fanplot(out,'databrush',{'selectionmode' 'Brush' 'FlagSize' '5'},'nameX',nameX,'namey',namey)

    Input Arguments

    expand all

    out — Data to plot. Structure.

    Structure containing the following fields

    Value Description
    Score

    (n-init) x length(la)+1 matrix:

    1st col = fwd search index;

    2nd col = value of the score test in each step of the fwd search for la(1);

    ...;

    last col = value of the score test in each step of the fwd search for la(end).

    la

    vector containing the values of lambda for which fan plot is constructed.

    bs

    matrix of size p x length(la) containing the units forming the initial subset for each value of lambda.

    out. Un = cell of size length(la). out.Un{i} is a (n-init) x 11 matrix which contains the unit(s) included in the subset at each step of the fwd search (necessary only if option datatooltip or databrush are not empty).

    y

    a vector containing the response (necessary only if option databrush is true).

    X

    a matrix containing the explanatory variables (necessary only if option databrush is not empty).

    Data Types: struct

    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: 'corr',1 , 'conflev',[0.9 0.95 0.99] , 'datatooltip','' , 'databrush',1 , 'titl','Fan plot' , 'labx','Subset size m' , 'laby','Score test statistic' , 'xlimx',[init n] , 'ylimy',[0 100] , 'lwd',2 , 'lwdenv',1 , 'FontSize',12 , 'SizeAxesNum',10 , 'nameX','' , 'namey','' , 'tag','pl_mycov'

    label —Labels.cell array of strings.

    Cell containing the labels of the units (optional argument used when datatooltip=1). If this field is not present labels row1, ..., rown will be automatically created and included in the pop up datatooltip window.

    Example: 'corr',1

    Data Types: Cell array of strings

    conflev —Confidence level.scalar | vector.

    Confidence level for the bands (default is 0.99, that is we plot two horizontal lines in correspondence of value -2.58 and 2.58).

    Example: 'conflev',[0.9 0.95 0.99]

    Data Types: double

    datatooltip —Information about the unit selected.empty value | structure.

    The default is datatooltip=''. If datatooltip is not empty the user can use the mouse in order to have information about the unit selected, the step in which the unit enters the search and the associated label. If datatooltip is a structure, it is possible to control the aspect of the data cursor (see function datacursormode for more details or the examples below). The default options of the structure are DisplayStyle='Window' and SnapToDataVertex='on'.

    Example: 'datatooltip',''

    Data Types: Empty value or structure

    databrush —Databrush options.empty value, scalar | cell.

    DATABRUSH IS AN EMPTY VALUE: If databrush is an empty value (default), no brushing is done. The activation of this option (databrush is a scalar or a cell) enables the user to select a set of trajectories in the current plot and to see them highlighted in the y|X plot (notice that if the plot y|X does not exist it is automatically created). In addition, brushed units can be highlighted in the other following plots (only if they are already open): monitoring residual plot monitoring leverage plot maximum studentized residual $s^2$ and $R^2$ Cook distance and modified Cook distance deletion t statistics. The window style of the other figures is set equal to that which contains the monitoring residual plot. In other words, if the monitoring residual plot is docked all the other figures will be docked too. DATABRUSH IS A SCALAR: If databrush is a scalar the default selection tool is a rectangular brush and it is possible to brush only once (that is persist=''). DATABRUSH IS A CELL: If databrush is a cell, it is possible to use all optional arguments of function selectdataFS and LXS inside the curly brackets of option databrush and the following optional argument:

    persist = Persist is an empty value or a scalar containing the strings 'on' or 'off'. If persist = 'on' or 'off' brusing can be done as many time as the user requires. In case persist='off', every time a new brush is performed, units previously brushed are removed. In case persist='on' the unit(s) currently brushed are added to those previously brushed. However in both cases, if the user brushes a different trajectory from the one previously brushed, the previos brushed plots are stored in a figure in the background. The default value of persist is '' that is brushing is allowed only once.

    bivarfit = This option adds one or more least square lines, based on SIMPLE REGRESSION of y on Xi, to the plots of y|Xi.

    If bivarfit = '' is the default: no line is fitted.

    If bivarfit = '1' fits a single ols line to all points of each bivariate plot in the scatter matrix y|X.

    If bivarfit = '2' fits two ols lines: one to all points and another to the group of the genuine observations. The group of the potential outliers is not fitted.

    If bivarfit = '0' fits one ols line to each group. This is useful for the purpose of fitting mixtures of regression lines.

    If bivarfit = 'i1' or 'i2' or 'i3' etc fits an ols line to a specific group, the one with index 'i' equal to 1, 2, 3 etc. Again, useful in case of mixtures.

    multivarfit = This option adds one or more least square lines, based on MULTIVARIATE REGRESSION of y on X, to the plots of y|Xi.

    If multivarfit = '' is the default: no line is fitted.

    If multivarfit = '1' fits a single ols line to all points of each bivariate plot in the scatter matrix y|X. The line added to the scatter plot y|Xi is avconst +Ci*Xi, where Ci is the coefficient of Xi in the multivariate regression and avconst is the effect of all the other explanatory variables different from Xi evaluated at their centroid (that is overline{y}'C)) If multivarfit = '2' exactly equal to multivarfit ='1' but this time we add the line based on the group of unselected observations.

    Example: 'databrush',1

    Data Types: Empty value, scalar or cell.

    titl —Title.string.

    A label for the title (default: 'Fan plot')

    Example: 'titl','Fan plot'

    Data Types: char

    labx —x-axis label.string.

    A label for the x-axis (default:

    'Subset size m').

    Example: 'labx','Subset size m'

    Data Types: char

    laby —y-axis label.string.

    a label for the y-axis (default:'Score test statistic').

    Example: 'laby','Score test statistic'

    Data Types: char

    xlimx —Min and Max of the x axis.vector.

    Vector with two elements controlling minimum and maximum of the x axis.

    Default value is [init n].

    Example: 'xlimx',[init n]

    Data Types: double

    ylimy —Min and Max of the y axis.vector.

    Vector with two elements controlling minimum and maximum of the y axis.

    Default value for ylimy(1)=max(min(score_test),-20). Default value for ylimy(2)=min(max(score_test),20).

    Example: 'ylimy',[0 100]

    Data Types: double

    lwd —Linewidth.scalar.

    Scalar which controls linewidth of the curves which contain the score test.

    Default line width=2.

    Example: 'lwd',2

    Data Types: double

    lwdenv —Width of the envelope lines.scalar.

    Scalar which controls the width of the lines associated with the envelopes. Default is lwdenv=1.

    Example: 'lwdenv',1

    Data Types: double

    FontSize —Font size of the labels.scalar.

    Scalar which controls the font size of the labels of the axes and of the labels inside the plot. Default value is 12.

    Example: 'FontSize',12

    Data Types: double

    SizeAxesNum —Size of the numbers of the axis.scalar.

    Scalar which controls the size of the numbers of the axes.

    Default value is 10.

    Example: 'SizeAxesNum',10

    Data Types: double

    nameX —Labels of the X variables.cell array of strings.

    Cell array of strings of length p containing the labels of the varibles of the regression dataset. If it is empty (default) the sequence X1, ..., Xp will be created automatically.

    Example: 'nameX',''

    Data Types: Cell array of strings

    namey —Labels of the y variable.string.

    String containing the label of the response variable.

    Example: 'namey',''

    Data Types: char

    tag —Handle of the plot.string.

    String which identifies the handle of the plot which is about to be created. The default is to use tag pl_fan. Notice that if the program finds a plot which has a tag equal to the one specified by the user, then the output of the new plot overwrites the existing one in the same window else a new window is created.

    Example: 'tag','pl_mycov'

    Data Types: char

    Output Arguments

    expand all

    brushedUnits —List of the units which are inside subset in the trajectories which have been brushed using option databrush. brushed units. Vector. Vector

    If option databrush has not been used brushedUnits will be an empty value.

    References

    Atkinson, A.C. and Riani, M. (2000), "Robust Diagnostic Regression Analysis", Springer Verlag, New York.

    Atkinson, A.C. and Riani, M. (2002a), Tests in the fan plot for robust, diagnostic transformations in regression, "Chemometrics and Intelligent Laboratory Systems", Vol. 60, pp. 87-100.

    Atkinson, A.C. Riani, M., Corbellini A. (2019), The analysis of transformations for profit-and-loss data, Journal of the Royal Statistical Society, Series C, "Applied Statistics", https://doi.org/10.1111/rssc.12389

    Atkinson, A.C. Riani, M. and Corbellini A. (2020), The Box-Cox Transformation: Review and Extensions, "Statistical Science", in press.

    See Also

    This page has been automatically generated by our routine publishFS