# reg_cdir: Cross-sectional dependence in regression In estsyawo/RpacSPD: Spatial Panel Data models

## Description

A routine like `reg_cd()` that partially optimises with respect δ and uses internal R routines to optimise with respect to β. This is particularly helpful in high dimensional settings.

## Usage

 `1` ```reg_cdir(startdel, Y, X, Xm, ..., modclass = "lmcd", rvcov = FALSE) ```

## Arguments

 `startdel` vector of starting values for δ `Y` outcome variable `X` matrix of covariates or design matrix `Xm` matrix of other control variables `...` other arguments to be passed to ncd_gen except arguments listed here and `rval`. Argument names must match exactly. `modclass` the class of model. See description above for classes supported. `rvcov` Logical. Should the variance-covariance matrix be returned?

## Value

A list

• coefs vector of coefficients

• stde vector of standard errors

• tstat vector of t-statistics

• pval vector of p-values

• varcov variance-covariance matrix if `rvcov` is set to `TRUE`

• Wstat a Wald chi-square statistic

• pvwald Prob>Wstat

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14``` ```pars = c(1.0,0.5,0.8); pars2=pars = c(1.0,0.5,0.8,0.1,-0.1); N = 10; Tp = 16 fnp<- function(x,y,k) {-(0.5*y^4 + (x-y)^4)^.25} # a dummy k datpois = gdat_cd(pars=pars,N=N,Tp=Tp,seed=2,fun=fnp,eta = 200,modclass="poiscd") datpois2 = gdat_cd(pars=pars2,N=N,Tp=Tp,ncXm=2,seed=2,fun=fnp,eta = 200,modclass="poiscd") k=1; lp=k*(k+1)/2; startp = rep(0.2,lp); # fun() is known zg1=RpacSPD::reg_cdir(startdel=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",rvcov=TRUE) #return function value BIC(zg1) #compute BIC of fitted model k=4; lp=k*(k+1)/2; startp = rep(0,lp); # fun() is polynomial approximated zg4=RpacSPD::reg_cdir(startdel=startp,Y=datpois2\$Y,X=datpois2\$X,Xm=datpois2[c("X1","X2")], Xi=datpois2\$X,Tid=datpois2\$tpID,Pid=datpois2\$psID,fun=polyexp,k=k,nt=lp,utid=c(2:Tp), modclass="poiscd",rvcov=TRUE) BIC(zg4) #compute BIC of fitted model ```