normYJ

normYJ computes (normalized) Yeo-Johnson transformation

Syntax

  • Ytra=normYJ(Y,ColtoTra,la)example
  • Ytra=normYJ(Y,ColtoTra,la,Name,Value)example

Description

example

Ytra =normYJ(Y, ColtoTra, la) Example of use of normYJ with all default options.

example

Ytra =normYJ(Y, ColtoTra, la, Name, Value) Comparison between Box-Cox and Yeo-Johnson transformation.

Examples

expand all

  • Example of use of normYJ with all default options.
  • Transform value -3, -2, ..., 3

    y=(-3:3)';
    lambda=0
    y1=normYJ(y,1,lambda)
    plot(y,y1)
    xlabel('Original values')
    ylabel('Transformed values')

  • Comparison between Box-Cox and Yeo-Johnson transformation.
  • close all
    y=(-2:0.1:2)';
    n=length(y);
    la=-1:1:3;
    nla=length(la);
    YtraYJ=zeros(n,nla);
    YtraBC=nan(n,nla);
    posy=y>0;
    for j=1:nla
    YtraYJ(:,j)=normYJ(y,1,la(j),'Jacobian',false);
    YtraBC(posy,j)=normBoxCox(y(posy),1,la(j),'Jacobian',false);
    end
    subplot(1,2,1)
    plot(y,YtraYJ)
    for j=1:nla
    text(y(1), YtraYJ(1,j),['\lambda=' num2str(la(j))])
    end
    xlabel('Original values')
    ylabel('Transformed values')
    title('Yeo-Johnson transformation')
    subplot(1,2,2)
    plot(y,YtraBC)
    xlim([y(1) y(end)])
    for j=1:nla
    text(y(16), YtraBC(22,j),['\lambda=' num2str(la(j))])
    end
    xlabel('Original values')
    ylabel('Transformed values')
    title('Box-Cox transformation')

    Related Examples

    expand all

  • Simulated data check inverse transformation.
  • n=100;p=5;
    Y=randn(n,p);
    Y(3,1:3)=0;
    la=[0.5 0 -0.5 2 0];
    % Transform all columns of matrix Y according to the values of la
    Ytra=normYJ(Y,[],la,'Jacobian',false);
    Ychk=normYJ(Ytra,[],la,'Jacobian',false,'inverse',true);
    disp(max(max(abs(Y-Ychk))))

    Input Arguments

    expand all

    Y — Input data. Matrix.

    n x v data matrix; n observations and v variables. Rows of Y 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

    ColtoTra — Variable to transform. Vector.

    k x 1 integer vector specifying the variables which must be transformed. If it is missing and length(la)=v all variables are transformed

    Data Types: single|double

    la — transformation parameters. Vector.

    k x 1 vector containing set of transformation parameters for the k ColtoTra.

    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: 'inverse',true , 'Jacobian',true

    inverse —Inverse transformation.logical.

    If inverse is true, the inverse transformation is returned. The default value of inverse is false.

    Example: 'inverse',true

    Data Types: Logical

    Jacobian —Requested Jacobian of transformed values.true (default) | false.

    If true (default) the transformation is normalized to have Jacobian equal to 1

    Example: 'Jacobian',true

    Data Types: Logical

    Output Arguments

    expand all

    Ytra —transformed data matrix. Matrix

    n x v data matrix containing transformed observations The Yeo-Johnson transformation is the Box-Cox transformation of y+1 for nonnegative values, and of |y|+1 with parameter 2-lambda for y negative.

    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.

    This page has been automatically generated by our routine publishFS