LinCombMatrix: Creation of linear combination matrices

Description Usage Arguments Value Note Examples

View source: R/PanelEstimation.R

Description

Create matrices for changes (LagDiff), means (Period) and mean changes (PeriodDiff).

Usage

 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
LinCombMatrix(
  n,
  period = NULL,
  lag = NULL,
  k = 0,
  takeMean = TRUE,
  removerows = TRUE,
  overlap = FALSE
)

LagDiff(n, lag = 1, removerows = TRUE)

Period(
  n,
  period = 1,
  k = 0,
  takeMean = TRUE,
  removerows = TRUE,
  overlap = FALSE
)

PeriodDiff(
  n,
  period = 1,
  lag = period,
  k = 0,
  takeMean = TRUE,
  removerows = TRUE,
  overlap = FALSE
)

Arguments

n

Number of variables

period

Number of variables involved in each period

lag

Lag used for difference calculation

k

Shift the start of each period

takeMean

Calculate mean over each period (sum when FALSE)

removerows

Revove incomplete rows

overlap

Overlap between periods (moving averages)

Value

Linear combination matrix

Note

It can be useful to add row names to the resulting matrix before further use.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
# We assume two years of four quarters (n=8)

# Quarter to quarter differences
LagDiff(8)

# Changes from same quarter last year
LagDiff(8,4)

# Yearly averages
Period(8,4)

# Moving yearly averages
Period(8,4,overlap=TRUE)

# Difference between yearly averages
PeriodDiff(8,4) # Also try n=16 with overlap=TRUE/FALSE

# Combine two variants and add row names
lc = rbind(LagDiff(8,4),PeriodDiff(8,4))
rownames(lc) = c("diffQ1","diffQ2","diffQ3","diffQ4","diffYearMean")
lc

CalibrateSSB documentation built on Aug. 5, 2020, 1:07 a.m.