[R] help with plotting results of lda
Prof Brian Ripley
ripley at stats.ox.ac.uk
Sun Apr 26 18:35:46 CEST 2009
On Sun, 26 Apr 2009, Uwe Ligges wrote:
> Works for me with
>
> library(MASS)
> plot(lda(Species~., data=iris))
>
> hence you may want to profide the data to enable us to reproduce your
> problem...
He is trying to plot the results from a cross-validation. As the help
page clearly states, that is a list (and has no assigned class).
Plotting an arbitrary list makes little sense (and not does plotting
the results of an LDA cross-validation).
>
> Uwe Ligges
>
>
>
> pgseye wrote:
>> Hi,
>>
>> I've performed an lda and obtained a classification table for some of my
>> data:
>>
>>> efa.dfa<-lda(groups~.,efa.scores.8,CV=T)
>>> str(efa.dfa)
>> List of 5
>> $ class : Factor w/ 2 levels "1","2": 1 2 1 2 1 1 2 2 1 2 ...
>> $ posterior: num [1:160, 1:2] 0.99083 0.00852 0.93983 0.23186 0.85931 ...
>> ..- attr(*, "dimnames")=List of 2
>> .. ..$ : chr [1:160] "1" "2" "3" "4" ...
>> .. ..$ : chr [1:2] "1" "2"
>> $ terms :Classes 'terms', 'formula' length 3 groups ~ Comp.1 + Comp.2 +
>> Comp.3 + Comp.4 + Comp.5 + Comp.6 + Comp.7 + Comp.8 + Comp.9 + Comp.10
>> + Comp.11 + Comp.12 + ...
>> .. ..- attr(*, "variables")= language list(groups, Comp.1, Comp.2,
>> Comp.3,
>> Comp.4, Comp.5, Comp.6, Comp.7, Comp.8, Comp.9, Comp.10, Comp.11,
>> Comp.12, Comp.13, ...
>> .. ..- attr(*, "factors")= int [1:35, 1:34] 0 1 0 0 0 0 0 0 0 0 ...
>> .. .. ..- attr(*, "dimnames")=List of 2
>> .. .. .. ..$ : chr [1:35] "groups" "Comp.1" "Comp.2" "Comp.3" ...
>> .. .. .. ..$ : chr [1:34] "Comp.1" "Comp.2" "Comp.3" "Comp.4" ...
>> .. ..- attr(*, "term.labels")= chr [1:34] "Comp.1" "Comp.2" "Comp.3"
>> "Comp.4" ...
>> .. ..- attr(*, "order")= int [1:34] 1 1 1 1 1 1 1 1 1 1 ...
>> .. ..- attr(*, "intercept")= int 1
>> .. ..- attr(*, "response")= int 1
>> .. ..- attr(*, ".Environment")=<environment: R_GlobalEnv> .. ..-
>> attr(*, "predvars")= language list(groups, Comp.1, Comp.2, Comp.3,
>> Comp.4, Comp.5, Comp.6, Comp.7, Comp.8, Comp.9, Comp.10, Comp.11,
>> Comp.12, Comp.13, ...
>> .. ..- attr(*, "dataClasses")= Named chr [1:35] "numeric" "numeric"
>> "numeric" "numeric" ...
>> .. .. ..- attr(*, "names")= chr [1:35] "groups" "Comp.1" "Comp.2"
>> "Comp.3"
>> ...
>> $ call : language lda(formula = groups ~ ., data = efa.scores.8, CV =
>> T)
>> $ xlevels : list()
>>> table(groups, Classified=efa.dfa$class)
>> Classified
>> groups 1 2
>> 1 59 21
>> 2 10 70
>>
>> but when I try to plot the results I get:
>>
>>> plot(efa.dfa)
>> Error in plot.window(...) : need finite 'xlim' values
>> In addition: Warning messages:
>> 1: In min(x) : no non-missing arguments to min; returning Inf
>> 2: In max(x) : no non-missing arguments to max; returning -Inf
>> 3: In min(x) : no non-missing arguments to min; returning Inf
>> 4: In max(x) : no non-missing arguments to max; returning -Inf
>>
>> anyone have any ideas?
>>
>> Thanks a lot,
>>
>> Paul
>
> ______________________________________________
> 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.
>
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list