我希望你们所有人都做得很好。我对州空间模型有疑问。您可能知道,通过使用这些模型,我们可以使用一个可观察变量来计算不规则组件和级别组件的误差方差。例如,假设我们有一个变量;这是asser的价格。状态空间模型帮助我们找到此变量的级别和不规则组件。我使用以下代码来计算:
proc ucm data = work;
model price (price is my observable variable);
irregular plot = smooth;
level checkbreak plot = smooth;
estimate plot = residual;
forecast plot = forecasts lead = 10 alpha = 0.5;
run;
我的问题是,我需要找到每个组的不规则和级别组件的错误差异。上面提到的代码帮助我通过使用所有组的数据来找到这些差异。为简单起见,我通过使用简单数据来解释它。我有以下数据表:
group price
A 0.5
A 0.4
A 0.8
A 0.1
B 0.3
B 0.2
B 0.5
我想获得以下数据表:
group price Error variances of irregular components (irr.c) Error variances of level components
A 0.5 0.1 (assume that er.variance of irr.c for A is 0.1) 0.3 (assume that er.variance of lev.c for A is 0.3)
A 0.4 0.1 (assume that er.variance of irr.c for A is 0.1) 0.3 (assume that er.variance of lev.c for A is 0.3)
A 0.8 0.1 (assume that er.variance of irr.c for A is 0.1) 0.3 (assume that er.variance of lev.c for A is 0.3)
A 0.1 0.1 (assume that er.variance of irr.c for A is 0.1) 0.3 (assume that er.variance of lev.c for A is 0.3)
B 0.3 0.2 (assume that er.variance of irr.c for B is 0.2) 0.1 (assume that er.variance of lev.c for B is 0.1)
B 0.2 0.2 (assume that er.variance of irr.c for B is 0.2) 0.1 (assume that er.variance of lev.c for B is 0.1)
B 0.5 0.2 (assume that er.variance of irr.c for B is 0.2) 0.1 (assume that er.variance of lev.c for B is 0.1)
我希望我能解释一下我的问题。对不起任何误解。
答案 0 :(得分:0)
data work;
input group $ price;
datalines;
A 0.5
A 0.4
A 0.8
A 0.1
B 0.3
B 0.2
B 0.5
;
run;
proc print data=work;
run;
ods trace on;
ods select ParameterEstimates;
ods output ParameterEstimates=myEstimates;
proc ucm data=work;
model price;
by group;
irregular plot=smooth;
level checkbreak plot=smooth;
estimate plot=residual;
forecast plot=forecasts lead=10 alpha=0.5;
run;
proc print data=myEstimates;
run;
proc transpose data=myEstimates(keep=group component estimate)
out=transposedEstimates;
by group;
id component;
run;
proc print data=transposedEstimates;
run;
proc sql;
create table myResults as
select a.*,
b.irregular as IrregularComponent,
b.level as LevelComponent
from work as a,
transposedEstimates as b
where a.group=b.group;
quit;
proc print data=myResults;
run;