Anne,

you do this: Rprob <- predict(D, lda.0x, type="probabilities")

But  ?predict.lda  does not say that you can use an argument like
type="probabilities"

To get the posterior probabilities you could probably do:

Rprob <- predict(D, lda.0x, fun=function(x){predict(x)$posterior})

(based on what ?predict.lda  says under "Value")

Robert

On Wed, Jan 30, 2013 at 6:21 AM, <Anne.Reichmuth@dlr.de> wrote:

> Dear R group,
>
> I have a question about calculating and plotting probability of a
> classification using a raster image.
> My data consist of three different classes, in my case three tree species
> with specific reference spectra. Linear discriminant analysis was used for
> classifying the spectra
> >library(MASS)
> >lda.0x=lda(data0.x[,c(140,62,31,13)],grouping.code)  #data0.x are 4
> selected bands and grouping.code are the classes
>
> Results of lda.0x:
>
> Call:
> lda(data0.x[, c(140, 62, 31, 13)], grouping = grouping.code)
>
> Prior probabilities of groups:
>        Bu        Fi        Ta
> 0.2206522 0.6097826 0.1695652
>
> Group means:
>       X0.9193      X0.6367     X0.5244     X0.4591
> Bu  1.2526457  0.375728279  0.47791591  0.45878963
> Fi -0.4867618 -0.134819712 -0.19422522 -0.14486541
> Ta  0.1204249 -0.004096041  0.07656038 -0.07605643
>
> Coefficients of linear discriminants:
>                LD1        LD2
> X0.9193  3.0803877  0.7704369
> X0.6367 -1.1332850  4.6852711
> X0.5244 -1.2421211 -7.7201729
> X0.4591  0.5219285  2.4969266
>
> Proportion of trace:
>    LD1    LD2
> 0.9664 0.0336
>
> What I now want is to calculate the probability of these classes using the
> whole image
> >Rprob <- predict(D, lda.0x, type="probabilities") #D is image where the
> reference spectra have been collected before
>
> class       : RasterLayer
> dimensions  : 1780, 2116, 3766480  (nrow, ncol, ncell)
> resolution  : 2, 2  (x, y)
> extent      : 771779, 776011, 5305525, 5309085  (xmin, xmax, ymin, ymax)
> coord. ref. : +proj=utm +zone=32 +datum=WGS84 +units=m +no_defs
> +ellps=WGS84 +towgs84=0,0,0
> data source : in memory
> names       : layer
> values      : 1, 3  (min, max)
>
>
> First problem: no probability was calculated
> Second problem: I would like to separate the predict classification by
> class so that I can plot the probability by class.
>
> It would be terrific if someone might know how to reach that goal. I also
> tried this using ksvm which brings me to the same problem of selecting by
> class.
>
> Greetings, Anne
>
>
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

	[[alternative HTML version deleted]]

