First, sorry about the vacuous title but I find it really hard to describe the problem and to say whether it is a bug or not.
The setting is as follows: I am using isat with both user-defined estimator and user-defined diagnostics. Sometimes, the diagnostic tests fail in any block search, which causes the isat algorithm to not do any selection (see Issue #39). This means that in the final selection, there are no indicators and in my case, the diagnostics still fail.
|
##do final gets: |
|
|
|
getsis <- getsFun(y, mXis, untransformed.residuals=NULL, |
|
user.estimator=userEstArg, gum.result=NULL, t.pval=t.pval, |
|
wald.pval=wald.pval, do.pet=do.pet, ar.LjungB=arLjungB, |
|
arch.LjungB=archLjungB, normality.JarqueB=normality.JarqueB, |
|
user.diagnostics=user.diagnostics, gof.function=gofFunArg, |
|
gof.method=gof.method, keep=mxkeep, include.gum=include.gum, |
|
include.1cut=include.1cut, include.empty=include.empty, |
|
max.paths=max.paths, turbo=turbo, tol=tol, LAPACK=LAPACK, |
|
max.regs=max.regs, print.searchinfo=print.searchinfo, |
|
alarm=FALSE) |
Then, it removes the x regressors mXis even though these should still be included in the model (we only want to select over indicators).
|
##estimate final model: |
|
y <- zoo(y, order.by=y.index) |
|
if(is.null(getsis$specific.spec)){ |
|
mXisNames <- NULL |
|
mXis <- NULL |
|
}else{ |
The following arx() call therefore has no regressors.
|
mod <- arx(y, mc=FALSE, mxreg=mXis, vcov.type=vcov.type, |
|
qstat.options=qstat.options, normality.JarqueB=normalityArg, |
|
user.estimator=userEstArgArx, user.diagnostics=user.diagnostics, |
|
tol=tol, LAPACK=LAPACK, plot=FALSE) |
Now, this would not necessarily be a problem because the model selection procedure has shown us that the GUM does not pass the diagnostics - neither with nor without indicators present. The real problem is that the arx() call produces an error, namely in the part where it calls the diagnostics() function. My user-specified diagnostic function requires regressors. So unlike the AR or ARCH test, it does not work with an empty model (for example, I am testing the endogeneity of a regressors - but when there is no regressor, I cannot run this test). Currently, I have coded my user diagnostic function to return NULL in that case. And with the current code, everything works because it treats NULL as a special case.
|
if( !is.null(userVals) ){ userVals <- rbind(userVals) } |
|
## !is.null(userVals) is due to J-bat's ivgets code: |
|
if( !is.null(user.fun$pval) && !is.null(userVals) ){ |
However, if we want to get rid of this special rule, I get an error in the following code chunk because the returned value is NULL but there has been a rejection rule, so the length of the vectors do not match.
|
tmp[,"is.reject.bad"] <- user.fun$is.reject.bad |
So I guess there are two questions:
- Is it desirable that the
arx() call deletes the theory regressors if no selection of indicators was made?
- What should my user diagnostic function return when the diagnostic test cannot be run? A matrix of
NAs would be my first instinct but then we obtain NA values when the diagnostics are checked for whether they pass or not, which messes up the rest of the code.
First, sorry about the vacuous title but I find it really hard to describe the problem and to say whether it is a bug or not.
The setting is as follows: I am using isat with both user-defined estimator and user-defined diagnostics. Sometimes, the diagnostic tests fail in any block search, which causes the isat algorithm to not do any selection (see Issue #39). This means that in the final selection, there are no indicators and in my case, the diagnostics still fail.
gets/gets/R/gets-isat-source.R
Lines 586 to 597 in a58749f
Then, it removes the x regressors
mXiseven though these should still be included in the model (we only want to select over indicators).gets/gets/R/gets-isat-source.R
Lines 610 to 615 in a58749f
The following
arx()call therefore has no regressors.gets/gets/R/gets-isat-source.R
Lines 631 to 634 in a58749f
Now, this would not necessarily be a problem because the model selection procedure has shown us that the GUM does not pass the diagnostics - neither with nor without indicators present. The real problem is that the
arx()call produces an error, namely in the part where it calls thediagnostics()function. My user-specified diagnostic function requires regressors. So unlike the AR or ARCH test, it does not work with an empty model (for example, I am testing the endogeneity of a regressors - but when there is no regressor, I cannot run this test). Currently, I have coded my user diagnostic function to returnNULLin that case. And with the current code, everything works because it treatsNULLas a special case.gets/gets/R/gets-base-source.R
Lines 186 to 188 in a58749f
However, if we want to get rid of this special rule, I get an error in the following code chunk because the returned value is
NULLbut there has been a rejection rule, so the length of the vectors do not match.gets/gets/R/gets-base-source.R
Line 198 in a58749f
So I guess there are two questions:
arx()call deletes the theory regressors if no selection of indicators was made?NAs would be my first instinct but then we obtainNAvalues when the diagnostics are checked for whether they pass or not, which messes up the rest of the code.