Re: [R] Trellis Conditional contourplot

From: Marco LO <>
Date: Wed 25 Oct 2006 - 15:58:36 GMT


  # The R codes to generate the Trellis plot are from the R help archive by Karl Ove Hufthammer    

  panel.estcontplot <- function(x, y, ..., pretty=TRUE, region=FALSE) {, y)

                   subscripts = seq(nrow(,
                   pretty=pretty, region=region, contour=TRUE, ...)

  # The titanic3 dataset is from with missing value imputations according to the book    

xtrans <- transcan(~ I(age) + pclass + sex + sibsp + parch + survived, data = titanic3,

            n.impute=5, pl=F, trantab=T, imputed=T, transformed=TRUE) titanic3[ ,'age'] <- xtrans$transformed[ ,'age'] titanic3[ ,'survived'] <- as.factor(titanic[ ,'survived'])    

  xyplot(age ~ sibsp | survived, data = titanic3, panel=panel.estcontplot)        

  Anyway, I realized that Trellis could only be conditional on the categorical variable while what I really want is conditional density plot of survived on the two covariates. Thus I tried to twist cdplot with kde2d to substitute density.    

  However, I still have no success. Would anyone help, please!    


Deepayan Sarkar <> wrote:   On 10/24/06, Marco LO wrote:
> Hello All,
> I've problems to interpret the contourplot for a binary response dependent variable. For example, I ploted the survived probability for the titanic3 dataset,
> Trellis displayed two panels of contour, one for dead and one for alive. However,
> the contours between the two panels didn't conform to the rule of prob(dead) =
> 1 - prob(alive). How I should read the contours? What I did wrongly?

Hard to say, since we have no idea what you actually did. As the footer of every r-help message says:

PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code.


> Is there an example that I could follow?
> Thanks!
> marco

        [[alternative HTML version deleted]] mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Thu Oct 26 05:44:25 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 25 Oct 2006 - 20:30:44 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.