CREATE FUNCTIONS SPSS

9
SDIFF Function (CREATE command) You can specify only one degree of differencing per SDIFF function. If no periodicity is specified, the periodicity established on TSET PERIOD is in effect. If TSET PERIOD has not been specified, the periodicity established on the DATE command is used. If periodicity was not established anywhere, the SDIFF function cannot be executed. If either of the pair of values involved in a seasonal difference computation is missing, the result is set to system-missing in the new series. Example CREATE SDVAR = SDIFF(VARA,1,12). The series SDVAR is created by applying one seasonal difference with a periodicity of 12 to the series VARA. Examples (CREATE command) CREATE NEWVAR1 = DIFF(OLDVAR,1). In this example, the series NEWVAR1 is created by taking the first-order difference of OLDVAR. CSUM Function (CREATE command) CSUM produces new series based on the cumulative sums of the existing series. Cumulative sums are the inverse of first-order differencing. The only specification on CSUM is the name or names of the existing series in parentheses. Cases with missing values in the existing series are not used to compute values for the new series. The values of these cases are system-missing in the new series. Example CREATE NEWVAR1 NEWVAR2 = CSUM(TICKETS RNDTRP). This example produces a new series called NEWVAR1, which is the cumulative sum of the series TICKETS, and a new series called NEWVAR2, which is the cumulative sum of the series RNDTRP.

description

CREATE FUNCTIONS SPSS

Transcript of CREATE FUNCTIONS SPSS

Page 1: CREATE FUNCTIONS SPSS

SDIFF Function (CREATE command)

You can specify only one degree of differencing per SDIFF function.

• If no periodicity is specified, the periodicity established on TSET PERIOD is in effect. If TSET PERIOD has not been specified, the periodicity established on the DATE command is used. If periodicity was not established anywhere, the SDIFF function cannot be executed.

• If either of the pair of values involved in a seasonal difference computation is missing, the result is set to system-missing in the new series.

Example

CREATE SDVAR = SDIFF(VARA,1,12).

• The series SDVAR is created by applying one seasonal difference with a periodicity of 12 to the series VARA.

Examples (CREATE command)

CREATE NEWVAR1 = DIFF(OLDVAR,1).

• In this example, the series NEWVAR1 is created by taking the first-order difference of OLDVAR.

CSUM Function (CREATE command)

CSUM produces new series based on the cumulative sums of the existing series. Cumulative sums are the inverse of first-order differencing.

• The only specification on CSUM is the name or names of the existing series in parentheses.

• Cases with missing values in the existing series are not used to compute values for the new series. The values of these cases are system-missing in the new series.

Example

CREATE NEWVAR1 NEWVAR2 = CSUM(TICKETS RNDTRP).

• This example produces a new series called NEWVAR1, which is the cumulative sum of the series TICKETS, and a new series called NEWVAR2, which is the cumulative sum of the series RNDTRP.

DIFF Function (CREATE command)

DIFF produces new series based on nonseasonal differences of existing series.

• The specification on DIFF is the name or names of the existing series and the degree of differencing, in parentheses.

• The degree of differencing must be specified; there is no default.

• Since one observation is lost for each order of differencing, system-missing values will appear at the beginning of the new series.

• You can specify only one degree of differencing per DIFF function.

Page 2: CREATE FUNCTIONS SPSS

• If either of the pair of values involved in a difference computation is missing, the result is set to system-missing in the new series.

Example

CREATE ADIF2 = DIFF(VARA,2) /

YDIF1 ZDIF1 = DIFF(VARY VARZ,1).

• The series ADIF2 is created by differencing VARA twice.

• The series YDIF1 is created by differencing VARY once.

• The series ZDIF1 is created by differencing VARZ once.

FFT Function (CREATE command)

FFT produces new series based on fast Fourier transformations of existing series (Brigham, 1974).

• The only specification on FFT is the name or names of the existing series in parentheses.

• FFT creates two series, the cosine and sine parts (also called real and imaginary parts), for each existing series named. Thus, you must specify two new series names on the left side of the equation for each existing series specified on the right side.

• The first new series named becomes the real series, and the second new series named becomes the imaginary series.

• The existing series cannot have embedded missing values.

• The existing series must be of even length. If an odd-length series is specified, FFT pads it with a 0 to make it even. Alternatively, you can make the series even by adding or dropping an observation.

