prodest icon indicating copy to clipboard operation
prodest copied to clipboard

Control variables with ACF correction error

Open matthiasfru opened this issue 5 years ago • 1 comments

Hi Gabrielle,

when trying to run a ACF-corrected model with non-NULL control variables the command throws an error:

prodestACF(Y = chilean$Y, fX = chilean$fX1, sX = chilean$sX, 
    pX = chilean$pX, cX = chilean$cX, idvar = chilean$idvar, timevar = chilean$timevar, 
    R = 5, opt = 'optim', theta0 = NULL, cluster = NULL)

yields

Warning message in coef(first.stage)[2:(1 + snum + fnum + cnum)] + rnorm((snum + :
“longer object length is not a multiple of shorter object length”Warning message in coef(first.stage)[2:(1 + snum + fnum + cnum)] + rnorm((snum + :
“longer object length is not a multiple of shorter object length”Warning message in coef(first.stage)[2:(1 + snum + fnum + cnum)] + rnorm((snum + :
“longer object length is not a multiple of shorter object length”Warning message in coef(first.stage)[2:(1 + snum + fnum + cnum)] + rnorm((snum + :
“longer object length is not a multiple of shorter object length”Warning message in coef(first.stage)[2:(1 + snum + fnum + cnum)] + rnorm((snum + :
“longer object length is not a multiple of shorter object length”Warning message in coef(first.stage)[2:(1 + snum + fnum + cnum)] + rnorm((snum + :
“longer object length is not a multiple of shorter object length”Warning message in matrix(unlist(lapply(boot.indices, finalACF, data = data, fnum = fnum, :
“data length [10] is not a sub-multiple or multiple of the number of rows [4]”
Error in names(betas$betas) <- res.names: 'names' attribute [3] must be the same length as the vector [2]

The issue maybe related to line 88 prodestACF.R

theta0 <- coef(first.stage)[2:(1 + snum + fnum + cnum)] + rnorm((snum + fnum), 0, 0.01)

because this implies that length(theta0) = snum+fnum+cnum. But if length(theta0) = snum + fnum +cnum the optimization routine on throws an error on line 144, namely that Error in mX %*% theta : non-conformable arguments.

So I guess the problem is what the proper length of theta0 should be or rather if the controls matter in the second stage, no?

Thank you for the package, Matthias

matthiasfru avatar Aug 01 '19 16:08 matthiasfru

Dear Matthias,

thanks for the message and sorry for the very late reply: I must have missed it!

I will be looking into the issue - which, by the way, seems to me that has to do exactly with the lines of code you mention - and let you know as soon as possible.

Sorry again for the late reply,

Gabriele

GabrieleRovigatti avatar Oct 10 '19 12:10 GabrieleRovigatti