mondrian.olap.fun
Class LinReg

java.lang.Object
  extended by org.eigenbase.xom.XMLUtil
      extended by org.eigenbase.xom.XOMUtil
          extended by mondrian.olap.Util
              extended by mondrian.olap.fun.FunUtil
                  extended by mondrian.olap.fun.FunDefBase
                      extended by mondrian.olap.fun.LinReg
All Implemented Interfaces:
FunDef
Direct Known Subclasses:
LinReg.InterceptFunDef, LinReg.PointFunDef, LinReg.R2FunDef, LinReg.SlopeFunDef, LinReg.VarianceFunDef

public abstract class LinReg
extends FunDefBase

Abstract base class for definitions of linear regression functions.

See Also:
LinReg.InterceptFunDef, LinReg.PointFunDef, LinReg.R2FunDef, LinReg.SlopeFunDef,

Correlation coefficient

Correlation coefficient

The correlation coefficient, r, ranges from -1 to + 1. The nonparametric Spearman correlation coefficient, abbreviated rs, has the same range.

Value of r (or rs) Interpretation
r= 0 The two variables do not vary together at all.
0 > r > 1

The two variables tend to increase or decrease together.

r = 1.0

Perfect correlation.

-1 > r > 0

One variable increases as the other decreases.

r = -1.0

Perfect negative or inverse correlation.

If r or rs is far from zero, there are four possible explanations:

The X variable helps determine the value of the Y variable.

  • The Y variable helps determine the value of the X variable.
  • Another variable influences both X and Y.
  • X and Y don't really correlate at all, and you just happened to observe such a strong correlation by chance. The P value determines how often this could occur.

r2

Perhaps the best way to interpret the value of r is to square it to calculate r2. Statisticians call this quantity the coefficient of determination, but scientists call it r squared. It is has a value that ranges from zero to one, and is the fraction of the variance in the two variables that is shared. For example, if r2=0.59, then 59% of the variance in X can be explained by variation in Y.  Likewise, 59% of the variance in Y can be explained by (or goes along with) variation in X. More simply, 59% of the variance is shared between X and Y.

(Source).

Also see: least squares fitting.

 

Nested Class Summary
static class LinReg.InterceptFunDef
          Definition of the LinRegIntercept MDX function.
static class LinReg.PointFunDef
          Definition of the LinRegPoint MDX function.
static class LinReg.R2FunDef
          Definition of the LinRegR2 MDX function.
static class LinReg.SlopeFunDef
          Definition of the LinRegSlope MDX function.
(package private) static class LinReg.Value
           
static class LinReg.VarianceFunDef
          Definition of the LinRegVariance MDX function.
 
Nested classes/interfaces inherited from class mondrian.olap.fun.FunUtil
FunUtil.SetWrapper
 
Nested classes/interfaces inherited from class mondrian.olap.Util
Util.ErrorCellValue, Util.PropertyList
 
Field Summary
static int Intercept
           
(package private) static Resolver InterceptResolver
           
static int Point
           
(package private) static Resolver PointResolver
           
static int R2
           
(package private) static Resolver R2Resolver
           
(package private)  int regType
          Code for the specific function.
static int Slope
           
(package private) static Resolver SlopeResolver
           
static int Variance
           
(package private) static Resolver VarianceResolver
           
 
Fields inherited from class mondrian.olap.fun.FunDefBase
flags, parameterCategories, returnCategory, signature
 
Fields inherited from class mondrian.olap.fun.FunUtil
BooleanNull, DoubleEmpty, DoubleNull, emptyStringArray, IntegerNull, NullMember
 
Fields inherited from class mondrian.olap.Util
EmptyValue, JdbcVersion, nl, nullValue, PreJdk15, Retrowoven
 
Constructor Summary
protected LinReg(FunDef funDef, int regType)
           
 
Method Summary
static LinReg.Value accuracy(LinReg.Value value)
           
 Calc compileCall(ResolvedFunCall call, ExpCompiler compiler)
          Converts a call to this function into executable objects.
protected static void debug(String type, String msg)
           
static List forecast(LinReg.Value value)
           
static LinReg.Value linearReg(List xlist, List ylist)
           
protected static LinReg.Value process(Evaluator evaluator, ListCalc listCalc, DoubleCalc yCalc, DoubleCalc xCalc, boolean isTuples)
           
 
Methods inherited from class mondrian.olap.fun.FunDefBase
castType, createCall, getDescription, getName, getParameterCategories, getResultType, getReturnCategory, getSignature, getSyntax, unparse, validateArg
 
