[R] glm in hdlm?

Stanislav Aggerwal stan.aggerwal at gmail.com
Thu Mar 19 10:13:59 CET 2015


I am following the example in the vignette for hdlm (p. 19), but I cannot
get it to to fit a logistic. For those who don't know the package, it
allows one to fit high dimensional data where the number of variables may
exceed the number of cases.

library(hdlm)

LMFUN <- function(x,y) return(glm(y ~ x, family=binomial(link=logit)))
FUNCVFIT <- function(x,y) return(cv.glmnet(x, y, family='binomial'))

set.seed(1234)
xx<-matrix(runif(20*4),20,4)  #20 cases, 4 variables
xx[,1]<-xx[,1]+1:20
yy<-c(0,0,0,1,0,1,1,0,1,0,1,0,1,0,1,1,1,1,1,1)

#ordinary glms are fitted with no problems with yy either factor or numeric
fit1<-glm(as.factor(yy)~xx,family=binomial)
fit2<-glm(yy~xx,family=binomial)

fit3<-hdlm(as.factor(yy) ~ xx, LMFUN = LMFUN, FUNCVFIT = FUNCVFIT)

This produces the error:
========
Error in { :
  task 1 failed - "(list) object cannot be coerced to type 'double'"
In addition: There were 11 warnings (use warnings() to see them)
=========

fit4<-hdlm(yy ~ xx, LMFUN = LMFUN, FUNCVFIT = FUNCVFIT)

This produces:
============
Error in { :
  task 1 failed - "(list) object cannot be coerced to type 'double'"
In addition: Warning messages:
1: Option grouped=FALSE enforced in cv.glmnet, since < 3 observations per
fold
2: Option grouped=FALSE enforced in cv.glmnet, since < 3 observations per
fold
3: Option grouped=FALSE enforced in cv.glmnet, since < 3 observations per
fold
4: Option grouped=FALSE enforced in cv.glmnet, since < 3 observations per
fold
5: Option grouped=FALSE enforced in cv.glmnet, since < 3 observations per
fold
6: Option grouped=FALSE enforced in cv.glmnet, since < 3 observations per
fold
7: Option grouped=FALSE enforced in cv.glmnet, since < 3 observations per
fold
8: Option grouped=FALSE enforced in cv.glmnet, since < 3 observations per
fold
9: Option grouped=FALSE enforced in cv.glmnet, since < 3 observations per
fold
10: Option grouped=FALSE enforced in cv.glmnet, since < 3 observations per
fold
=============

Please tell me how to fit the glm in hdlm. Thanks very much for any help.

Stan

	[[alternative HTML version deleted]]



More information about the R-help mailing list