Reputation: 129
I'm following this article for implementing the single and double LASSO procedures in the hdm package, but somehow the double LASSO isn't functioning properly for me. I'll use the dataset provided by the package because that isn't working for me either, in addition to my own dataset.
As in the article, I load the GrowthData dataset, then I try to implement the double LASSO procedure:
library(hdm)
DS=rlassoEffects(Outcome~. , I=~gdpsh465, data=GrowthData)
summary(DS)
However, I'm getting the following error message:
> DS=rlassoEffects(Outcome~. , I=~gdpsh465, data=GrowthData)
Error in colnames(X) : object 'X' not found
> summary(DS)
Error in summary(DS) : object 'DS' not found
I know the official guide for rlassoEffects provides two different syntaxes for the function, so the reference to "object X" seems to refer to the other syntax.
However, why isn't the syntax style I'm using working?
Thanks!
Upvotes: 2
Views: 340
Reputation: 36
Thank you for your question. Yes, exactly. There was a bug in the indicated line. We fixed it already in the development version, which is available from the package git repository.
You can install the development version via the command
devtools::install_github("MartinSpindler/hdm")
Your example should work now.
We are going to update the CRAN version soon.
Upvotes: 2
Reputation: 157
Actually, I stumbled upon the same problem with the very same article. Note that rlassoEffects is just a wrapper for rlassoEffect. You could try implementing it by yourself following this tutorial.
EDIT:
Or just use it without a wrapper
rlassoEffect(data.matrix(dataset[, -c(1:2)]), unlist(dataset[, 1]), unlist(dataset[, 2]), method = "double selection")
Strangely, this gives a slightly different value of the coefficient in comparison to your cited article.
EDIT2:
I found the possible line of code that is responsible for the behaviour:
I.c <- which(colnames(X) %in% cn[I.c])
It is in the source code in the file rlassoEffects.formula. I already contacted the author. Let's see what happens.
Upvotes: 1