# Generic Anova two-way.¶ ↑

You could enter the sum of squares or the mean squares for a, b, axb and within. You should enter the degrees of freedom for a,b and within, because #df_axb=df_a*df_b

## Usage¶ ↑

```anova=Statsample::Anova::TwoWay(:ss_a=>10,:ss_b=>20,:ss_axb=>10, :ss_within=>20, :df_a=>2, :df_b=>3,df_within=100 @name=>"ANOVA for....")
```

# Generic Anova two-way.¶ ↑

You could enter the sum of squares or the mean squares for a, b, axb and within. You should enter the degrees of freedom for a,b and within, because #df_axb=df_a*df_b

## Usage¶ ↑

```anova=Statsample::Anova::TwoWay(:ss_a=>10,:ss_b=>20,:ss_axb=>10, :ss_within=>20, :df_a=>2, :df_b=>3,df_within=100 @name=>"ANOVA for....")
```

### Attributes

df_a[R]
df_axb[R]
df_b[R]
df_total[R]
df_within[R]
f_a_object[R]
f_axb_object[R]
f_b_object[R]
ms_a[R]
ms_axb[R]
ms_b[R]
ms_total[R]
ms_within[R]
name[RW]

Name of ANOVA Analisys

name_a[RW]

Name of a factor

name_b[RW]

Name of b factor

name_within[RW]

Name of within factor

ss_a[R]
ss_axb[R]
ss_b[R]
ss_total[R]
ss_within[R]

### Public Class Methods

new(opts=Hash.new) click to toggle source
```# File lib/statsample/anova/twoway.rb, line 23
def initialize(opts=Hash.new)
# First see if sum of squares or mean squares are entered
raise ArgumentError, "You should set all d.f." unless [:df_a, :df_b, :df_within].all? {|v| opts.has_key? v}

@df_a=opts.delete :df_a
@df_b=opts.delete :df_b
@df_axb=@df_a*@df_b
@df_within=opts.delete :df_within
@df_total=@df_a+@df_b+@df_axb+@df_within

if [:ss_a, :ss_b, :ss_axb, :ss_within].all? {|v| opts.has_key? v}
@ss_a = opts.delete :ss_a
@ss_b = opts.delete :ss_b
@ss_axb = opts.delete :ss_axb
@ss_within = opts.delete :ss_within

@ms_a =@ss_a.quo(@df_a)
@ms_b =@ss_b.quo(@df_b)
@ms_axb =@ss_axb.quo(@df_axb)
@ms_within =@ss_within.quo(@df_within)

elsif [:ms_a, :ms_b, :ms_axb, :ms_within].all? {|v| opts.has_key? v}
@ms_a = opts.delete :ms_a
@ms_b = opts.delete :ms_b
@ms_axb = opts.delete :ms_axb
@ms_within = opts.delete :ms_within

@ss_a =@ms_a*@df_a
@ss_b =@ms_b*@df_b
@ss_axb =@ms_axb*@df_axb
@ss_within =@ms_within*@df_within
else
raise "You should set all ss or ss"
end
@ss_total=@ss_a+@ss_b+@ss_axb+@ss_within
@ms_total=@ms_a+@ms_b+@ms_axb+@ms_within
opts_default={:name=>_("ANOVA Two-Way"),
:name_a=>_("A"),
:name_b=>_("B"),
:name_within=>_("Within")
}
@opts=opts_default.merge(opts)
opts_default.keys.each {|k|
send("#{k}=", @opts[k])
}
@f_a_object=Statsample::Test::F.new(@ms_a,@ms_within,@df_a,@df_within)
@f_b_object=Statsample::Test::F.new(@ms_b,@ms_within,@df_b,@df_within)
@f_axb_object=Statsample::Test::F.new(@ms_axb,@ms_within,@df_axb,@df_within)
end```

### Public Instance Methods

f_a() click to toggle source
```# File lib/statsample/anova/twoway.rb, line 72
def f_a
@f_a_object.f
end```
f_a_probability() click to toggle source
```# File lib/statsample/anova/twoway.rb, line 81
def f_a_probability
@f_a_object.probability
end```
f_axb() click to toggle source
```# File lib/statsample/anova/twoway.rb, line 78
def f_axb
@f_axb_object.f
end```
f_axb_probability() click to toggle source
```# File lib/statsample/anova/twoway.rb, line 87
def f_axb_probability
@f_axb_object.probability
end```
f_b() click to toggle source
```# File lib/statsample/anova/twoway.rb, line 75
def f_b
@f_b_object.f
end```
f_b_probability() click to toggle source
```# File lib/statsample/anova/twoway.rb, line 84
def f_b_probability
@f_b_object.probability
end```