-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathSGF2019_Example2.sas
128 lines (103 loc) · 3.4 KB
/
SGF2019_Example2.sas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/****************************************************************/
/* S A S G L O B A L F O R U M 2 0 1 9 */
/* */
/* TITLE: Estimating Source Signals with Dimension Reduction */
/* PRODUCT: SAS Viya, Visual Statistics */
/* */
/****************************************************************/
data mycas.Signals2;
keep t x:;
array S[200,3]; /* S: source signals */
array A[3,3]; /* A: mixing matrix */
array x[4] x1-x4; /* X: observed signals */
N = 200;
do i = 1 to 3;
do j = 1 to 3;
A[i,j] = 0.7*uniform(12345);
end;
end;
do i = 1 to N;
S[i,1] = cos(i/3);
S[i,2] = 0.4*((mod(i,23)-11)/7)**5;
S[i,3] = ((mod(i,29)-7)/11)-0.7;
end;
do i = 1 to N;
t = i;
do j = 1 to 3;
x[j] = 0;
do k = 1 to 3;
x[j] = x[j] + S[i,k]*A[k,j];
end;
end;
x[4] = 0.1*uniform(67890);
output;
end;
run;
/* Extract independent components with dimension reduction */
proc ica data=mycas.Signals2 eigthresh=0.004 noscale seed=345;
var x1-x4;
output out=mycas.Scores2 component=c copyvar=t;
run;
proc template;
define statgraph Panel4;
beginGraph;
layout lattice / rows=3
columns=1
rowgutter=10
columndatarange=unionall
order=packed;
columnaxes;
columnaxis / label="t";
endcolumnaxes;
layout overlay / yaxisopts=
(linearopts=(viewmin=-3 viewmax=3 tickvaluelist=(-3 0 3)));
seriesplot x=t y=c1;
endlayout;
layout overlay / yaxisopts=
(linearopts=(viewmin=-2 viewmax=2 tickvaluelist=(-2 0 2)));
seriesplot x=t y=c2;
endlayout;
layout overlay / yaxisopts=
(linearopts=(viewmin=-2 viewmax=2 tickvaluelist=(-2 0 2)));
seriesplot x=t y=c3;
endlayout;
endlayout;
endGraph;
end;
run;
proc sgrender data=mycas.Scores2 template=Panel4;
run;
/* Extract independent components with full dimensions */
proc ica data=mycas.Signals2 noscale seed=345;
var x1-x4;
output out=mycas.Scores2a component=c copyvar=t;
run;
proc template;
define statgraph Panel5;
beginGraph;
layout lattice / rows=4
columns=1
rowgutter=10
columndatarange=unionall
order=packed;
columnaxes;
columnaxis / label="t";
endcolumnaxes;
layout overlay / yaxisopts=(linearopts=(viewmin=-4 viewmax=0 tickvaluelist=(-4 -2 0)));
seriesplot x=t y=c1;
endlayout;
layout overlay / yaxisopts=(linearopts=(viewmin=-2 viewmax=2 tickvaluelist=(-2 0 2)));
seriesplot x=t y=c2;
endlayout;
layout overlay / yaxisopts=(linearopts=(viewmin=-2 viewmax=2 tickvaluelist=(-2 0 2)));
seriesplot x=t y=c3;
endlayout;
layout overlay / yaxisopts=(linearopts=(viewmin=-3 viewmax=3 tickvaluelist=(-3 0 3)));
seriesplot x=t y=c4;
endlayout;
endlayout;
endGraph;
end;
run;
proc sgrender data=mycas.Scores2a template=Panel5;
run;