> ## Documentation Index
> Fetch the complete documentation index at: https://docs.repdata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# linearRegression

> # Description

Get linear regression analysis between two questions.

# Payload

```json
{
  "fromDate": string,
  "toDate": string,
  "questionId1": string,
  "questionId2": string,
  "filter": array
}
```

where:

* `fromDate`: start date in ISO format. __(Required)__.
* `toDate`: end date in ISO format. __(Required)__.
* `questionId1`: Question identifier for the `x` axis. __(Required)__.  
* `questionId2`: Question identifier for the `y` axis. __(Required)__.  
* `filter`: array of filters to filter the responses. (Optional).

# Response

## 200 OK

```json
{
    "x": "array",
    "y": "array",
    "slope": "number",
    "intercept": "number",
    "r": "number",
    "r2": "number",
    "adjustedR2": "number",
    "stdErrorR2": "number",
    "dfRegression": "integer",
    "dfResidual": ""integer",
    "dfTotal": "integer",
    "n": "integer",
    "regressionSS": "number",
    "residualErrorSS": "number",
    "totalSS": "integer",
    "regressionMS": "number",
    "residualErrorMS": "number",
    "f": "number",
    "fPValue": "number",
    "slopeB": "number",
    "slopeBError": "number",
    "interceptB": "number",
    "interceptBError": "number",
    "slopeBeta": "number",
    "slopeBT": "number",
    "slopeBPvalue": "number",
    "interceptBT": "number",
    "interceptBPvalue": "number"
}
```

- `x`: n-size array where the nth is the  option position for the nth answer of question 1.
- `y`: n-size array where the nth is the  option position for the nth answer of question 2.
- `slope`: Slope or gradient. Commonly denoted as **m** in y = **m** * x + b.
- `intercept`: Commonly denoted as **b** in in y = m * x + **b**.
- `r`: Correlation coefficient.
- `r2`: Correlation coefficient squared.
- `adjustedR2`: Adjusted correlation coefficient squared.
- `stdErrorR2`: a.k.a Standard error of the regression, standard error of the estimate.
- `dfRegression`: Degrees of freedom for regression, set as 1.
- `dfResidual`: Residual degrees of freedom.
- `dfTotal`: Degrees of freedom.
- `n`: Number of data points.
- `regressionSS`: Regression sum of squares.
- `residualErrorSS`: Residual sum of squares.
- `totalSS`: Total sum of squares.
- `regressionMS`: Regression mean square.
- `residualErrorMS`: Residual mean square.
- `f`: F-test.
- `fPValue`: F-test **P** value.
- `slopeB`: Slope B (based on standard deviation).
- `slopeBError`: Standard error of B.
- `interceptB`: Intercept B.
- `interceptBError`: Error of intercept.
- `slopeBeta`: Beta coefficient.
- `slopeBT`: Slope BT.
- `slopeBPvalue`: B-test **P** value.
- `interceptBT`: Intercept BT.
- `interceptBPvalue`: Intercept B-test P value.

## 401 Unauthorized

> If user don't have permission to use this endpoint.

## 500 Internal Server Error

> If there is a problem with the service.

# Description

Get linear regression analysis between two questions.

# Payload

```json theme={null}
{
  "fromDate": string,
  "toDate": string,
  "questionId1": string,
  "questionId2": string,
  "filter": array
}
```

where:

* `fromDate`: start date in ISO format. **(Required)**.
* `toDate`: end date in ISO format. **(Required)**.
* `questionId1`: Question identifier for the `x` axis. **(Required)**.
* `questionId2`: Question identifier for the `y` axis. **(Required)**.
* `filter`: array of filters to filter the responses. (Optional).

# Response

## 200 OK

```json theme={null}
{
    "x": "array",
    "y": "array",
    "slope": "number",
    "intercept": "number",
    "r": "number",
    "r2": "number",
    "adjustedR2": "number",
    "stdErrorR2": "number",
    "dfRegression": "integer",
    "dfResidual": ""integer",
    "dfTotal": "integer",
    "n": "integer",
    "regressionSS": "number",
    "residualErrorSS": "number",
    "totalSS": "integer",
    "regressionMS": "number",
    "residualErrorMS": "number",
    "f": "number",
    "fPValue": "number",
    "slopeB": "number",
    "slopeBError": "number",
    "interceptB": "number",
    "interceptBError": "number",
    "slopeBeta": "number",
    "slopeBT": "number",
    "slopeBPvalue": "number",
    "interceptBT": "number",
    "interceptBPvalue": "number"
}
```

* `x`: n-size array where the nth is the  option position for the nth answer of question 1.
* `y`: n-size array where the nth is the  option position for the nth answer of question 2.
* `slope`: Slope or gradient. Commonly denoted as **m** in y = **m** \* x + b.
* `intercept`: Commonly denoted as **b** in in y = m \* x + **b**.
* `r`: Correlation coefficient.
* `r2`: Correlation coefficient squared.
* `adjustedR2`: Adjusted correlation coefficient squared.
* `stdErrorR2`: a.k.a Standard error of the regression, standard error of the estimate.
* `dfRegression`: Degrees of freedom for regression, set as 1.
* `dfResidual`: Residual degrees of freedom.
* `dfTotal`: Degrees of freedom.
* `n`: Number of data points.
* `regressionSS`: Regression sum of squares.
* `residualErrorSS`: Residual sum of squares.
* `totalSS`: Total sum of squares.
* `regressionMS`: Regression mean square.
* `residualErrorMS`: Residual mean square.
* `f`: F-test.
* `fPValue`: F-test **P** value.
* `slopeB`: Slope B (based on standard deviation).
* `slopeBError`: Standard error of B.
* `interceptB`: Intercept B.
* `interceptBError`: Error of intercept.
* `slopeBeta`: Beta coefficient.
* `slopeBT`: Slope BT.
* `slopeBPvalue`: B-test **P** value.
* `interceptBT`: Intercept BT.
* `interceptBPvalue`: Intercept B-test P value.

