1 package ubic.basecode.math.linearmodels;
2
3 import ubic.basecode.dataStructure.matrix.DoubleMatrix;
4
5 import javax.annotation.Nullable;
6 import java.io.Serializable;
7 import java.util.List;
8 import java.util.Map;
9
10 public interface LinearModelSummary extends Serializable {
11
12 String INTERCEPT_COEFFICIENT_NAME = "(Intercept)";
13
14 /**
15 * @return may be null if ANOVA was not run.
16 */
17 @Nullable
18 GenericAnovaResult getAnova();
19
20 double[] getCoefficients();
21
22 /**
23 * @return The contrast coefficients and associated statistics for all tested contrasts.
24 * <p>
25 * Row names are the contrasts, for example for a model with one
26 * factor "f" with two
27 * levels "a" and "b": {"(Intercept)", "fb"}. columns are always {"Estimate" ,"Std. Error", "t value",
28 * "Pr(>|t|)"}
29 *
30 */
31 DoubleMatrix<String, String> getContrastCoefficients();
32
33 Map<String, Double> getContrastCoefficients( String factorName );
34
35 /**
36 * For the requested factor, return the standard errors associated with the contrast coefficient estimates.
37 */
38 Map<String, Double> getContrastCoefficientStderr( String factorName );
39
40 /**
41 * @return Map of pvalues for the given factor. For continuous factors or factors with only one level, there will be
42 * just one value. For factors with N>2 levels, there will be N-1 values, one for each contrast
43 * (since we compute treatment contrasts to the baseline)
44 */
45 Map<String, Double> getContrastPValues( String factorName );
46
47 /**
48 * @return Map of T statistics for the given factor. For continuous factors or factors with only one level, there
49 * will be just one value. For factors with N>2 levels, there will be N-1 values, one for each contrast
50 * (since we compute treatment contrasts to the baseline)
51 */
52 Map<String, Double> getContrastTStats( String factorName );
53
54 double[] getEffects();
55
56 /**
57 * @return F statistic for overall model fit.
58 */
59 double getFStat();
60
61 /**
62 * @return the factorNames
63 */
64 List<String> getFactorNames();
65
66 double getInterceptCoefficient();
67
68 double getInterceptPValue();
69
70 double getInterceptTStat();
71
72 String getKey();
73
74 double getNumeratorDof();
75
76 /**
77 * Overall p value for F stat of model fit (upper tail probability)
78 *
79 * @return value or NaN if it can't be computed for some reason
80 */
81 double getOverallPValue();
82
83 /**
84 * @return the priorDof
85 */
86 double getPriorDof();
87
88 double getResidualsDof();
89
90 /**
91 * @return the residuals
92 */
93 double[] getResiduals();
94
95 /**
96 * @return the rSquared
97 */
98 double getRSquared();
99
100 /**
101 * @return the adjRSquared
102 */
103 double getAdjRSquared();
104
105 /**
106 * Residual standard deviation
107 */
108 double getSigma();
109
110 /**
111 * Unscaled standard deviations for the coefficient estimators in same order as coefficients. The standard errors
112 * are given by stdev.unscaled * sigma (a la limma)
113 */
114 double[] getStdevUnscaled();
115
116 boolean isBaseline( String factorValueName );
117
118 /**
119 * Whether this is the result of emprical bayes shrinkage of variance estimates
120 */
121 boolean isShrunken();
122 }