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

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

Arguments

startdel

vector of starting values for \(\delta\)

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

See also

Examples

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
#> Warning: one-dimensional optimization by Nelder-Mead is unreliable: #> use "Brent" or optimize() directly
BIC(zg1) #compute BIC of fitted model
#> [1] 525.4116
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
#> [1] 581.1042