home *** CD-ROM | disk | FTP | other *** search
- cycmov(a,n,l,kda,b,c,temp,ph)
-
- /*if monthly data is supplied, seasonal index and cyclical move- */
- /*ment are computed, otherwise only cyclical movement is computed.*/
-
- int kda,l,n;
- float a[],b[],c[],temp[],ph[];
-
- {
- int i,il,j,kk,nd,nst;
- float d[12],count[12],sum;
-
- nd = n;
- moveav(a,nd,l,b);
- if((kda-1) == 0)
- {
- for(i = 0; i <= n-1; i++)
- {
- if(b[i] == 0.) c[i] = 0.;
- else c[i] = a[i]/b[i]*100.;
- }
- for(i = 0; i <= n-1; i++)
- {
- temp[i] = 0.;
- ph[i] = c[i] - 100.;
- if (c[i] == 0.) ph[i] = 0.;
- }
- return;
- }
-
- for(i = 0; i <= n-1; i++)
- {
- if(b[i] == 0.) c[i] = 0.;
- else c[i] = a[i]/b[i] * 100.;
- }
- nst = 7;
- nd = n -nst + 1;
-
- for(i = 1; i <= 12; i++)
- {
- count[i-1] = 0.;
- d[i-1] = 0.;
-
- for(j = nst; j <= nd; j++)
- {
- kk = (j/12) * 12;
- if((j-kk-i) == 0)
- {
- d[i-1] = d[i-1] + c[j-1];
- count[i-1] = count[i-1] + 1.;
- }
- else
- {
- if ((j-kk) == 0)
- {
- if((i - 12) == 0)
- {
- d[i-1] = d[i-1] + c[j-1];
- count[i-1] = count[i-1] + 1.;
- }
- }
- }
- }
- }
- sum = 0.;
-
- for(i = 0; i <= 11; i++)
- {
- d[i] = d[i]/count[i];
- sum = sum + d[i];
- }
-
- for(i = 0; i <= 11; i++)
- d[i] = d[i]/sum * 12. * 100.;
-
- for(j = 1; j <= n; j++)
- {
- il = (j/12) * 12;
- i = j - il;
- if(i == 0) i = 12;
- if(i >= 0)
- {
- ph[j-1] = c[j-1] - d[i-1];
- if (c[j-1] == 0.) ph[j-1] = 0.;
- temp[j-1] = d[i-1];
- }
- }
- }