panel series

A class for panel series for which several useful computations and data transformations are available.

# S3 method for pseries
print(x, ...)

# S3 method for pseries as.matrix(x, idbyrow = TRUE, ...)

# S3 method for pseries plot( x, plot = c("lattice", "superposed"), scale = FALSE, transparency = TRUE, col = "blue", lwd = 1, ... )

# S3 method for pseries summary(object, ...)

# S3 method for summary.pseries plot(x, ...)

# S3 method for summary.pseries print(x, ...)

Between(x, ...)

# S3 method for default Between(x, effect, ...)

# S3 method for pseries Between(x, effect = c("individual", "time", "group"), ...)

# S3 method for matrix Between(x, effect, ...)

between(x, ...)

# S3 method for default between(x, effect, ...)

# S3 method for pseries between(x, effect = c("individual", "time", "group"), ...)

# S3 method for matrix between(x, effect, ...)

Within(x, ...)

# S3 method for default Within(x, effect, ...)

# S3 method for pseries Within(x, effect = c("individual", "time", "group", "twoways"), ...)

# S3 method for matrix Within(x, effect, rm.null = TRUE, ...)

x, object

a pseries or a summary.pseries object,

further arguments, e. g. na.rm = TRUE for transformation functions like beetween, see Details and Examples.


if TRUE in the as.matrix method, the lines of the matrix are the individuals,

plot, scale, transparency, col, lwd

plot arguments,


character string indicating the "individual" or "time" effect,


if TRUE, for the Within.matrix method, remove the empty columns,


The functions between, Between, and Within perform specific data transformations, i. e. the between and within transformation.

between returns a vector containing the individual means (over time) with the length of the vector equal to the number of individuals (if effect = "individual" (default); if effect = "time", it returns the time means (over individuals)). Between duplicates the values and returns a vector which length is the number of total observations. Within returns a vector containing the values in deviation from the individual means (if effect = "individual", from time means if effect = "time"), the so called demeaned data.

For between, Between, and Within in presence of NA values it can be useful to supply na.rm = TRUE as an additional argument to keep as many observations as possible in the resulting transformation, see also Examples.


All these functions return an object of class pseries, except: between, which returns a numeric vector, as.matrix, which returns a matrix.

See Also

is.pseries() to check if an object is a pseries. For more functions on class 'pseries' see lag(), lead(), diff() for lagging values, leading values (negative lags) and differencing.

  • pseries
  • print.pseries
  • as.matrix.pseries
  • plot.pseries
  • summary.pseries
  • plot.summary.pseries
  • print.summary.pseries
  • Between
  • Between.default
  • Between.pseries
  • Between.matrix
  • between
  • between.default
  • between.pseries
  • between.matrix
  • Within
  • Within.default
  • Within.pseries
  • Within.matrix
# First, create a pdata.frame
data("EmplUK", package = "plm")
Em <- pdata.frame(EmplUK)

# Then extract a series, which becomes additionally a pseries
z <- Em$output

# obtain the matrix representation

# compute the between and within transformations

# Between replicates the values for each time observation

# between, Between, and Within transformations on other dimension
between(z, effect = "time")
Between(z, effect = "time")
Within(z, effect = "time")

# NA treatment for between, Between, and Within
z2 <- z
z2[length(z2)] <- NA # set last value to NA
between(z2, na.rm = TRUE) # non-NA value for last individual
Between(z2, na.rm = TRUE) # only the NA observation is lost
Within(z2, na.rm = TRUE)  # only the NA observation is lost

sum( # 9 observations lost due to one NA value
sum(, na.rm = TRUE))) # only the NA observation is lost
sum( # 9 observations lost due to one NA value
sum(, na.rm = TRUE))) # only the NA observation is lost

# }
Documentation reproduced from package plm, version 2.2-5, License: GPL (>= 2)

Community examples

Looks like there are no examples yet.