Perform Tests of Independence and Correlation
Perform Tests of Independence and Correlation
A series of factors were measured in 506 Boston suburbs with the intention of determining how these factors are related to home price.
Significant correlations among factors such as nitrogen oxide concentration and median home price serve as a reminder that correlation does not imply causation:
data = ExampleData[{"Statistics", "BostonHomes"}][[All, {3, 5, 6, 13, 14}]];
labs = {"Industrial
Percent", "NOX
Conc.", "Median
Home
Value", "Number
of
Rooms", "Poverty
Fraction"};
opts = Sequence[Frame -> True, Axes -> None, AspectRatio -> 1, PlotStyle -> PointSize[Medium], FrameTicks -> None, ImageSize -> {60, 60}, PlotRange -> All, Background -> White];GraphicsGrid[Table[If[i == j, ListPlot[{0}, PlotStyle -> None, Background -> Lighter[Blue, .9], opts, Epilog -> Inset@Style[labs[[i]], Bold, FontSize -> 12, FontFamily -> "Helvetica"]], ListPlot[#, opts]&[Transpose[{data[[All, j]], data[[All, i]]}]]], {i, 5}, {j, 5}], Spacings -> {4, 4}]KendallTau[data]//MatrixFormIndependenceTest suggests home values drop with increasing nitrogen oxide concentrations:
IndependenceTest[data[[All, 2]], data[[All, 3]], {"TestDataTable", {"KendallTau", "SpearmanRank", "HoeffdingD"}}]CorrelationTest[data[[All, 1 ;; 2]], 0, "TestDataTable"]