0

Ι am an absolute beginner at R. I want to use it to do a lasso multiresponse regression model, using a large number of MRI brain metrics to predict 3 or 4 behavioural outcome variables. The original datasets are in SPSS. I have used to 'foreign' package to import them from SPSS. One SPSS file consists solely of all the predictor variables, and the other one consists solely of 3 dependent variables. I have 26 participants. Here is the code:

> x=read.spss("F:\\Google Drive\\Master\\Thesis\\Predictors.sav", use.value.labels=FALSE, to.data.frame=TRUE,
+ max.value.labels=FALSE, trim.factor.names=TRUE,
+ trim_values=TRUE, reencode=NA, use.missings=to.data.frame,
+ sub=".", add.undeclared.levels="sort",
+ duplicated.value.labels="append",
+ duplicated.value.labels.infix="_duplicated_")

> y=read.spss("F:\\Google Drive\\Master\\Thesis\\Response.sav", use.value.labels=FALSE, to.data.frame=TRUE,
+ max.value.labels=FALSE, trim.factor.names=TRUE,
+ trim_values=TRUE, reencode=NA, use.missings=to.data.frame,
+ sub=".", add.undeclared.levels="sort",
+ duplicated.value.labels="append",
+ duplicated.value.labels.infix="_duplicated_")

> fit=glmnet(x, y, family="mgaussian", alpha=1.0, weights=rep(1,26), offset=NULL, nlambda=100)
Error in mrelnet(x, is.sparse, ix, jx, y, weights, offset, alpha, nobs,  : 
  (list) object cannot be coerced to type 'double'

Any idea how to solve that error message? Again, I have to stress I am an absolute beginner in R.

  • Please make your [example reproducible](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – Roman Luštrik Jul 24 '17 at 11:24
  • might [this](https://stackoverflow.com/questions/8457624/r-glmnet-list-object-cannot-be-coerced-to-type-double) be of help? – simone Jul 24 '17 at 11:54

0 Answers0