[R] lars - lasso problem

Steve Lianoglou mailinglist.honeypot at gmail.com
Fri Apr 8 20:01:22 CEST 2011


Hi,

First: Please make sure you CC R-help when responding to messages on
the list so that more people can help you, and more people can benefit
from help that is provided. You can do so easily by replying with
"reply-all."

Now:
Look at the help for the lars function:

R> ?lars

You'll see that `x` should be a matrix. I guess it doesn't say as
much, but `y` should be a (numeric) response.

Both of x and y in your case are data.frames. Convert them to the
appropriate objects and try again, eg:

R> x <- as.matrix(x)
R> y <- as.numeric(y[,1])

Now make sure that these objects look right by (among other things)
examining the output of:

R> head(x)
R> head(y)

Then try lars again.

Also, I'd suggest using the glmnet package instead of lars. It's
written by the same people and you'll get both the lasso and
elasticnet under one roof.

-steve

On Fri, Apr 8, 2011 at 1:54 PM, gauri j <gauri.jape7 at gmail.com> wrote:
> hi,
> the output of commands given by you, is as follows,
>
>
> command:
> R> is(x)
> R> apply(x, 2, function(x) is(x)[1])
> R> is(y)
>
>
>
> output:
> is(x)
> [1] "data.frame" "list"       "oldClass"   "vector"
>> apply(x, 2, function(x) is(x)[1])
>        V1        V2        V3        V4        V5        V6        V7
> V8
> "integer" "integer" "integer" "integer" "integer" "integer" "integer"
> "integer"
>        V9       V10       V11       V12       V13       V14       V15
> V16
> "integer" "integer" "integer" "integer" "integer" "integer" "integer"
> "integer"
>       V17       V18       V19       V20       V21       V22       V23
> V24
> "integer" "integer" "integer" "integer" "integer" "integer" "integer"
> "integer"
>       V25       V26       V27       V28       V29       V30       V31
> V32
> "integer" "integer" "integer" "integer" "integer" "integer" "integer"
> "integer"
>       V33       V34       V35       V36       V37       V38       V39
> V40
> "integer" "integer" "integer" "integer" "integer" "integer" "integer"
> "integer"
>       V41       V42       V43       V44       V45       V46       V47
> V48
> "integer" "integer" "integer" "integer" "integer" "integer" "integer"
> "integer"
>       V49       V50       V51       V52       V53       V54       V55
> V56
> "integer" "integer" "integer" "integer" "integer" "integer" "integer"
> "integer"
>       V57       V58       V59       V60       V61       V62       V63
> V64
> "integer" "integer" "integer" "integer" "integer" "integer" "integer"
> "integer"
>       V65       V66       V67       V68       V69       V70       V71
> V72
> "integer" "integer" "integer" "integer" "integer" "integer" "integer"
> "integer"
>       V73       V74       V75       V76       V77       V78       V79
> V80
> "integer" "integer" "integer" "integer" "integer" "integer" "integer"
> "integer"
>       V81       V82       V83       V84       V85       V86       V87
> V88
> "integer" "integer" "integer" "integer" "integer" "integer" "integer"
> "integer"
>       V89       V90       V91       V92       V93       V94       V95
> V96
> "integer" "integer" "integer" "integer" "integer" "integer" "integer"
> "integer"
>       V97       V98       V99      V100      V101      V102      V103
> V104
> "integer" "integer" "integer" "integer" "integer" "integer" "integer"
> "integer"
>      V105      V106      V107      V108      V109      V110      V111
> V112
> "integer" "integer" "integer" "integer" "integer" "integer" "integer"
> "integer"
>      V113      V114      V115      V116      V117      V118      V119
> V120
> "integer" "integer" "integer" "integer" "integer" "integer" "integer"
> "integer"
>      V121      V122      V123      V124      V125      V126      V127
> V128
> "integer" "integer" "integer" "integer" "integer" "integer" "integer"
> "integer"
>      V129      V130      V131      V132      V133      V134      V135
> V136
> "integer" "integer" "integer" "integer" "integer" "integer" "integer"
> "integer"
>      V137      V138      V139      V140      V141      V142      V143
> V144
> "integer" "integer" "integer" "integer" "integer" "integer" "integer"
> "integer"
>      V145      V146      V147      V148      V149      V150      V151
> V152
> "integer" "integer" "integer" "integer" "integer" "integer" "integer"
> "integer"
>      V153      V154      V155      V156      V157      V158      V159
> V160
> "integer" "integer" "integer" "integer" "integer" "integer" "integer"
> "integer"
>      V161      V162      V163      V164      V165      V166      V167
> V168
> "integer" "integer" "integer" "integer" "integer" "integer" "integer"
> "integer"
>      V169      V170      V171      V172      V173      V174      V175
> V176
> "integer" "integer" "integer" "integer" "integer" "integer" "integer"
> "integer"
>      V177      V178      V179      V180      V181      V182      V183
> V184
> "integer" "integer" "integer" "integer" "integer" "integer" "integer"
> "integer"
>      V185      V186      V187      V188      V189      V190      V191
> V192
> "integer" "integer" "integer" "integer" "integer" "integer" "integer"
> "integer"
>      V193      V194      V195      V196      V197      V198      V199
> V200
> "integer" "integer" "integer" "integer" "integer" "integer" "integer"
> "integer"
>      V201      V202      V203      V204      V205      V206      V207
> V208
> "integer" "integer" "integer" "integer" "integer" "integer" "integer"
> "integer"
>      V209      V210      V211      V212      V213      V214      V215
> V216
> "integer" "integer" "integer" "integer" "integer" "integer" "integer"
> "integer"
>      V217      V218      V219      V220      V221      V222      V223
> V224
> "integer" "integer" "integer" "integer" "integer" "integer" "integer"
> "integer"
>      V225      V226      V227      V228      V229      V230      V231
> V232
> "integer" "integer" "integer" "integer" "integer" "integer" "integer"
> "integer"
>      V233      V234      V235      V236      V237      V238      V239
> V240
> "integer" "integer" "integer" "integer" "integer" "integer" "integer"
> "integer"
>      V241      V242      V243      V244      V245      V246      V247
> V248
> "integer" "integer" "integer" "integer" "integer" "integer" "integer"
> "integer"
>      V249      V250      V251      V252      V253      V254      V255
> V256
> "integer" "integer" "integer" "integer" "integer" "integer" "integer"
> "integer"
>      V257      V258      V259      V260      V261      V262      V263
> V264
> "integer" "integer" "integer" "integer" "integer" "integer" "integer"
> "integer"
>      V265      V266      V267      V268      V269      V270      V271
> V272
> "integer" "integer" "integer" "integer" "integer" "integer" "integer"
> "integer"
>      V273      V274      V275      V276      V277      V278      V279
> V280
> "integer" "integer" "integer" "integer" "integer" "integer" "integer"
> "integer"
>> is(y)
> [1] "data.frame" "list"       "oldClass"   "vector"
>
> On Fri, Apr 8, 2011 at 11:11 AM, Steve Lianoglou
> <mailinglist.honeypot at gmail.com> wrote:
>>
>> Hi,
>>
>> On Fri, Apr 8, 2011 at 10:33 AM, gauri j <gauri.jape7 at gmail.com> wrote:
>> > hi,
>> > I have problem in following code, error is occurred. I have attached my
>> > data
>> > herewith. and my code is as following,
>> >> library(lars)
>> > Loaded lars 0.9-8
>> > Warning message:
>> > package 'lars' was built under R version 2.12.2
>> >> x<- read.table("D:/spring '11/james reggression/NewFeature.txt")
>> >> y<-read.table("D:/spring '11/lars/RFU.txt")
>> >> out<- lars(x,y, type = "lasso")
>> > Error in one %*% x : requires numeric/complex matrix/vector arguments
>>
>> What is the output for the following commands?
>>
>> R> is(x)
>> R> apply(x, 2, function(x) is(x)[1])
>> R> is(y)
>>
>>
>> --
>> Steve Lianoglou
>> Graduate Student: Computational Systems Biology
>>  | Memorial Sloan-Kettering Cancer Center
>>  | Weill Medical College of Cornell University
>> Contact Info: http://cbio.mskcc.org/~lianos/contact
>
>



-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact



More information about the R-help mailing list