Calculate the expected frequencies of an n-way table assuming independence.

ExpFreq(x, freq = c("abs", "rel"))

Arguments

x

a table.

freq

indicates, whether absolute or relative frenquencies should be computed. Can either be "abs" or "rel". Partial matching is supported.

Value

A table with either the absolute or the relative expected frequencies.

Note

This is a copy of the function independence_table in vcd.

Author

David Meyer <David.Meyer@R-project.org>

See also

Examples

ExpFreq(Titanic)
#> , , Age = Child, Survived = No
#> 
#>       Sex
#> Class       Male   Female
#>   1st   8.569058 2.326665
#>   2nd   7.514404 2.040306
#>   3rd  18.614630 5.054232
#>   Crew 23.334203 6.335688
#> 
#> , , Age = Adult, Survived = No
#> 
#>       Sex
#> Class      Male    Female
#>   1st  164.4630  44.65489
#>   2nd  144.2214  39.15890
#>   3rd  357.2643  97.00416
#>   Crew 447.8454 121.59870
#> 
#> , , Age = Child, Survived = Yes
#> 
#>       Sex
#> Class       Male    Female
#>   1st   4.088993 1.1102408
#>   2nd   3.585733 0.9735958
#>   3rd   8.882552 2.4117847
#>   Crew 11.134643 3.0232711
#> 
#> , , Age = Adult, Survived = Yes
#> 
#>       Sex
#> Class       Male   Female
#>   1st   78.47866 21.30848
#>   2nd   68.81975 18.68589
#>   3rd  170.47980 46.28856
#>   Crew 213.70343 58.02462
#> 

ExpFreq(UCBAdmissions, freq="r")
#> , , Dept = A
#> 
#>           Gender
#> Admit            Male     Female
#>   Admitted 0.04752573 0.03240792
#>   Rejected 0.07503920 0.05116943
#> 
#> , , Dept = B
#> 
#>           Gender
#> Admit            Male     Female
#>   Admitted 0.02979909 0.02032008
#>   Rejected 0.04705030 0.03208373
#> 
#> , , Dept = C
#> 
#>           Gender
#> Admit            Male     Female
#>   Admitted 0.04676165 0.03188689
#>   Rejected 0.07383279 0.05034677
#> 
#> , , Dept = D
#> 
#>           Gender
#> Admit            Male     Female
#>   Admitted 0.04034339 0.02751026
#>   Rejected 0.06369887 0.04343643
#> 
#> , , Dept = E
#> 
#>           Gender
#> Admit            Male     Female
#>   Admitted 0.02974815 0.02028534
#>   Rejected 0.04696988 0.03202888
#> 
#> , , Dept = F
#> 
#>           Gender
#> Admit            Male     Female
#>   Admitted 0.03637017 0.02480092
#>   Rejected 0.05742550 0.03915860
#>