Assume that you have assigned the variable "model" as your LinearModelFit
result. Then you can get the F statistic and its p-value with:
model[{"ANOVATableFStatistics", "ANOVATablePValues"}]
For interactions, you can include them when you build your data. For example, assume that you have two independent variables. Build your data list as:
data = Table[{x1[[i]], x2[[i]], x1[[i]] x2[[i]], y[[i]]}, {i, 1, Length[y]}]
Now, run your regression:
model = LinearModelFit[data, {x1, x2, x3}, {x1, x2, x3}]
and examine the results:
model["ParameterTable"]
You can calculate the overall F statistic for the model by averaging the individual F statistics:
Mean[model["ANOVATableFStatistics"]]
To get the p value is a bit of a hassle, but this will do it:
1 - CDF[FRatioDistribution[Total[model["ANOVATableDegreesOfFreedom"][[1;;Length[model["ANOVATableFStatistics"]]]]], model["ANOVATableDegreesOfFreedom"][[-2]]], Mean[model["ANOVATableFStatistics"]]]
and here is a function to give both the F statistic and its p value as a list {f,p}
:
fStat[m_FittedModel] := {Mean[m["ANOVATableFStatistics"]],
1 - CDF[
FRatioDistribution[
Total[m["ANOVATableDegreesOfFreedom"][[1 ;;
Length[m["ANOVATableFStatistics"]]]]],
m["ANOVATableDegreesOfFreedom"][[-2]]],
Mean[m["ANOVATableFStatistics"]]]};
,
There may be easier ways to get these values, and I'd love to see them, but this is what I was able to figure out. I don't understand why MMA doesn't have these as properties.
ANOVA[]
for the interactions in my multiple regression? $\endgroup$