Description Usage Arguments Value Examples
View source: R/Functions_Cross_Dep.R
This routine computes all models considered for cross-sectional dependence using endogenously
generated weight matrices. Currently "lmcd" for linear regression, "logitcd" (logit model), 
"poiscd" (poisson model), "probitcd" (probit model), "nbcd" (negative binomial) are supported.
Note: the data should first be sorted by unit ID Pid, then by time ID Tid
| 1 2 3 | 
| pars | vector of parameter values at which to evaluate the function | 
| Y | outcome variable | 
| X | matrix of covariates that generate spillovers | 
| Xm | matrix of other control variables | 
| Xi | matrix of variable(s) that drive cross-sectional dependence | 
| Tid | time ID | 
| Pid | unit ID | 
| fun | a function that parameterises cross-sectional dependence. it can be user-written. It must take exactly three inputs: xi,xj, and k. see polyexp, polyexp_mul, inter_xij for example. | 
| k | order of polynomial approximation for  | 
| nt | number of terms in approximation; should be of length equal to output of  | 
| utid | unique time IDs to be used in the estimation; should leave at least 1 period for lagged Xi | 
| modclass | the class of model. See description above for classes supported. | 
| rval | character string naming the output to return; "crit" - value of criterion, "critobs" - observation-specific criterion values, squared residuals for "lmcd", negative log-likelihoods for MLE methods, etc., "X" vector X*W where W collects weight matrices through time, or "PE" to return the linear combination lc and NxN weight matrices in a list of length utid. Use this last option for computing (private and spillover) partial effects | 
| eta | extra parameter to be passed, eg. θ for negative binomial,τ for quantile regression. | 
| dWzero | logical. Should the diagonal elements of the weight matrix be set to zero? 
Defaults to  | 
criterion value or vector of observation-specific criterion values if crit_obs=TRUE
| 1 2 3 4 5 6 7 | pars=c(1.0,0.5,0.8); N = 5; Tp = 6; fnp<- function(x,y,k){-(0.5*y^4+(x-y)^4)^.25} #dummy k
datpois=gdat_cd(pars=pars,N=N,Tp=Tp,seed=2,fun=fnp,eta = 200,modclass="poiscd") #poisson data 
k=1; lp=k*(k+1)/2; startp = rep(0.2,(lp+2))
RpacSPD::ncd_gen(pars=startp,Y=datpois$Y,X=datpois$X,Xm=NULL,Xi=datpois$X,Tid=datpois$tpID,
Pid=datpois$psID,fun=fnp,k=k,nt=lp,utid=c(2:Tp),modclass="poiscd") #return function value
RpacSPD::ncd_gen(pars=startp,Y=datpois$Y,X=datpois$X,Xm=NULL,Xi=datpois$X,Tid=datpois$tpID,
Pid=datpois$psID,fun=fnp,k=k,nt=lp,utid=c(2:Tp),modclass="poiscd",rval="Xw") #return Xw
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.