{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Dominance Analysis with statsample\n", "\n", "This example demonstrates dominance analysis with the Statsample::DominanceAnalysis class" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Analysis 2015-06-03 15:49:07 +0530\n", "= Statsample::DominanceAnalysis\n", " Correlation Matrix\n", "+----+-------+-------+-------+-------+-------+\n", "| | a | b | cc | d | y |\n", "+----+-------+-------+-------+-------+-------+\n", "| a | 1.000 | .071 | -.013 | -.037 | .785 |\n", "| b | .071 | 1.000 | .046 | .011 | .545 |\n", "| cc | -.013 | .046 | 1.000 | .061 | .322 |\n", "| d | -.037 | .011 | .061 | 1.000 | .154 |\n", "| y | .785 | .545 | .322 | .154 | 1.000 |\n", "+----+-------+-------+-------+-------+-------+\n", "\n", " == Multiple reggresion of a,b,cc,d on y\n", " Engine: Statsample::Regression::Multiple::RubyEngine\n", " Cases(listwise)=300(300)\n", " R=0.989\n", " R^2=0.978\n", " R^2 Adj=0.977\n", " Std.Error R=0.984\n", " Equation=-0.062 + 5.000a + 2.986b + 2.004cc + 1.046d\n", " === ANOVA\n", " ANOVA Table\n", "+------------+-----------+-----+----------+----------+-------+\n", "| source | ss | df | ms | f | p |\n", "+------------+-----------+-----+----------+----------+-------+\n", "| Regression | 12431.643 | 4 | 3107.911 | 3211.058 | 0.000 |\n", "| Error | 285.524 | 295 | 0.968 | | |\n", "| Total | 12717.167 | 299 | 3108.879 | | |\n", "+------------+-----------+-----+----------+----------+-------+\n", "\n", " Beta coefficients\n", "+----------+--------+-------+-------+--------+\n", "| coeff | b | beta | se | t |\n", "+----------+--------+-------+-------+--------+\n", "| Constant | -0.062 | - | 0.057 | -1.080 |\n", "| a | 5.000 | 0.761 | 0.058 | 86.894 |\n", "| b | 2.986 | 0.476 | 0.055 | 54.325 |\n", "| cc | 2.004 | 0.300 | 0.058 | 34.323 |\n", "| d | 1.046 | 0.159 | 0.058 | 18.180 |\n", "+----------+--------+-------+-------+--------+\n", "\n", " == Dominance Analysis: a,b,cc,d over y\n", " Dominance Analysis result\n", "+------------------+-------+-------+-------+-------+-------+-------+\n", "| | r2 | sign | a | b | cc | d |\n", "+------------------+-------+-------+-------+-------+-------+-------+\n", "| Model 0 | | | 0.616 | 0.297 | 0.104 | 0.024 |\n", "+------------------+-------+-------+-------+-------+-------+-------+\n", "| a | 0.616 | 0.000 | -- | 0.241 | 0.110 | 0.034 |\n", "| b | 0.297 | 0.000 | 0.559 | -- | 0.088 | 0.022 |\n", "| cc | 0.104 | 0.000 | 0.622 | 0.282 | -- | 0.018 |\n", "| d | 0.024 | 0.007 | 0.626 | 0.296 | 0.098 | -- |\n", "+------------------+-------+-------+-------+-------+-------+-------+\n", "| k=1 Average | | | 0.602 | 0.273 | 0.099 | 0.025 |\n", "+------------------+-------+-------+-------+-------+-------+-------+\n", "| a*b | 0.857 | 0.000 | -- | -- | 0.096 | 0.031 |\n", "| a*cc | 0.726 | 0.000 | -- | 0.226 | -- | 0.027 |\n", "| a*d | 0.650 | 0.000 | -- | 0.238 | 0.103 | -- |\n", "| b*cc | 0.386 | 0.000 | 0.566 | -- | -- | 0.017 |\n", "| b*d | 0.319 | 0.000 | 0.568 | -- | 0.083 | -- |\n", "| cc*d | 0.122 | 0.000 | 0.631 | 0.281 | -- | -- |\n", "+------------------+-------+-------+-------+-------+-------+-------+\n", "| k=2 Average | | | 0.589 | 0.249 | 0.094 | 0.025 |\n", "+------------------+-------+-------+-------+-------+-------+-------+\n", "| a*b*cc | 0.952 | 0.000 | -- | -- | -- | 0.025 |\n", "| a*b*d | 0.888 | 0.000 | -- | -- | 0.090 | -- |\n", "| a*cc*d | 0.753 | 0.000 | -- | 0.225 | -- | -- |\n", "| b*cc*d | 0.403 | 0.000 | 0.575 | -- | -- | -- |\n", "+------------------+-------+-------+-------+-------+-------+-------+\n", "| k=3 Average | | | 0.575 | 0.225 | 0.090 | 0.025 |\n", "+------------------+-------+-------+-------+-------+-------+-------+\n", "| a*b*cc*d | 0.978 | 0.000 | -- | -- | -- | -- |\n", "+------------------+-------+-------+-------+-------+-------+-------+\n", "| Overall averages | | | 0.595 | 0.261 | 0.097 | 0.025 |\n", "+------------------+-------+-------+-------+-------+-------+-------+\n", "\n", " Pairwise dominance\n", "+--------+-------+-------------+---------+\n", "| Pairs | Total | Conditional | General |\n", "+--------+-------+-------------+---------+\n", "| a - b | 1.0 | 1.0 | 1.0 |\n", "| a - cc | 1.0 | 1.0 | 1.0 |\n", "| a - d | 1.0 | 1.0 | 1.0 |\n", "| b - cc | 1.0 | 1.0 | 1.0 |\n", "| b - d | 1.0 | 1.0 | 1.0 |\n", "| cc - d | 1.0 | 1.0 | 1.0 |\n", "+--------+-------+-------------+---------+\n", "\n", " == Dominance Analysis using group of predictors\n", " Dominance Analysis result\n", "+------------------+-------+-------+-------+-------+--------+\n", "| | r2 | sign | a | b | (cc,d) |\n", "+------------------+-------+-------+-------+-------+--------+\n", "| Model 0 | | | 0.616 | 0.297 | 0.122 |\n", "+------------------+-------+-------+-------+-------+--------+\n", "| a | 0.616 | 0.000 | -- | 0.241 | 0.137 |\n", "| b | 0.297 | 0.000 | 0.559 | -- | 0.105 |\n", "| (cc,d) | 0.122 | 0.000 | 0.631 | 0.281 | -- |\n", "+------------------+-------+-------+-------+-------+--------+\n", "| k=1 Average | | | 0.595 | 0.261 | 0.121 |\n", "+------------------+-------+-------+-------+-------+--------+\n", "| a*b | 0.857 | 0.000 | -- | -- | 0.121 |\n", "| a*(cc,d) | 0.753 | 0.000 | -- | 0.225 | -- |\n", "| b*(cc,d) | 0.403 | 0.000 | 0.575 | -- | -- |\n", "+------------------+-------+-------+-------+-------+--------+\n", "| k=2 Average | | | 0.575 | 0.225 | 0.121 |\n", "+------------------+-------+-------+-------+-------+--------+\n", "| a*b*(cc,d) | 0.978 | 0.000 | -- | -- | -- |\n", "+------------------+-------+-------+-------+-------+--------+\n", "| Overall averages | | | 0.595 | 0.261 | 0.121 |\n", "+------------------+-------+-------+-------+-------+--------+\n", "\n", " Pairwise dominance\n", "+------------+-------+-------------+---------+\n", "| Pairs | Total | Conditional | General |\n", "+------------+-------+-------------+---------+\n", "| a - b | 1.0 | 1.0 | 1.0 |\n", "| a - (cc-d) | 1.0 | 1.0 | 1.0 |\n", "| b - (cc-d) | 1.0 | 1.0 | 1.0 |\n", "+------------+-------+-------------+---------+\n", "\n", "\n" ] } ], "source": [ "require 'statsample'\n", "\n", "Statsample::Analysis.store(Statsample::DominanceAnalysis) do\n", " sample=300\n", " a = rnorm(sample)\n", " b = rnorm(sample)\n", " c = rnorm(sample)\n", " d = rnorm(sample)\n", " \n", " ds = Daru::DataFrame.new({:a => a,:b => b,:cc => c,:d => d})\n", " attach(ds)\n", " ds[:y]=a*5 + b*3 + cc*2 + d + rnorm(300) \n", " cm=cor(ds)\n", " summary(cm)\n", " lr=lr(ds,:y)\n", " summary(lr)\n", " da=dominance_analysis(ds,:y)\n", " summary(da)\n", " \n", " da = dominance_analysis(ds,:y,:name=>\"Dominance Analysis using group of predictors\", :predictors=>[:a, :b, [:cc, :d]])\n", " summary(da)\n", "end\n", "\n", "\n", "Statsample::Analysis.run_batch" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This example explains usage of the Statsample::DominanceAnalysis::Bootstrap class." ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false, "scrolled": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[0, 1]\n", "[0, 2]\n", "[0, 3]\n", "[1, 2]\n", "[1, 3]\n", "[2, 3]\n", "Bootstrap 1 of 100\n", "Bootstrap 2 of 100\n", "Bootstrap 3 of 100\n", "Bootstrap 4 of 100\n", "Bootstrap 5 of 100\n", "Bootstrap 6 of 100\n", "Bootstrap 7 of 100\n", "Bootstrap 8 of 100\n", "Bootstrap 9 of 100\n", "Bootstrap 10 of 100\n", "Bootstrap 11 of 100\n", "Bootstrap 12 of 100\n", "Bootstrap 13 of 100\n", "Bootstrap 14 of 100\n", "Bootstrap 15 of 100\n", "Bootstrap 16 of 100\n", "Bootstrap 17 of 100\n", "Bootstrap 18 of 100\n", "Bootstrap 19 of 100\n", "Bootstrap 20 of 100\n", "Bootstrap 21 of 100\n", "Bootstrap 22 of 100\n", "Bootstrap 23 of 100\n", "Bootstrap 24 of 100\n", "Bootstrap 25 of 100\n", "Bootstrap 26 of 100\n", "Bootstrap 27 of 100\n", "Bootstrap 28 of 100\n", "Bootstrap 29 of 100\n", "Bootstrap 30 of 100\n", "Bootstrap 31 of 100\n", "Bootstrap 32 of 100\n", "Bootstrap 33 of 100\n", "Bootstrap 34 of 100\n", "Bootstrap 35 of 100\n", "Bootstrap 36 of 100\n", "Bootstrap 37 of 100\n", "Bootstrap 38 of 100\n", "Bootstrap 39 of 100\n", "Bootstrap 40 of 100\n", "Bootstrap 41 of 100\n", "Bootstrap 42 of 100\n", "Bootstrap 43 of 100\n", "Bootstrap 44 of 100\n", "Bootstrap 45 of 100\n", "Bootstrap 46 of 100\n", "Bootstrap 47 of 100\n", "Bootstrap 48 of 100\n", "Bootstrap 49 of 100\n", "Bootstrap 50 of 100\n", "Bootstrap 51 of 100\n", "Bootstrap 52 of 100\n", "Bootstrap 53 of 100\n", "Bootstrap 54 of 100\n", "Bootstrap 55 of 100\n", "Bootstrap 56 of 100\n", "Bootstrap 57 of 100\n", "Bootstrap 58 of 100\n", "Bootstrap 59 of 100\n", "Bootstrap 60 of 100\n", "Bootstrap 61 of 100\n", "Bootstrap 62 of 100\n", "Bootstrap 63 of 100\n", "Bootstrap 64 of 100\n", "Bootstrap 65 of 100\n", "Bootstrap 66 of 100\n", "Bootstrap 67 of 100\n", "Bootstrap 68 of 100\n", "Bootstrap 69 of 100\n", "Bootstrap 70 of 100\n", "Bootstrap 71 of 100\n", "Bootstrap 72 of 100\n", "Bootstrap 73 of 100\n", "Bootstrap 74 of 100\n", "Bootstrap 75 of 100\n", "Bootstrap 76 of 100\n", "Bootstrap 77 of 100\n", "Bootstrap 78 of 100\n", "Bootstrap 79 of 100\n", "Bootstrap 80 of 100\n", "Bootstrap 81 of 100\n", "Bootstrap 82 of 100\n", "Bootstrap 83 of 100\n", "Bootstrap 84 of 100\n", "Bootstrap 85 of 100\n", "Bootstrap 86 of 100\n", "Bootstrap 87 of 100\n", "Bootstrap 88 of 100\n", "Bootstrap 89 of 100\n", "Bootstrap 90 of 100\n", "Bootstrap 91 of 100\n", "Bootstrap 92 of 100\n", "Bootstrap 93 of 100\n", "Bootstrap 94 of 100\n", "Bootstrap 95 of 100\n", "Bootstrap 96 of 100\n", "Bootstrap 97 of 100\n", "Bootstrap 98 of 100\n", "Bootstrap 99 of 100\n", "Bootstrap 100 of 100\n", "[0, 1]\n", "[0, 2]\n", "[0, 3]\n", "[1, 2]\n", "[1, 3]\n", "[2, 3]\n", "Bootstrap 1 of 100\n", "Bootstrap 2 of 100\n", "Bootstrap 3 of 100\n", "Bootstrap 4 of 100\n", "Bootstrap 5 of 100\n", "Bootstrap 6 of 100\n", "Bootstrap 7 of 100\n", "Bootstrap 8 of 100\n", "Bootstrap 9 of 100\n", "Bootstrap 10 of 100\n", "Bootstrap 11 of 100\n", "Bootstrap 12 of 100\n", "Bootstrap 13 of 100\n", "Bootstrap 14 of 100\n", "Bootstrap 15 of 100\n", "Bootstrap 16 of 100\n", "Bootstrap 17 of 100\n", "Bootstrap 18 of 100\n", "Bootstrap 19 of 100\n", "Bootstrap 20 of 100\n", "Bootstrap 21 of 100\n", "Bootstrap 22 of 100\n", "Bootstrap 23 of 100\n", "Bootstrap 24 of 100\n", "Bootstrap 25 of 100\n", "Bootstrap 26 of 100\n", "Bootstrap 27 of 100\n", "Bootstrap 28 of 100\n", "Bootstrap 29 of 100\n", "Bootstrap 30 of 100\n", "Bootstrap 31 of 100\n", "Bootstrap 32 of 100\n", "Bootstrap 33 of 100\n", "Bootstrap 34 of 100\n", "Bootstrap 35 of 100\n", "Bootstrap 36 of 100\n", "Bootstrap 37 of 100\n", "Bootstrap 38 of 100\n", "Bootstrap 39 of 100\n", "Bootstrap 40 of 100\n", "Bootstrap 41 of 100\n", "Bootstrap 42 of 100\n", "Bootstrap 43 of 100\n", "Bootstrap 44 of 100\n", "Bootstrap 45 of 100\n", "Bootstrap 46 of 100\n", "Bootstrap 47 of 100\n", "Bootstrap 48 of 100\n", "Bootstrap 49 of 100\n", "Bootstrap 50 of 100\n", "Bootstrap 51 of 100\n", "Bootstrap 52 of 100\n", "Bootstrap 53 of 100\n", "Bootstrap 54 of 100\n", "Bootstrap 55 of 100\n", "Bootstrap 56 of 100\n", "Bootstrap 57 of 100\n", "Bootstrap 58 of 100\n", "Bootstrap 59 of 100\n", "Bootstrap 60 of 100\n", "Bootstrap 61 of 100\n", "Bootstrap 62 of 100\n", "Bootstrap 63 of 100\n", "Bootstrap 64 of 100\n", "Bootstrap 65 of 100\n", "Bootstrap 66 of 100\n", "Bootstrap 67 of 100\n", "Bootstrap 68 of 100\n", "Bootstrap 69 of 100\n", "Bootstrap 70 of 100\n", "Bootstrap 71 of 100\n", "Bootstrap 72 of 100\n", "Bootstrap 73 of 100\n", "Bootstrap 74 of 100\n", "Bootstrap 75 of 100\n", "Bootstrap 76 of 100\n", "Bootstrap 77 of 100\n", "Bootstrap 78 of 100\n", "Bootstrap 79 of 100\n", "Bootstrap 80 of 100\n", "Bootstrap 81 of 100\n", "Bootstrap 82 of 100\n", "Bootstrap 83 of 100\n", "Bootstrap 84 of 100\n", "Bootstrap 85 of 100\n", "Bootstrap 86 of 100\n", "Bootstrap 87 of 100\n", "Bootstrap 88 of 100\n", "Bootstrap 89 of 100\n", "Bootstrap 90 of 100\n", "Bootstrap 91 of 100\n", "Bootstrap 92 of 100\n", "Bootstrap 93 of 100\n", "Bootstrap 94 of 100\n", "Bootstrap 95 of 100\n", "Bootstrap 96 of 100\n", "Bootstrap 97 of 100\n", "Bootstrap 98 of 100\n", "Bootstrap 99 of 100\n", "Bootstrap 100 of 100\n", "Analysis 2015-06-03 16:03:14 +0530\n", "= Statsample::DominanceAnalysis\n", " Correlation Matrix\n", "+----+-------+-------+-------+-------+-------+\n", "| | a | b | cc | d | y |\n", "+----+-------+-------+-------+-------+-------+\n", "| a | 1.000 | .026 | -.035 | -.090 | .784 |\n", "| b | .026 | 1.000 | -.051 | .169 | .493 |\n", "| cc | -.035 | -.051 | 1.000 | .127 | .284 |\n", "| d | -.090 | .169 | .127 | 1.000 | .206 |\n", "| y | .784 | .493 | .284 | .206 | 1.000 |\n", "+----+-------+-------+-------+-------+-------+\n", "\n", " == Multiple reggresion of a,b,cc,d on y\n", " Engine: Statsample::Regression::Multiple::RubyEngine\n", " Cases(listwise)=300(300)\n", " R=0.988\n", " R^2=0.976\n", " R^2 Adj=0.975\n", " Std.Error R=0.983\n", " Equation=0.030 + 4.956a + 2.876b + 1.948cc + 1.049d\n", " === ANOVA\n", " ANOVA Table\n", "+------------+-----------+-----+----------+----------+-------+\n", "| source | ss | df | ms | f | p |\n", "+------------+-----------+-----+----------+----------+-------+\n", "| Regression | 11379.077 | 4 | 2844.769 | 2942.454 | 0.000 |\n", "| Error | 285.206 | 295 | 0.967 | | |\n", "| Total | 11664.283 | 299 | 2845.736 | | |\n", "+------------+-----------+-----+----------+----------+-------+\n", "\n", " Beta coefficients\n", "+----------+-------+-------+-------+--------+\n", "| coeff | b | beta | se | t |\n", "+----------+-------+-------+-------+--------+\n", "| Constant | 0.030 | - | 0.057 | 0.520 |\n", "| a | 4.956 | 0.798 | 0.057 | 87.146 |\n", "| b | 2.876 | 0.462 | 0.058 | 49.839 |\n", "| cc | 1.948 | 0.316 | 0.057 | 34.280 |\n", "| d | 1.049 | 0.160 | 0.062 | 17.057 |\n", "+----------+-------+-------+-------+--------+\n", "\n", " == Dominance Analysis: a,b,cc,d over y\n", " Dominance Analysis result\n", "+------------------+-------+-------+-------+-------+-------+-------+\n", "| | r2 | sign | a | b | cc | d |\n", "+------------------+-------+-------+-------+-------+-------+-------+\n", "| Model 0 | | | 0.614 | 0.243 | 0.081 | 0.042 |\n", "+------------------+-------+-------+-------+-------+-------+-------+\n", "| a | 0.614 | 0.000 | -- | 0.224 | 0.097 | 0.077 |\n", "| b | 0.243 | 0.000 | 0.595 | -- | 0.096 | 0.015 |\n", "| cc | 0.081 | 0.000 | 0.631 | 0.258 | -- | 0.029 |\n", "| d | 0.042 | 0.000 | 0.649 | 0.216 | 0.068 | -- |\n", "+------------------+-------+-------+-------+-------+-------+-------+\n", "| k=1 Average | | | 0.625 | 0.233 | 0.087 | 0.041 |\n", "+------------------+-------+-------+-------+-------+-------+-------+\n", "| a*b | 0.838 | 0.000 | -- | -- | 0.113 | 0.040 |\n", "| a*cc | 0.712 | 0.000 | -- | 0.240 | -- | 0.058 |\n", "| a*d | 0.691 | 0.000 | -- | 0.187 | 0.078 | -- |\n", "| b*cc | 0.339 | 0.000 | 0.612 | -- | -- | 0.007 |\n", "| b*d | 0.259 | 0.000 | 0.619 | -- | 0.087 | -- |\n", "| cc*d | 0.110 | 0.000 | 0.660 | 0.236 | -- | -- |\n", "+------------------+-------+-------+-------+-------+-------+-------+\n", "| k=2 Average | | | 0.630 | 0.221 | 0.093 | 0.035 |\n", "+------------------+-------+-------+-------+-------+-------+-------+\n", "| a*b*cc | 0.951 | 0.000 | -- | -- | -- | 0.024 |\n", "| a*b*d | 0.878 | 0.000 | -- | -- | 0.097 | -- |\n", "| a*cc*d | 0.770 | 0.000 | -- | 0.206 | -- | -- |\n", "| b*cc*d | 0.346 | 0.000 | 0.629 | -- | -- | -- |\n", "+------------------+-------+-------+-------+-------+-------+-------+\n", "| k=3 Average | | | 0.629 | 0.206 | 0.097 | 0.024 |\n", "+------------------+-------+-------+-------+-------+-------+-------+\n", "| a*b*cc*d | 0.976 | 0.000 | -- | -- | -- | -- |\n", "+------------------+-------+-------+-------+-------+-------+-------+\n", "| Overall averages | | | 0.625 | 0.226 | 0.090 | 0.035 |\n", "+------------------+-------+-------+-------+-------+-------+-------+\n", "\n", " Pairwise dominance\n", "+--------+-------+-------------+---------+\n", "| Pairs | Total | Conditional | General |\n", "+--------+-------+-------------+---------+\n", "| a - b | 1.0 | 1.0 | 1.0 |\n", "| a - cc | 1.0 | 1.0 | 1.0 |\n", "| a - d | 1.0 | 1.0 | 1.0 |\n", "| b - cc | 1.0 | 1.0 | 1.0 |\n", "| b - d | 1.0 | 1.0 | 1.0 |\n", "| cc - d | 1.0 | 1.0 | 1.0 |\n", "+--------+-------+-------------+---------+\n", "\n", " == Dominance Analysis using group of predictors\n", " Dominance Analysis result\n", "+------------------+-------+-------+-------+-------+--------+\n", "| | r2 | sign | a | b | (cc,d) |\n", "+------------------+-------+-------+-------+-------+--------+\n", "| Model 0 | | | 0.614 | 0.243 | 0.110 |\n", "+------------------+-------+-------+-------+-------+--------+\n", "| a | 0.614 | 0.000 | -- | 0.224 | 0.155 |\n", "| b | 0.243 | 0.000 | 0.595 | -- | 0.103 |\n", "| (cc,d) | 0.110 | 0.000 | 0.660 | 0.236 | -- |\n", "+------------------+-------+-------+-------+-------+--------+\n", "| k=1 Average | | | 0.627 | 0.230 | 0.129 |\n", "+------------------+-------+-------+-------+-------+--------+\n", "| a*b | 0.838 | 0.000 | -- | -- | 0.137 |\n", "| a*(cc,d) | 0.770 | 0.000 | -- | 0.206 | -- |\n", "| b*(cc,d) | 0.346 | 0.000 | 0.629 | -- | -- |\n", "+------------------+-------+-------+-------+-------+--------+\n", "| k=2 Average | | | 0.629 | 0.206 | 0.137 |\n", "+------------------+-------+-------+-------+-------+--------+\n", "| a*b*(cc,d) | 0.976 | 0.000 | -- | -- | -- |\n", "+------------------+-------+-------+-------+-------+--------+\n", "| Overall averages | | | 0.624 | 0.226 | 0.125 |\n", "+------------------+-------+-------+-------+-------+--------+\n", "\n", " Pairwise dominance\n", "+------------+-------+-------------+---------+\n", "| Pairs | Total | Conditional | General |\n", "+------------+-------+-------------+---------+\n", "| a - b | 1.0 | 1.0 | 1.0 |\n", "| a - (cc-d) | 1.0 | 1.0 | 1.0 |\n", "| b - (cc-d) | 1.0 | 1.0 | 1.0 |\n", "+------------+-------+-------------+---------+\n", "\n", "= Statsample::DominanceAnalysis::Bootstrap\n", " == Bootstrap dominance Analysis: a,b,cc,d,y1,y2 over [:y1, :y2]\n", " Sample size: 100\n", "\n", " t: 1.9842169363295818\n", "\n", " Linear Regression Engine: Statsample::Regression::Multiple::MultipleDependent\n", " Bootstrap report\n", "+-----------------------+-----+--------+---------+-------+-------+-------+-----------------+\n", "| pairs | sD | Dij | SE(Dij) | Pij | Pji | Pno | Reproducibility |\n", "+-----------------------+-----+--------+---------+-------+-------+-------+-----------------+\n", "| Complete dominance | | | | | | | |\n", "+-----------------------+-----+--------+---------+-------+-------+-------+-----------------+\n", "| a - b | 1.0 | 1.0000 | 0.000 | 1.000 | 0.000 | 0.000 | 1.000 |\n", "| a - cc | 1.0 | 1.0000 | 0.000 | 1.000 | 0.000 | 0.000 | 1.000 |\n", "| a - d | 1.0 | 1.0000 | 0.000 | 1.000 | 0.000 | 0.000 | 1.000 |\n", "| b - cc | 0.5 | 0.4500 | 0.379 | 0.000 | 0.000 | 0.000 | 0.000 |\n", "| b - d | 1.0 | 0.5800 | 0.448 | 0.000 | 0.000 | 0.000 | 0.000 |\n", "| cc - d | 0.5 | 0.5800 | 0.381 | 0.000 | 0.000 | 0.000 | 0.000 |\n", "+-----------------------+-----+--------+---------+-------+-------+-------+-----------------+\n", "| Conditional dominance | | | | | | | |\n", "+-----------------------+-----+--------+---------+-------+-------+-------+-----------------+\n", "| a - b | 1.0 | 1.0000 | 0.000 | 1.000 | 0.000 | 0.000 | 1.000 |\n", "| a - cc | 1.0 | 1.0000 | 0.000 | 1.000 | 0.000 | 0.000 | 1.000 |\n", "| a - d | 1.0 | 1.0000 | 0.000 | 1.000 | 0.000 | 0.000 | 1.000 |\n", "| b - cc | 0.5 | 0.4550 | 0.383 | 0.000 | 0.000 | 0.000 | 0.000 |\n", "| b - d | 1.0 | 0.5800 | 0.459 | 0.000 | 0.000 | 0.000 | 0.000 |\n", "| cc - d | 0.5 | 0.5700 | 0.389 | 0.000 | 0.000 | 0.000 | 0.000 |\n", "+-----------------------+-----+--------+---------+-------+-------+-------+-----------------+\n", "| General Dominance | | | | | | | |\n", "+-----------------------+-----+--------+---------+-------+-------+-------+-----------------+\n", "| a - b | 1.0 | 1.0000 | 0.000 | 1.000 | 0.000 | 0.000 | 1.000 |\n", "| a - cc | 1.0 | 1.0000 | 0.000 | 1.000 | 0.000 | 0.000 | 1.000 |\n", "| a - d | 1.0 | 1.0000 | 0.000 | 1.000 | 0.000 | 0.000 | 1.000 |\n", "| b - cc | 1.0 | 0.6300 | 0.485 | 0.000 | 0.000 | 0.000 | 0.000 |\n", "| b - d | 1.0 | 0.5800 | 0.496 | 0.000 | 0.000 | 0.000 | 0.000 |\n", "| cc - d | 0.0 | 0.3800 | 0.488 | 0.000 | 0.000 | 0.000 | 0.000 |\n", "+-----------------------+-----+--------+---------+-------+-------+-------+-----------------+\n", "\n", " General averages\n", "+-----+-------+-------+-------+-------+\n", "| var | mean | se | p.5 | p.95 |\n", "+-----+-------+-------+-------+-------+\n", "| a | 0.934 | 0.017 | 0.908 | 0.962 |\n", "| b | 0.021 | 0.010 | 0.007 | 0.042 |\n", "| cc | 0.016 | 0.011 | 0.003 | 0.039 |\n", "| d | 0.020 | 0.012 | 0.003 | 0.040 |\n", "+-----+-------+-------+-------+-------+\n", "\n", " == Bootstrap dominance Analysis: a,b,cc,d,y1 over y1\n", " Sample size: 100\n", "\n", " t: 1.9842169363295818\n", "\n", " Linear Regression Engine: Statsample::Regression::Multiple::MatrixEngine\n", " Bootstrap report\n", "+-----------------------+-----+--------+---------+-------+-------+-------+-----------------+\n", "| pairs | sD | Dij | SE(Dij) | Pij | Pji | Pno | Reproducibility |\n", "+-----------------------+-----+--------+---------+-------+-------+-------+-----------------+\n", "| Complete dominance | | | | | | | |\n", "+-----------------------+-----+--------+---------+-------+-------+-------+-----------------+\n", "| a - b | 1.0 | 0.9950 | 0.050 | 0.000 | 0.000 | 0.000 | 0.000 |\n", "| a - cc | 1.0 | 1.0000 | 0.000 | 1.000 | 0.000 | 0.000 | 1.000 |\n", "| a - d | 1.0 | 0.9900 | 0.100 | 0.000 | 0.000 | 0.000 | 0.000 |\n", "| b - cc | 1.0 | 0.6700 | 0.434 | 0.000 | 0.000 | 0.000 | 0.000 |\n", "| b - d | 0.5 | 0.5050 | 0.429 | 0.000 | 0.000 | 0.000 | 0.000 |\n", "| cc - d | 0.0 | 0.4000 | 0.426 | 0.000 | 0.000 | 0.000 | 0.000 |\n", "+-----------------------+-----+--------+---------+-------+-------+-------+-----------------+\n", "| Conditional dominance | | | | | | | |\n", "+-----------------------+-----+--------+---------+-------+-------+-------+-----------------+\n", "| a - b | 1.0 | 0.9950 | 0.050 | 0.000 | 0.000 | 0.000 | 0.000 |\n", "| a - cc | 1.0 | 1.0000 | 0.000 | 1.000 | 0.000 | 0.000 | 1.000 |\n", "| a - d | 1.0 | 0.9900 | 0.100 | 0.000 | 0.000 | 0.000 | 0.000 |\n", "| b - cc | 1.0 | 0.6700 | 0.445 | 0.000 | 0.000 | 0.000 | 0.000 |\n", "| b - d | 0.5 | 0.5100 | 0.449 | 0.000 | 0.000 | 0.000 | 0.000 |\n", "| cc - d | 0.0 | 0.4000 | 0.438 | 0.000 | 0.000 | 0.000 | 0.000 |\n", "+-----------------------+-----+--------+---------+-------+-------+-------+-----------------+\n", "| General Dominance | | | | | | | |\n", "+-----------------------+-----+--------+---------+-------+-------+-------+-----------------+\n", "| a - b | 1.0 | 0.9900 | 0.100 | 0.000 | 0.000 | 0.000 | 0.000 |\n", "| a - cc | 1.0 | 1.0000 | 0.000 | 1.000 | 0.000 | 0.000 | 1.000 |\n", "| a - d | 1.0 | 0.9900 | 0.100 | 0.000 | 0.000 | 0.000 | 0.000 |\n", "| b - cc | 1.0 | 0.6900 | 0.465 | 0.000 | 0.000 | 0.000 | 0.000 |\n", "| b - d | 1.0 | 0.5400 | 0.501 | 0.000 | 0.000 | 0.000 | 0.000 |\n", "| cc - d | 0.0 | 0.3900 | 0.490 | 0.000 | 0.000 | 0.000 | 0.000 |\n", "+-----------------------+-----+--------+---------+-------+-------+-------+-----------------+\n", "\n", " General averages\n", "+-----+-------+-------+-------+-------+\n", "| var | mean | se | p.5 | p.95 |\n", "+-----+-------+-------+-------+-------+\n", "| a | 0.144 | 0.038 | 0.094 | 0.223 |\n", "| b | 0.030 | 0.017 | 0.010 | 0.065 |\n", "| cc | 0.022 | 0.016 | 0.004 | 0.049 |\n", "| d | 0.031 | 0.024 | 0.004 | 0.078 |\n", "+-----+-------+-------+-------+-------+\n", "\n", "\n" ] } ], "source": [ "require 'statsample'\n", "\n", "Statsample::Analysis.store(Statsample::DominanceAnalysis::Bootstrap) do\n", " \n", " # Remember to call *update* after an assignment/deletion cycle if lazy_update\n", " # is *false*.\n", " Daru.lazy_update = true\n", " sample=300\n", " a=rnorm(sample)\n", " b=rnorm(sample)\n", " c=rnorm(sample)\n", " d=rnorm(sample) \n", " a.rename :a\n", " b.rename :b\n", " c.rename :c\n", " d.rename :d\n", " \n", " ds = Daru::DataFrame.new({:a => a,:b => b,:cc => c,:d => d})\n", " attach(ds)\n", " ds[:y1] = a*5 + b*2 + cc*2 + d*2 + rnorm(sample,0,10)\n", " ds[:y2] = a*10 + rnorm(sample)\n", " \n", " dab=dominance_analysis_bootstrap(ds, [:y1,:y2], :debug=>true)\n", " dab.bootstrap(100,nil)\n", " summary(dab)\n", " ds2=ds[:a, :b, :cc, :d, :y1]\n", " dab2=dominance_analysis_bootstrap(ds2, :y1, :debug=>true)\n", " dab2.bootstrap(100,nil)\n", " summary(dab2)\n", " Daru.lazy_update = false\n", "end\n", "\n", "Statsample::Analysis.run_batch" ] } ], "metadata": { "kernelspec": { "display_name": "Ruby 2.2.1", "language": "ruby", "name": "ruby" }, "language_info": { "file_extension": "rb", "mimetype": "application/x-ruby", "name": "ruby", "version": "2.2.1" } }, "nbformat": 4, "nbformat_minor": 0 }