Package ubic.basecode.math.linearmodels
Class LinearModelSummary
- java.lang.Object
-
- ubic.basecode.math.linearmodels.LinearModelSummary
-
- All Implemented Interfaces:
Serializable
public class LinearModelSummary extends Object implements Serializable
Represents the results of a linear model analysis from R. Both the summary.lm and anova objects are represented. FIXME make this have the capabilities of the "fit" object, rather than just the summary.- Author:
- paul
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
INTERCEPT_COEFFICIENT_NAME
-
Constructor Summary
Constructors Modifier Constructor Description protected
LinearModelSummary()
Construct an empty summary.LinearModelSummary(String key)
Construct an empty summary.LinearModelSummary(String k, Double[] coefficients, Double[] residuals, List<String> terms, DoubleMatrix<String,String> contrastCoefficients, Double[] effects, Double[] stdevUnscaled, double rsquared, double adjRsquared, double fstat, Integer ndof, Integer ddof, GenericAnovaResult anovaResult, double sigma, boolean isShrunken)
LinearModelSummary(org.rosuda.REngine.REXP summaryLm, org.rosuda.REngine.REXP anova, String[] factorNames)
Construct from the result of evaluation of an R call.
-
Method Summary
-
-
-
Field Detail
-
INTERCEPT_COEFFICIENT_NAME
public static final String INTERCEPT_COEFFICIENT_NAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
LinearModelSummary
public LinearModelSummary(org.rosuda.REngine.REXP summaryLm, org.rosuda.REngine.REXP anova, String[] factorNames)
Construct from the result of evaluation of an R call. should be deprecated because we're not using R integration- Parameters:
summaryLm
-anova
-factorNames
- as referred to in the model. Used as keys to keep track of coefficients etc.
-
LinearModelSummary
public LinearModelSummary(String key)
Construct an empty summary. Use for model fits that fail due to 0 degrees of freedom, etc.- Parameters:
key
- identifier
-
LinearModelSummary
public LinearModelSummary(String k, Double[] coefficients, Double[] residuals, List<String> terms, DoubleMatrix<String,String> contrastCoefficients, Double[] effects, Double[] stdevUnscaled, double rsquared, double adjRsquared, double fstat, Integer ndof, Integer ddof, GenericAnovaResult anovaResult, double sigma, boolean isShrunken)
- Parameters:
k
- optional identifiercoefficients
-residuals
-terms
-contrastCoefficients
-effects
- AKA Qtyrsquared
-adjRsquared
-fstat
-ndof
-ddof
-anovaResult
-sigma
-isShrunken
-
-
LinearModelSummary
protected LinearModelSummary()
Construct an empty summary. Use for model fits that fail due to 0 residual degrees of freedom, etc.
-
-
Method Detail
-
getAdjRSquared
public Double getAdjRSquared()
- Returns:
- the adjRSquared
-
getAnova
public GenericAnovaResult getAnova()
- Returns:
- may be null if ANOVA was not run.
-
getCoefficients
public Double[] getCoefficients()
-
getContrastCoefficients
public DoubleMatrix<String,String> getContrastCoefficients()
- Returns:
- The contrast coefficients and associated statistics for all tested contrasts.
Row names are the contrasts, for example for a model with one factor "f" with two levels "a" and "b": {"(Intercept)", "fb"}. columns are always {"Estimate" ,"Std. Error", "t value", "Pr(>|t|)"}
-
getContrastCoefficients
public Map<String,Double> getContrastCoefficients(String factorName)
- Parameters:
factorName
-- Returns:
-
getContrastCoefficientStderr
public Map<String,Double> getContrastCoefficientStderr(String factorName)
For the requested factor, return the standard errors associated with the contrast coefficient estimates.- Parameters:
factorName
-- Returns:
-
getContrastPValues
public Map<String,Double> getContrastPValues(String factorName)
- Parameters:
factorName
-- Returns:
- Map of pvalues for the given factor. For continuous factors or factors with only one level, there will be just one value. For factors with N>2 levels, there will be N-1 values, one for each contrast (since we compute treatment contrasts to the baseline)
-
getContrastTStats
public Map<String,Double> getContrastTStats(String factorName)
- Parameters:
factorName
-- Returns:
- Map of T statistics for the given factor. For continuous factors or factors with only one level, there will be just one value. For factors with N>2 levels, there will be N-1 values, one for each contrast (since we compute treatment contrasts to the baseline)
-
getEffects
public Double[] getEffects()
- Returns:
-
getF
public Double getF()
- Returns:
- F statistic for overall model fit.
-
getFactorValueNames
public List<String> getFactorValueNames(String factorName)
Return the factor names in the order they are stored here. Pvalues and T statistics for this factor are in the same order, but the 'baseline' must be accounted for.- Parameters:
factorName
-- Returns:
-
getFormula
public String getFormula()
- Returns:
- the formula
-
getInteractionEffectP
public Double getInteractionEffectP(String... fnames)
- Parameters:
fnames
- names of the factors- Returns:
- See Also:
ubic.basecode.math.linearmodels.GenericAnovaResult#getInteractionEffectP(java.lang.String)
-
getInterceptCoeff
public Double getInterceptCoeff()
- Returns:
-
getInterceptP
public Double getInterceptP()
- Returns:
-
getInterceptT
public Double getInterceptT()
- Returns:
-
getKey
public String getKey()
-
getMainEffectFactorNames
public Collection<String> getMainEffectFactorNames()
- Returns:
- See Also:
GenericAnovaResult.getMainEffectFactorNames()
-
getMainEffectP
public Double getMainEffectP(String factorName)
- Parameters:
factorName
-- Returns:
- overall p-value for the given factor
- See Also:
GenericAnovaResult.getMainEffectP(java.lang.String)
-
getNumeratorDof
public Integer getNumeratorDof()
- Returns:
-
getP
public Double getP()
Overall p value for F stat of model fit (upper tail probability)- Returns:
- value or NaN if it can't be computed for some reason
-
getPriorDof
public Double getPriorDof()
- Returns:
- the priorDof
-
getResidualDof
public Integer getResidualDof()
- Returns:
-
getResiduals
public Double[] getResiduals()
- Returns:
- the residuals
-
getRSquared
public Double getRSquared()
- Returns:
- the rSquared
-
getSigma
public Double getSigma()
Residual standard deviation- Returns:
-
getStdevUnscaled
public Double[] getStdevUnscaled()
Unscaled standard deviations for the coefficient estimators in same order as coefficients. The standard errors are given by stdev.unscaled * sigma (a la limma)
-
hasInteractions
public boolean hasInteractions()
- Returns:
- See Also:
GenericAnovaResult.hasInteractions()
-
isBaseline
public boolean isBaseline(String factorValueName)
-
isShrunken
public boolean isShrunken()
Whether this is the result of emprical bayes shrinkage of variance estimates- Returns:
-
setAnova
public void setAnova(GenericAnovaResult genericAnovaResult)
- Parameters:
genericAnovaResult
-
-
setKey
public void setKey(String key)
-
setPriorDof
public void setPriorDof(Double priorDof)
- Parameters:
priorDof
- the priorDof to set
-
-