• The new series will be only half as long as the existing series. The remaining cases are assigned the system-missing value.

Example

CREATE A B = FFT(C).

• Two series, A (real) and B (imaginary), are created by applying a fast Fourier transformation to series C.

IFFT Function (CREATE command)

IFFT produces new series based on the inverse Fourier transformation of existing series.

• The only specification on IFFT is the name or names of the existing series in parentheses.

• IFFT needs two existing series to compute each new series. Thus, you must specify two existing series names on the right side of the equation for each new series specified on the left.

• The first existing series specified is the real series and the second series is the imaginary series.

• The existing series cannot have embedded missing values.

Page 3: CREATE FUNCTIONS SPSS

• The new series will be twice as long as the existing series. Thus, the last half of each existing series must be system-missing to allow enough room to create the new series.

Example

CREATE C = IFFT(A B).

• This command creates one new series, C, from the series A (real) and B (imaginary).

LAG Function (CREATE command)

LAG creates new series by copying the values of the existing series and moving them forward the specified number of observations. This number is called the lag order. The table below shows a first-order lag for a hypothetical dataset.

• The specification on LAG is the name or names of the existing series and one or two lag orders, in parentheses.

• At least one lag order must be specified; there is no default.

• Two lag orders indicate a range. For example, 2,6 indicates lag orders two through six. A new series is created for each lag order in the range.

• The number of new series specified must equal the number of existing series specified times the number of lag orders in the range.

• The first n cases at the beginning of the new series, where n is the lag order, are assigned the system-missing value.

• Missing values in the existing series are lagged and are assigned the system-missing value in the new series.

• A first-order lagged series can also be created using COMPUTE. COMPUTE does not cause a data pass (see COMPUTE).

First-order lag and lead of series X

X Lag Lead

198 . 220

220 198 305

305 220 470

470 305 .

Example

CREATE LAGVAR2 TO LAGVAR5 = LAG(VARA,2,5).

• Four new variables are created based on lags on VARA. LAGVAR2 is VARA lagged two steps, LAGVAR3 is VARA lagged three steps, LAGVAR4 is VARA lagged four steps, and LAGVAR5 is VARA lagged five steps.

Page 4: CREATE FUNCTIONS SPSS

LEAD Function (CREATE command)

LEAD creates new series by copying the values of the existing series and moving them back the specified number of observations. This number is called the lead order.

• The specification on LEAD is the name or names of the existing series and one or two lead orders, in parentheses.

• At least one lead order must be specified; there is no default.

• Two lead orders indicate a range. For example, 1,5 indicates lead orders one through five. A new series is created for each lead order in the range.

• The number of new series must equal the number of existing series specified times the number of lead orders in the range.

• The last n cases at the end of the new series, where n equals the lead order, are assigned the system-missing value.

• Missing values in the existing series are moved back and are assigned the system-missing value in the new series.

Example

CREATE LEAD1 TO LEAD4 = LEAD(VARA,1,4).

• Four new series are created based on leads of VARA. LEAD1 is VARA led one step, LEAD2 is VARA led two steps, LEAD3 is VARA led three steps, and LEAD4 is VARA led four steps.

MA Function (CREATE command)

MA produces new series based on the centered moving averages of existing series.

• The specification on MA is the name or names of the existing series and the span to be used in averaging, in parentheses.

• A span must be specified; there is no default.

• If the specified span is odd, the MA is naturally associated with the middle term. If the specified span is even, the MA is centered by averaging each pair of uncentered means (Velleman and Hoaglin, 1981).

• After the initial span, a second span can be specified to indicate the minimum number of values to use in averaging when the number specified for the initial span is unavailable. This makes it possible to produce nonmissing values at or near the ends of the new series.

• The second span must be greater than or equal to 1 and less than or equal to the first span.

• The second span should be even (or 1) if the first span is even; it should be odd if the first span is odd. Otherwise, the next higher span value will be used.

• If no second span is specified, the minimum span is simply the value of the first span.

• If the number of values specified for the span or the minimum span is not available, the case in the new series is set to system-missing. Thus, unless a minimum span of 1 is specified, the endpoints of the new series will contain system-missing values.

Page 5: CREATE FUNCTIONS SPSS

