简体   繁体   English

SAS 能否对 ARIMA 模型的数据集进行评分?

[英]Can SAS Score a Data Set to an ARIMA Model?

Is it possible to score a data set with a model created by PROC ARIMA in SAS?是否可以使用 SAS 中 PROC ARIMA 创建的模型对数据集进行评分?

This is the code I have that is not working:这是我的代码不起作用:

proc arima data=work.data;
identify var=x crosscorr=(y(7) y(30));
estimate outest=work.arima;
run;

proc score data=work.data score=work.arima type=parms predict out=pred;
var x;
run;

When I run this code I get an error from the PROC SCORE portion that says "ERROR: Variable x not found."当我运行此代码时,我从 PROC SCORE 部分收到一条错误消息,显示“错误:未找到变量 x”。 The x column is in the data set work.data. x 列位于数据集 work.data 中。

proc score does not support autocorrelated variables. proc score不支持自相关变量。 The simplest way to get an out-of-sample score is to combine both proc arima and a data step.获得样本外分数的最简单方法是结合proc arimadata步骤。 Here's an example using sashelp.air .这是使用sashelp.air的示例。

Step 1: Generate historical data第 1 步:生成历史数据

We leave out the year 1960 as our score dataset.我们省略了 1960 年作为我们的分数数据集。

data have;
    set sashelp.air;
    where year(date) < 1960;
run;

Step 2: Generate a model and forecast第 2 步:生成模型和预测

The nooutall option tells proc arima to only produce the 12 future forecasts. nooutall选项告诉proc arima只生成 12 个未来预测。

proc arima data=have;
    identify var=air(12);
    estimate p=1 q=(2) method=ml;
    forecast lead=12 id=date interval=month out=forecast nooutall;
run;

Step 3: Score第 3 步:评分

Merge together your forecast and full historical dataset to see how well the model did.将您的预测和完整的历史数据集合并在一起,看看模型的表现如何。 I personally like the update statement because it will not replace anything with missing values.我个人喜欢update语句,因为它不会用缺失值替换任何内容。

data want;
    update forecast(in=fcst) 
           sashelp.air(in=historical);
    by Date;

    /* Generate fit statistics */
    Error    = Forecast-Air;
    PctError = Error/Air;
    AbsPctError = abs(PctError);

    /* Helpful for bookkeeping */
    if(fcst) then Type = 'Score';
        else if(historical) then Type = 'Est';

    format PctError AbsPctError percent8.2;
run; 

You can take this code and convert it into a generalized macro for yourself.您可以使用此代码并将其转换为自己的通用宏。 That way in the future, if you wanted to score something, you could simply call a macro program to get what you need.这样在未来,如果你想得分,你可以简单地调用一个宏程序来获得你需要的东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM