Learn R Programming

dlsem (version 1.0)

applyDiff: Differentiation

Description

Apply k-th order differentiation to one or more numerical variables. A single group factor may be taken into account.

Usage

applyDiff(x = NULL, group = NULL, time = NULL, data, k = 0)

Arguments

x
A vector containing the name of the numerical variables to be differenced. If NULL, all numerical variables will be differenced.
group
The name of a group factor (optional). If NULL, no groups are considered.
time
The name of a time factor (optional). If NULL and group is not NULL, data are assumed temporally ordered within each group. If both group and time are NULL, data are assumed
data
An object of class data.frame containing the variables to be differenced, the group factor if group is not NULL, and the time factor if time is not NULL.
k
The order of differentiation to be applied to all variables, or a vector of orders of differentiation, one for each variable to be differenced. Default is 0 (no differentiation).

Value

  • The object of class data.frame provided to argument data, where the requested variables have been differenced.

Examples

Run this code
data(agres)
applyDiff(c("NPATENT","GVA"),group="COUNTRY",data=agres,k=1)

Run the code above in your browser using DataLab