• When MA encounters an embedded missing value in the existing series, it creates two subsets, one containing cases before the missing value and one containing cases after the missing value. Each subset is treated as a separate series for computational purposes.

• The endpoints of these subset series will have missing values according to the rules described above for the endpoints of the entire series. Thus, if the minimum span is 1, the endpoints of the subsets will be nonmissing; the only cases that will be missing in the new series are cases that were missing in the original series.

Example

CREATE TICKMA = MA(TICKETS,4,2).

• This example creates the series TICKMA based on centered moving average values of the series TICKETS.

• A span of 4 is used for computing averages. At the endpoints, where four values are not available, the average is based on the specified minimum of two values.

PMA Function (CREATE command)

PMA creates new series based on the prior moving averages of existing series. The prior moving average for each case in the original series is computed by averaging the values of a span of cases preceding it.

• The specification on PMA is the name or names of the existing series and the span to be used, in parentheses.

• Only one span can be specified and it is required. There is no default span.

• If the number of values specified for the span is not available, the case is set to system-missing. Thus, the number of cases with system-missing values at the beginning of the new series equals the number specified for the span.

• When PMA encounters an imbedded missing value in the existing series, it creates two subsets, one containing cases before the missing value and one containing cases after the missing value. Each subset is treated as a separate series for computational purposes. The first n cases in the second subset will be system-missing, where n is the span.

Example

CREATE PRIORA = PMA(VARA,3).

• This command creates the series PRIORA by computing prior moving averages for the series VARA. Since the span is 3, the first three cases in the series PRIORA are system-missing. The fourth case equals the average of cases 1, 2, and 3 of VARA, the fifth case equals the average of cases 2, 3, and 4 of VARA, and so on.

Page 6: CREATE FUNCTIONS SPSS

RMED Function (CREATE command)

RMED produces new series based on the centered running medians of existing series.

• The specification on RMED is the name or names of the existing series and the span to be used in finding the median, in parentheses.

• A span must be specified; there is no default.

• If the specified span is odd, RMED is naturally the middle term. If the specified span is even, the RMED is centered by averaging each pair of uncentered medians (Velleman and Hoaglin, 1981).

• After the initial span, a second span can be specified to indicate the minimum number of values to use in finding the median when the number specified for the initial span is unavailable. This makes it possible to produce nonmissing values at or near the ends of the new series.

• The second span must be greater than or equal to 1 and less than or equal to the first span.

• The second span should be even (or 1) if the first span is even; it should be odd if the first span is odd. Otherwise, the next higher span value will be used.

• If no second span is specified, the minimum span is simply the value of the first span.

• If the number of values specified for the span or the minimum span is not available, the case in the new series is set to system-missing. Thus, unless a minimum span of 1 is specified, the endpoints of the new series will contain system-missing values.

• When RMED encounters an imbedded missing value in the existing series, it creates two subsets, one containing cases before the missing value and one containing cases after the missing value. Each subset is treated as a separate series for computational purposes.

• The endpoints of these subset series will have missing values according to the rules described above for the endpoints of the entire series. Thus, if the minimum span is 1, the endpoints of the subsets will be nonmissing; the only cases that will be missing in the new series are cases that were missing in the original series.

Example

CREATE TICKRMED = RMED(TICKETS,4,2).

• This example creates the series TICKRMED using centered running median values of the series TICKETS.

• A span of 4 is used for computing medians. At the endpoints, where four values are not available, the median is based on the specified minimum of two values.

T4253H Function (CREATE command)

T4253H produces new series by applying a compound data smoother to the original series. The smoother starts with a running median of 4, which is centered by a running median of 2. It then resmooths these values by applying a running median of 5, a running median of 3, and hanning (running weighted averages). Residuals are computed by subtracting the smoothed series from the original series. This whole process is then repeated on the computed residuals. Finally, the smoothed residuals are added to the smoothed values obtained the first time through the process (Velleman and Hoaglin, 1981).

• The only specification on T4253H is the name or names of the existing series in parentheses.

Page 7: CREATE FUNCTIONS SPSS

• The existing series cannot contain imbedded missing values.

• Endpoints are smoothed through extrapolation and are not system-missing.

Example

CREATE SMOOTHA = T4253H(VARA).

• The series SMOOTHA is a smoothed version of the series VARA.