R/cquad.R

Defines functions cquad

Documented in cquad

cquad <- function(formula, data, index=NULL, model=c("basic","equal","extended","pseudo"),
                  w=rep(1,n), dyn=FALSE, Ttol=10){

# INTERFACE FOR CQUAD ACCEPTING A FORMULA IN INPUT
#
# formula : formula with the same sintax as in plm
# data    : data.frame or pdata.frame
# index   : to denote panel structure as in plm
# model   : type of model = "basic", "equal", "extended", "pseudo"
# w       : vector of weights (not used for pseudo version)
# dyn     : for dynamic version (only for basic version)

# preliminaries
	model = match.arg(model)
	if (!inherits(data, "pdata.frame")) data <- pdata.frame(data, index)
	if (!inherits(formula, "pFormula")) formula <- pFormula(formula)
	data <- model.frame(formula, data)
	X = model.matrix(formula, data)[,-1]
	yv = pmodel.response(formula, data)
	id = attr(data,"index")[,1] 
	n = length(unique(id))
# call model
    if(model=="basic") out = cquad_basic(id,yv,X,w=w,dyn=dyn,Ttol=Ttol)
    if(model=="equal") out = cquad_equ(id,yv,X,w=w,Ttol=Ttol)
    if(model=="extended") out = cquad_ext(id,yv,X,w=w,Ttol=Ttol)
    if(model=="pseudo") out = cquad_pseudo(id,yv,X,Ttol=Ttol)		

    out$formula = formula
                                        # return output
    out
    
}

Try the cquad package in your browser

Any scripts or data that you put into this service are public.

cquad documentation built on Oct. 23, 2020, 7:55 p.m.