LINEST
使用最小平方方法來計算最符合指定數據的直線,然後傳回描述該線條的數據表。 線條的方程式格式為:y = Slope1*x1 + Slope2*x2 + ... + Intercept。
語法
LINEST ( <columnY>, <columnX>[, …][, <const>] )
參數
術語 | 定義 |
---|---|
columnY |
已知 y 值的數據行。 必須具有純量類型。 |
columnX |
已知 x 值的數據行。 必須具有純量類型。 至少必須提供一個。 |
const |
(選擇性)常數 TRUE /FALSE 值,指定是否強制常數 Intercept 等於 0。如果 TRUE 或省略,攔截 值會正常計算;如果 FALSE ,Intercept 值會設定為零。 |
傳回值
描述這一行的單一數據列數據表,加上其他統計數據。 以下是可用的資料列:
- Slope1、Slope2...、SlopeN:對應至每個 x 值的係數:
- 攔截:攔截值;
- StandardErrorSlope1、StandardErrorSlope2、...、StandardErrorSlopeN:Slope1、Slope2、...、SlopeN的標準誤差值;
- StandardErrorIntercept:常數 攔截的標準錯誤值;
- 係數OfDetermination:決定係數(rー)。 比較估計值和實際 y 值,以及從 0 到 1 的值範圍:值越高,樣本中的相互關聯就越高:
- StandardError:y 估計的標準錯誤;
- FStatistic:F 統計數據或 F 觀察值。 使用 F 統計數據來判斷相依變數與獨立變數之間的觀察關聯性是否偶然發生;
- DegreesOfFreedom:自由度。 使用此值可協助您在統計數據表中尋找 F 關鍵值,並判斷模型的信賴等級;
- RegressionSumOfSquares:平方的回歸總和;
- ResidualSumOfSquares:平方的剩餘總和。
言論
columnY
和 columnX
必須全部屬於相同的數據表。
範例 1
下列 DAX 查詢:
EVALUATE LINEST(
'FactInternetSales'[SalesAmount],
'FactInternetSales'[TotalProductCost]
)
傳回具有十個數據行的單一數據列資料表:
Slope1 | 攔截 | StandardErrorSlope1 | StandardErrorIntercept | CoefficientOfDetermination |
---|---|---|---|---|
1.67703250456677 | 6.34550460373026 | 0.000448675725548806 | 0.279131821917317 | 0.995695557281456 |
StandardError | FStatistic | DegreesOfFreedom | RegressionSumOfSquares | ResidualSumOfSquares |
---|---|---|---|---|
60.9171030357485 | 13970688.6139993 | 60396 | 51843736761.658 | 224123120.339218 |
- Slope1 和 攔截:計算線性模型的係數:
- StandardErrorSlope1 和 StandardErrorIntercept:上述係數的標準誤差值;
- CoefficientOfDetermination、StandardError、FStatistic、DegreesOfFreedom、RegressionSumOfSquares 和 ResidualSumOfSquares:模型的回歸統計數據。
針對指定的因特網銷售,此模型會透過下列公式預測銷售金額:
SalesAmount = Slope1 * TotalProductCost + Intercept
範例 2
下列 DAX 查詢:
EVALUATE LINEST(
'DimCustomer'[TotalSalesAmount],
'DimCustomer'[YearlyIncome],
'DimCustomer'[TotalChildren],
'DimCustomer'[BirthDate]
)
傳回具有十四個數據行的單一數據列數據表:
- Slope1
- Slope2
- Slope3
- 攔截
- StandardErrorSlope1
- StandardErrorSlope2
- StandardErrorSlope3
- StandardErrorIntercept
- CoefficientOfDetermination
- StandardError
- FStatistic
- DegreesOfFreedom
- RegressionSumOfSquares
- ResidualSumOfSquares
對於指定的客戶,此模型會根據下列公式預測總銷售額(出生日期會自動轉換成數位):
TotalSalesAmount = Slope1 * YearlyIncome + Slope2 * TotalChildren + Slope3 * BirthDate + Intercept