ScoreYJpn

Computes the score test for YJ transformation separately for pos and neg observations

Syntax

Description

example

outSC =ScoreYJpn(y, X) Ex in which positive and negative observations require the same lambda.

example

outSC =ScoreYJpn(y, X, Name, Value) Ex in which positive and negative observation require different lambdas.

Examples

expand all

  • Ex in which positive and negative observations require the same lambda.
  •     rng('default')
        rng(1)
        n=100;
        y=randn(n,1);
        % Transform the value to find out if we can recover the true value of
        % the transformation parameter
        la=0.5;
        ytra=normYJ(y,[],la,'inverse',true);
        % Start the analysis
        X=ones(n,1);
        [outSC]=ScoreYJ(ytra,X,'intercept',0);
        [outSCpn]=ScoreYJpn(ytra,X,'intercept',0);
        la=[-1 -0.5 0 0.5 1]';
        disp([la outSCpn.Score(:,1) outSC.Score outSCpn.Score(:,2)])
        % Comment: if we consider the 5 most common values of lambda
        % the value of the score test when lambda=0.5 is the only one which is not
        % significant. Both values of the score test for positive and negative
        % observations confirm that this value of the transformation parameter is
        % OK for both sides of the distribution.
    
       -1.0000   40.2357   24.1288   15.7149
       -0.5000   20.4741   14.7964    9.9619
             0    8.9009    6.9774    4.5230
        0.5000    1.3042    0.2740   -1.0664
        1.0000   -4.8797   -6.2978   -7.9574
    
    

  • Ex in which positive and negative observation require different lambdas.
  •     rng(1000)
        n=100;
        y=randn(n,1);
        % Tranform in a different way positive and negative values
        lapos=0;
        ytrapos=normYJ(y(y>=0),[],lapos,'inverse',true);
        laneg=1;
        ytraneg=normYJ(y(y<0),[],laneg,'inverse',true);
        ytra=[ytrapos; ytraneg];
    
        % Start the analysis
        X=ones(n,1);
        [outSC]=ScoreYJ(ytra,X,'intercept',0);
        [outSCpn]=ScoreYJpn(ytra,X,'intercept',0);
        la=[-1 -0.5 0 0.5 1]';
        disp([la outSCpn.Score(:,1) outSC.Score outSCpn.Score(:,2)])
        % Comment: if we consider the 5 most common values of lambda
        % the value of the score test when lambda=0.5 is the only one which is not
        % significant. However when lambda=0.5 the score test for negative
        % observations is highly significant. The difference between the test for
        % positive and the test for negative is 2.7597+0.7744=3.5341, which is very
        % large. This indicates that the two tails need a different value of the
        % transformation parameter.
    
       -1.0000   89.5466   39.6867   28.3433
       -0.5000   33.4110   24.9236   19.4072
             0   10.3643   11.4446   10.8674
        0.5000   -0.7744    0.8272    2.7597
        1.0000   -9.8327   -9.4050   -6.8708
    
    

    Related Examples

  • Extended score with all default options for the wool data.
  • Load the wool data.

        XX=load('wool.txt');
        y=XX(:,end);
        X=XX(:,1:end-1);
        % Score test using the five most common values of lambda.
        % In this case (given that all observations are positive the extended
        % score test for positive observations reduces to the standard score test
        % while that for negative is equal to NaN.
        [outSc]=ScoreYJpn(y,X);
    

  • Extended score test using Darwin data given by Yeo and Yohnson.
  •      y=[6.1, -8.4, 1.0, 2.0, 0.7, 2.9, 3.5, 5.1, 1.8, 3.6, 7.0, 3.0, 9.3, 7.5 -6.0]';
         n=length(y);
         X=ones(n,1);
         % Score and extended score test in the grid of lambda 1, 1.1, ..., 2
         la=[1:0.1:2];
         % Given that there are no explanatory variables the test must be
         % called with intercept 0
         outpn=ScoreYJpn(y,X,'intercept',0,'la',la);
         out=ScoreYJ(y,X,'intercept',0,'la',la);
         disp([la' outpn.Score(:,1) out.Score outpn.Score(:,2)])
    

    Input Arguments

    expand all

    y — Response variable. Vector.

    A vector with n elements that contains the response variable. It can be either a row or a column vector.

    Data Types: single| double

    X — Predictor variables. Matrix.

    Data matrix of explanatory variables (also called 'regressors') of dimension (n x p-1). Rows of X represent observations, and columns represent variables.

    Missing values (NaN's) and infinite values (Inf's) are allowed, since observations (rows) with missing or infinite values will automatically be excluded from the computations.

    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: 'intercept',1 , 'la',[0 0.5] , 'nocheck',1

    intercept —Indicator for constant term.scalar.

    If 1, a model with constant term will be fitted (default), else no constant term will be included.

    Example: 'intercept',1

    Data Types: double

    la —transformation parameter.vector.

    It specifies for which values of the transformation parameter it is necessary to compute the score test. Default value of lambda is la=[-1 -0.5 0 0.5 1]; that is the five most common values of lambda

    Example: 'la',[0 0.5]

    Data Types: double

    nocheck —Check input arguments.scalar.

    If nocheck is equal to 1 no check is performed on matrix y and matrix X. Notice that y and X are left unchanged. In other words the additional column of ones for the intercept is not added. As default nocheck=0.

    Example: 'nocheck',1

    Data Types: double

    Output Arguments

    expand all

    outSC — description Structure

    containing the following fields:

    Value Description
    Score

    score test. Matrix.

    Matrix of size length(lambda)-by-2 which contains the value of the score test for each value of lambda specfied in optional input parameter la. The first column refers to the test for positive observations while the second column refers to the test for negative observations. If la is not specified, the number of rows of outSc.Score is equal to 5 and will contain the values of the score test for the 5 most common values of lambda.

    References

    Yeo, I.K. and Johnson, R. (2000), A new family of power transformations to improve normality or symmetry, "Biometrika", Vol. 87, pp. 954-959.

    Atkinson, A.C. and Riani, M. (2018), Extensions of the score test, Submitted.

    See Also

    | |

    This page has been automatically generated by our routine publishFS