Methods inherited from class mondrian.olap.fun.FunUtil
addMembers, addMembers, addUnique, ancestor, appendTuple, avg, checkCompatible, checkFlag, checkIterListResultStyles, checkListResultStyles, compareHierarchically, compareSiblingMembers, compareValues, compareValues, compareValues, correlation, count, cousin, covariance, createDummyFunDef, decodeCategory, decodeParameterCategories, decodeReturnCategory, decodeSyntacticType, dimensionMembers, equalTuple, evaluateMembers, evaluateMembers, evaluateSet, evaluateSet, evaluateTuples, getLiteralArg, getLiteralArg, getNonEmptyLevelMembers, getNonEmptyMemberChildren, hierarchize, hierarchyMembers, isAncestorOf, isMemberType, levelMembers, makeNullMember, makeNullTuple, max, memberRange, min, newEvalException, newEvalException, percentile, periodsToDate, quartile, removeCalculatedMembers, resolveFunArgs, searchValuesDesc, sign, sortMembers, sortTuples, sortValuesDesc, stdev, sum, sumDouble, sumDouble, toPercent, tupleContainsNullMember, var
 
Methods inherited from class mondrian.olap.Util
addDatabaseTime, addLevelCalculatedMembers, areOccurencesEqual, assertPostcondition, assertPostcondition, assertPrecondition, assertPrecondition, assertTrue, assertTrue, badValue, camelToUpper, caseSensitiveCompareName, cast, cast, checkCJResultLimit, commaList, compareKey, compareName, convertStackToString, createExpr, createRandom, createSimpleValidator, createUdf, dbTimeMillis, deprecated, enumSetAllOf, enumSetNoneOf, enumSetOf, equal, equalName, equals, equals, getAnnotation, getErrorMessage, getErrorMessage, getFirstDescendantOnLevel, getMemberOrdinalInParent, hash, hash, hashArray, implode, isEmpty, isNull, isSorted, isValidProperty, lookup, lookup, lookup, lookup, lookupCompound, lookupCompound, lookupHierarchyLevel, lookupHierarchyRootMember, lookupHierarchyRootMember, lookupProperty, makeBigDecimalFromDouble, makeFqName, makeFqName, makeFqName, maskVersion, mdxEncodeString, needToImplement, newError, newError, newInternal, newInternal, nonDbTimeMillis, normalizeName, parseCommaList, parseConnectString, parseIdentifier, printMemory, printMemory, quoteForMdx, quoteMdxIdentifier, quoteMdxIdentifier, quoteMdxIdentifier, quoteMdxIdentifier, quotePattern, readFully, readURL, readURL, readURL, readURL, replace, replace, replaceProperties, singleQuoteString, singleQuoteString, toMap, toURL, unexpected, union, union, uniquify, unparse, unparse, wildcardToRegexp
 
Methods inherited from class org.eigenbase.xom.XOMUtil
addAll, addAll, addChild, addChild, addChildren, addElement, concatenate, createDefaultParser, discard, discard, discard, discard, discard, discard, discard, discard, discard, getFirstInstance, toList, toVector, wrapperToXml
 
Methods inherited from class org.eigenbase.xom.XMLUtil
getFirstTagName, printAtt, printAtt, printAtt, printAtt, printPCDATA, printPCDATA, printPCDATA, quoteAtt, quoteAtt, quoteAtt, quoteAtt, quotePCDATA, stringEncodeXML, stringHasXMLSpecials
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

regType

final int regType
Code for the specific function.


Point

public static final int Point
See Also:
Constant Field Values

R2

public static final int R2
See Also:
Constant Field Values

Intercept

public static final int Intercept
See Also:
Constant Field Values

Slope

public static final int Slope
See Also:
Constant Field Values

Variance

public static final int Variance
See Also:
Constant Field Values

InterceptResolver

static final Resolver InterceptResolver

PointResolver

static final Resolver PointResolver

SlopeResolver

static final Resolver SlopeResolver

R2Resolver

static final Resolver R2Resolver

VarianceResolver

static final Resolver VarianceResolver
Constructor Detail

LinReg

protected LinReg(FunDef funDef,
                 int regType)
Method Detail

compileCall

public Calc compileCall(ResolvedFunCall call,
                        ExpCompiler compiler)
Description copied from interface: FunDef
Converts a call to this function into executable objects.

The result must implement the appropriate interface for the result type. For example, a function which returns an integer must return an object which implements IntegerCalc.

Specified by:
compileCall in interface FunDef
Overrides:
compileCall in class FunDefBase

debug

protected static void debug(String type,
                            String msg)

process

protected static LinReg.Value process(Evaluator evaluator,
                                      ListCalc listCalc,
                                      DoubleCalc yCalc,
                                      DoubleCalc xCalc,
                                      boolean isTuples)

accuracy

public static LinReg.Value accuracy(LinReg.Value value)

linearReg

public static LinReg.Value linearReg(List xlist,
                                     List ylist)

forecast

public static List forecast(LinReg.Value value)

SourceForge.net_Logo