## 401 Unauthorized

> If user don't have permission to use this endpoint.

## 500 Internal Server Error

> If there is a problem with the service.

##### Query Parameters

| Parameter   | Description | Required | Example |
| ----------- | ----------- | -------- | ------- |
| `projectId` | —           | No       | —       |


## OpenAPI

````yaml POST /linear-regression-analysis-service/linearRegression
openapi: 3.0.3
info:
  title: SightX API
  version: 1.0.0
  description: >-
    SightX REST API documentation. Most responses are JSON; some export
    endpoints return files. API access is a paid add-on — contact
    sales@sightx.io for details.
servers:
  - url: https://auth.admin.sightx.io
    description: Authentication (Production)
  - url: https://auth.staging-admin.sightx.io
    description: Authentication (Staging)
security:
  - AuthorizationHeader: []
paths:
  /linear-regression-analysis-service/linearRegression:
    post:
      summary: linearRegression
      description: >-
        # Description


        Get linear regression analysis between two questions.


        # Payload


        ```json

        {
          "fromDate": string,
          "toDate": string,
          "questionId1": string,
          "questionId2": string,
          "filter": array
        }

        ```


        where:


        * `fromDate`: start date in ISO format. __(Required)__.

        * `toDate`: end date in ISO format. __(Required)__.

        * `questionId1`: Question identifier for the `x` axis. __(Required)__.  

        * `questionId2`: Question identifier for the `y` axis. __(Required)__.  

        * `filter`: array of filters to filter the responses. (Optional).


        # Response


        ## 200 OK


        ```json

        {
            "x": "array",
            "y": "array",
            "slope": "number",
            "intercept": "number",
            "r": "number",
            "r2": "number",
            "adjustedR2": "number",
            "stdErrorR2": "number",
            "dfRegression": "integer",
            "dfResidual": ""integer",
            "dfTotal": "integer",
            "n": "integer",
            "regressionSS": "number",
            "residualErrorSS": "number",
            "totalSS": "integer",
            "regressionMS": "number",
            "residualErrorMS": "number",
            "f": "number",
            "fPValue": "number",
            "slopeB": "number",
            "slopeBError": "number",
            "interceptB": "number",
            "interceptBError": "number",
            "slopeBeta": "number",
            "slopeBT": "number",
            "slopeBPvalue": "number",
            "interceptBT": "number",
            "interceptBPvalue": "number"
        }

        ```


        - `x`: n-size array where the nth is the  option position for the nth
        answer of question 1.

        - `y`: n-size array where the nth is the  option position for the nth
        answer of question 2.

        - `slope`: Slope or gradient. Commonly denoted as **m** in y = **m** * x
        + b.

        - `intercept`: Commonly denoted as **b** in in y = m * x + **b**.

        - `r`: Correlation coefficient.

        - `r2`: Correlation coefficient squared.

        - `adjustedR2`: Adjusted correlation coefficient squared.

        - `stdErrorR2`: a.k.a Standard error of the regression, standard error
        of the estimate.

        - `dfRegression`: Degrees of freedom for regression, set as 1.

        - `dfResidual`: Residual degrees of freedom.

        - `dfTotal`: Degrees of freedom.

        - `n`: Number of data points.

        - `regressionSS`: Regression sum of squares.

        - `residualErrorSS`: Residual sum of squares.

        - `totalSS`: Total sum of squares.

        - `regressionMS`: Regression mean square.

        - `residualErrorMS`: Residual mean square.

        - `f`: F-test.

        - `fPValue`: F-test **P** value.

        - `slopeB`: Slope B (based on standard deviation).

        - `slopeBError`: Standard error of B.

        - `interceptB`: Intercept B.

        - `interceptBError`: Error of intercept.

        - `slopeBeta`: Beta coefficient.

        - `slopeBT`: Slope BT.

        - `slopeBPvalue`: B-test **P** value.

        - `interceptBT`: Intercept BT.

        - `interceptBPvalue`: Intercept B-test P value.


        ## 401 Unauthorized


        > If user don't have permission to use this endpoint.


        ## 500 Internal Server Error


        > If there is a problem with the service.
      operationId: >-
        linearregression-post-linear-regression-analysis-service-linearregression
      parameters:
        - name: Authorization
          in: header
          required: true
          description: Auth token
          schema:
            type: string
        - name: projectId
          in: query
          required: false
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: true
            example:
              fromDate: '2020-01-01'
              toDate: '2022-12-31'
              filter: []
              questionId1: questionId1
              questionId2: questionId2
      responses:
        '200':
          description: Successful response
        '400':
          description: Bad request
        '401':
          description: Unauthorized
        '500':
          description: Internal server error
      servers:
        - url: https://linear-regression-analysis.sightx.io
components:
  securitySchemes:
    AuthorizationHeader:
      type: apiKey
      in: header
      name: Authorization
      description: Access token obtained from the m2m-token endpoint.

````