首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何运行预测模型

如何运行预测模型
EN

Stack Overflow用户
提问于 2016-11-23 19:59:24
回答 1查看 553关注 0票数 0

在SAS中是否存在与R的函数predict(model, data)等价的函数?

例如,如何将下面的模型应用于响应变量“年龄”未知的大型测试数据集?

代码语言:javascript
复制
proc reg data=sashelp.class;
    model Age = Height Weight ;
run;

我知道您可以从结果窗口中提取年龄= Intercept +高度(Estimate_height)+权重(Estimate_weight)的公式,并手动预测未知观测的“年龄”,但这不是很有效。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-11-25 03:10:42

这是SAS自己做的。只要模型有足够的数据点继续进行,它就会输出预测值。我使用了proc,但是您可以使用任何模型过程来创建这种输出。

代码语言:javascript
复制
/* this is a sample dataset */
data mydata;
input age weight dataset $;
cards;
1 10 mydata
2 11 mydata
3 12 mydata
4 15 mydata
5 12 mydata
;
run;

/* this is a test dataset. It needs to have all of the variables that you'll use in the model */
data test;
input weight dataset $;
cards;
6 test
7 test
10 test
;
run;
/* append (add to the bottom) the test to the original dataset */
proc append data=test base=mydata force; run;

/* you can look at mydata to see if that worked, the dependent var (age) should be '.' */
/* do the model */
proc glm data=mydata;
model age = weight/p clparm; /* these options after the '/' are to show predicte values in results screen - you don't need it */
output out=preddata predicted=pred lcl=lower ucl=upper; /* this line creates a dataset with the predicted value for all observations */
run;
quit;

/* look at the dataset (preddata) for the predicted values */
proc print data=preddata;
where dataset='test';
run;
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40773166

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档