Re: [R] Fw: Help with PLSR

From: Bjørn-Helge Mevik <b.h.mevik_at_usit.uio.no>
Date: Fri, 13 May 2011 09:57:19 +0200

Amit Patel <amitrhelp_at_yahoo.co.uk> writes:

>>str(FullDataListTrans)
> num [1:40, 1:94727] 42 40.9 65 56 61.7 ...
> - attr(*, "dimnames")=List of 2
> ..$ : chr [1:40] "X" "X.1" "X.12" "X.13" ...
> ..$ : NULL
>
> I have also created a vector "GroupingList" which gives the groupnames for each
> respective sample(row).
>
>> GroupingList
> [1] 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4
> [39] 4 4
>> str(GroupingList)
> int [1:40] 1 1 1 1 1 1 1 1 1 1 ...
>
> I am now stuck while conducting the plsr. I have tried various methods of
> creating structured lists etc and have got nowhere. I have also tried many
> incarnations of
>
>
> BHPLS1 <- plsr(GroupingList ~ PCIList, ncomp = FeaturePresenceExpected[1], data
> = FullDataListTrans, validation = "LOO")
>
> Where am I going wrong.

You are not telling us what happens (or how you tried to make "structured lists"), but from your description of the data, FullDataListTrans is a matrix with only the the predictor variables, and GroupingList is a vector with the response. The data argument of plsr() (as of most modelling functions in R) expects a data.frame with both response and predictor variables.

Try this:

mydata <- data.frame(GroupingList = GroupingList, PCIList = I(FullDataListTrans))

(The I() is to prevent R from making the coloumns in FullDataListTrans separate variables in the data frame.)

BHPLS1 <- plsr(GroupingList ~ PCIList, ncomp = FeaturePresenceExpected[1], data = FullDataListTrans, validation = "LOO")

-- 
Regards,
Bjørn-Helge Mevik

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Fri 13 May 2011 - 08:00:15 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 13 May 2011 - 10:00:07 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive