Class: DecorrTestLib::CorreFactLib

Inherits:
CorreFactIF show all
Defined in:
lib/num4tststatistic2.rb

Overview

相関係数の検定

Instance Method Summary collapse

Constructor Details

#initialize(hypothTest3) ⇒ CorreFactLib

Returns a new instance of CorreFactLib.



419
420
421
422
423
# File 'lib/num4tststatistic2.rb', line 419

def initialize(hypothTest3)
    @hypothTest3 = hypothTest3
    @paraTest = Num4TstStatisticLib::ParametrixTestLib.new
    @nonParaTest = Num4TstStatisticLib::NonParametrixTestLib.new
end

Instance Method Details

#kendallscorr(x, y, rth0, a) ⇒ boolean

ケンドールの順位相関係数

Examples:

x = [113, 64, 16, 45, 28, 19, 30, 82, 76]
y = [31, 5, 2, 17, 18, 2, 9, 25, 13]
hypothTest = Num4HypothTestLib::TwoSideTestLib.new
decorrTest = DecorrTestLib::CorreFactLib.new(hypothTest)
decorrTest.kendallscorr(x, y, -0.3, 0.05)
=> true

Returns 検定結果(true:棄却域内 false:棄却域外).

Parameters:

  • x (Array)

    xのデータ(double[])

  • y (Array)

    yのデータ(double[])

  • rth0 (double)

    母相関係数

  • a (double)

    有意水準

Returns:

  • (boolean)

    検定結果(true:棄却域内 false:棄却域外)

Raises:

  • (TypeError)


479
480
481
482
483
# File 'lib/num4tststatistic2.rb', line 479

def kendallscorr(x, y, rth0, a)
    raise TypeError unless @hypothTest3.kind_of?(HypothTest3IF)
    statistic = @nonParaTest.kendallscorr(x, y)
    return @hypothTest3.populationCorre(statistic, x.size, rth0, a)
end

#pearsoCorrelation(x, y, rth0, a) ⇒ boolean

ピアソン相関係数

Examples:

x = [113, 64, 16, 45, 28, 19, 30, 82, 76]
y = [31, 5, 2, 17, 18, 2, 9, 25, 13]
hypothTest = Num4HypothTestLib::TwoSideTestLib.new
decorrTest = DecorrTestLib::CorreFactLib.new(hypothTest)
decorrTest.pearsoCorrelation(x, y,  -0.3, 0.05)
=> true

Returns 検定結果(true:棄却域内 false:棄却域外).

Parameters:

  • x (Array)

    xのデータ(double[])

  • y (Array)

    yのデータ(double[])

  • rth0 (double)

    母相関係数

  • a (double)

    有意水準

Returns:

  • (boolean)

    検定結果(true:棄却域内 false:棄却域外)

Raises:

  • (TypeError)


439
440
441
442
443
# File 'lib/num4tststatistic2.rb', line 439

def pearsoCorrelation(x, y, rth0, a)
    raise TypeError unless @hypothTest3.kind_of?(HypothTest3IF)
    statistic = @paraTest.pearsoCorrelation(x, y)
    return @hypothTest3.populationCorre(statistic, x.size, rth0, a)
end

#spearmanscorr(x, y, rth0, a) ⇒ boolean

スピアマンの順位相関係数

Examples:

x = [113, 64, 16, 45, 28, 19, 30, 82, 76]
y = [31, 5, 2, 17, 18, 2, 9, 25, 13]
hypothTest = Num4HypothTestLib::TwoSideTestLib.new
decorrTest = DecorrTestLib::CorreFactLib.new(hypothTest)
decorrTest.spearmanscorr(x, y, -0.3, 0.05)
=> true

Returns 検定結果(true:棄却域内 false:棄却域外).

Parameters:

  • x (Array)

    xのデータ(double[])

  • y (Array)

    yのデータ(double[])

  • rth0 (double)

    母相関係数

  • a (double)

    有意水準

Returns:

  • (boolean)

    検定結果(true:棄却域内 false:棄却域外)

Raises:

  • (TypeError)


459
460
461
462
463
# File 'lib/num4tststatistic2.rb', line 459

def spearmanscorr(x, y, rth0, a)
    raise TypeError unless @hypothTest3.kind_of?(HypothTest3IF)
    statistic = @nonParaTest.spearmanscorr(x, y)
    return @hypothTest3.populationCorre(statistic, x.size, rth0, a)
end