pmean {plm}R Documentation

Conditional mean of a variable

Description

Computes the mean of a variable conditionnaly to the time or the individual index

Usage

pmean(x,cond=NULL,effect="individual",data=NULL)

Arguments

x a numeric vector or a numeric matrix for which the conditional means should be computed,
cond a vector containing the conditional variable,
effect the mean is conditionnal to the individual or the time index whether effect equals "individual" or "time",
data a pdata.frame.

Details

If x is a variable of a pdata.frame, pmean(x) finds the "data" attribute of x, extract the individual index from this pdata.frame and computes the individual means. If effect is "time", the time means are computed. The conditional variable may also be explicitely indicated using the cond (a vector of the same length as x) or the data (a pdata.frame) argument. This is the only way to use this function if x is a matrix.

Value

a vector (or matrix) of the same dimension as x containing the conditional means. An attribute "cm" contains a vector (or matrix) containing the conditional means with one line for each value of the conditionnal variable.

Examples

library(Ecdat)
data(Produc)
Produc=pdata.frame(Produc,state,year)
pmean(Produc$pc)
form <- pmean(log(gsp))~pmean(log(pc))
lm(form,data=Produc)

[Package plm version 0.1-1 Index]