WorksheetFunction.Forecast_Linear 方法 (Excel)WorksheetFunction.Forecast_Linear method (Excel)

根据已有的数值计算或预测未来值。Calculates, or predicts, a future value by using existing values. 此预测值为基于给定的 x 值推导出的 y 值。The predicted value is a y-value for a given x-value. 已知的数值为已有的 x 值和 y 值,再利用线性回归对新值进行预测。The known values are existing x-values and y-values, and the new value is predicted by using linear regression. 可以使用该函数来预测未来销售、库存需求或消费趋势等。You can use this function to predict future sales, inventory requirements, or consumer trends.


表达式Forecast_Linear(Arg1Arg2Arg3)expression.Forecast_Linear (Arg1, Arg2, Arg3)

_表达式_一个代表**WorksheetFunction** 对象的变量。expression A variable that represents a WorksheetFunction object.


名称Name 必需/可选Required/Optional 数据类型Data type 说明Description
Arg1Arg1 必需Required DoubleDouble x-要预测其值的数据点。x - the data point for which you want to predict a value.
Arg2Arg2 必需Required VariantVariant known_y's-相关的数据数组或数据区域。known_y's - the dependent array or range of data.
Arg3Arg3 必需Required VariantVariant known_x's-独立的数据数组或数据区域。known_x's - the independent array or range of data.

返回值Return value



如果 x 为非数值型, 则Forecast_Linear将返回 #VALUE!If x is nonnumeric, Forecast_Linear returns the #VALUE! error value.

如果_known_y_和_known_x_参数为空或包含不同数量的数据点, 则Forecast_Linear将返回 #N/a 错误值。If known_y and known_x parameters are empty or contain a different number of data points, Forecast_Linear returns the #N/A error value.

如果_known_x_参数的方差等于零, 则Forecast_Linear将返回 #DIV/0!If the variance of known_x parameters equals zero, Forecast_Linear returns the #DIV/0! error value.

Forecast_Linear的计算公式为 +   bx, 其中公式  和   公式以及 x 和 y 的样本平均值平均值 (all known_x) 和 average (all known_y).The equation for Forecast_Linear is a+bx, where   Formula   and   Formula   and where x and y are the sample means AVERAGE(all known_x) and AVERAGE(all known_y).


Dim instance As WorksheetFunction
Dim Arg1 As Double
Dim Arg2 As Object
Dim Arg3 As Object
Dim returnValue As Double

returnValue = instance.Forecast_Linear(Arg1, Arg2, Arg3)

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.