qdmean: Quasi-demean a variable, based on estimate of theta

View source: R/qdmean.R

qdmeanR Documentation

Quasi-demean a variable, based on estimate of theta

Description

Quasi-demean a variable, based on estimate of theta

Usage

qdmean(model, predictor, group, data, dv)

Arguments

model

an estimated random effects model

predictor

the predictor variable to quasi-demean

group

the grouping variable to use to quasi-demean

data

if a lmer model, the dataset used to estimate the model

dv

if a lmer model, the dependent variable (as a string in quotes)

Details

if using a lmer model, pass the data with no NA observations

Value

the quasi-demeaned independent variable

Author(s)

Soren Jordan and Andrew Q. Philips

Examples

## Not run: 
# using plm
model.plm <- plm(ln_wage ~ wks_work + union, index = c("idcode", "year"),
         data = nlswork,
         model = "random", random.method = "swar", effect = "individual")
# quasi-demean wks_work
wkswork.plm <- qdmean(model = model.plm, predictor = "wks_work", group = "idcode")
summary(wkswork.plm)

# using lmer
model.lmer <- lmer(ln_wage ~ wks_work + union + (1 | idcode),
         data = data)
# quasi-demean wks_work
wkswork.lmer <- qdmean(model = model.lmer, predictor = "wks_work", group = "idcode", 
         data = nlswork, dv = "ln_wage")
summary(wkswork.lmer)

## End(Not run)

andyphilips/qdmean documentation built on June 6, 2024, 12:49 p.m.