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 |
pars |
vector of parameter values at which to evaluate the function |
Y |
outcome variable |
X |
matrix of covariates that generate spillovers or cross-sectional dependence |
Xm |
matrix of other control variables |
Tid |
time ID |
Pid |
unit ID |
wfun |
a user-supplied function of indices i,j, t, and δ that directly models the (i,j)'th
i \not = j entry (without normalisation) of the spatial matrix at period t. This is a more flexible option
vis-a-vis |
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., or "Xweight" vector X*W where W collects weight matrices through time. |
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 8 9 10 | 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))
wfn = function(i,j,t,del){ Xi=datpois$X; xit1 = datpois$X[((i-1)*Tp + t-1)];
xjt1 = datpois$X[((j-1)*Tp + t-1)]; return(exp(sum(c(fnp(xit1,xjt1,k))*del)))} #weight function
wfn(2,3,4,0.5) #test the weight function
RpacSPD::ncd_gen2(pars=startp,Y=datpois$Y,X=datpois$X,Xm=NULL,Tid=datpois$tpID,
Pid=datpois$psID,wfun=wfn,k=k,nt=lp,utid=c(2:Tp),modclass="poiscd") #return function value
RpacSPD::ncd_gen2(pars=startp,Y=datpois$Y,X=datpois$X,Xm=NULL,Tid=datpois$tpID,
Pid=datpois$psID,wfun=wfn,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.