Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

Analytics and Notifications for PI System Explorer (PI Server 2018)

LinRegr

  • Last UpdatedMay 08, 2024
  • 2 minute read

Apply linear least squares fitting to two sets of values given by attributes over a specified time range. The output is a one-based array with the values of the slope, intercept and R2.

Syntax

LinRegr(x, y, mode, starttime, endtime [, pctgood])

LinRegr(y, starttime, endtime [, pctgood])

Arguments

  • x

    an attribute with the first set of time series data (such as PI point data reference) enclosed in single quotes

  • y

    an attribute with the second set of time series data (such as PI point data reference) enclosed in single quotes

  • mode

    a number that specifies how to align time-stamped values

  • choose from 0, 1 or 2 where:

    0 represents the combination of time-stamped values from x and y

    1 represents values from both attributes according to x's time stamps

    2 represents values from both attributes according to y's time stamps

  • starttime

    a time expression representing the beginning of a time range enclosed in single quotes; can be a relative time (such as '-3h') in reference to an absolute endtime

  • endtime

    a time expression representing the end of a time range enclosed in single quotes; can be a relative time (such as '+1h') in reference to an absolute starttime

  • pctgood

    Optional. Minimum percentage of attribute values during the time range that must be good.

    You can set pctgood as a threshold to ensure that there are sufficient good values to calculate LinRegr.

Returns

One-based array with the values of slope, intercept and R2.

Exceptions

If the attribute has no good values or the pctgood minimum is not reached for the given time range, returns an error value

Notes

Bad values are excluded from LinRegr calculation.

For LinRegr(y, starttime, endtime [, pctgood]), the unit of the output slope is unit of y/second.

Note: If the attribute has very few good values during the time range, this function's result may not be trustworthy. Use the PctGood function to find out what percentage of the values is good.

Index the slope, intercept and R2 outputs from [1].

Example

  • LinRegr('att1', 'att2', 0, 't', '+1h', 80)

    [Return a one-based array of slope, intercept and R2 based on time-stamped values of 'att1' and 'att2' between 12:00 and 1:00am today when at least 80% of the values were good. Return an error when minimum pctgood is not reached]

  • LinRegr('att1', 'att2', 1, 't', '+1h')

    [Return a one-based array of slope, intercept and R2 based on time-stamped values of 'att1' between 12:00 and 1:00am today]

  • LinRegr('att1', 't', '+1h', 80)

    [Return a one-based array of slope, intercept and R2 of 'att1' between 12:00 and 1:00am today when at least 80% of the values were good. Return an error when minimum pctgood is not reached]

  • LinRegr('att1', 't', '+1h')

    [Return a one-based array of slope, intercept and R2 of 'att1' between 12:00 and 1:00am today]

In This Topic
TitleResults for “How to create a CRG?”Also Available in