Grokbase Groups R r-help October 2006
FAQ
Dear all,
I am trying to include confidence intervals in a xyplot.

This is what I am doing:
xyplot(x ~ y|z, alpha = 1,band = "global",panel = panel.locfit)
(more specifically, in my case x is a binary response from a logistic
regression model)

The output plot was fine but it did not include the confidence intervals
Anyone knows how to do it? (xYplot did not work either)

many thanks
- juan

--
Juan F. Poyatos
Structural and Computational Biology Programme
Spanish National Cancer Centre (CNIO)
Melchor Fernandez Almagro, 3/E-28029 Madrid SPAIN
Phone:+34 912 246 900/Fax: +34 912 246 980

http://bioinfo.cnio.es/~jpoyatos/




**NOTA DE CONFIDENCIALIDAD** Este correo electr?nico, y en s...{{dropped}}

Search Discussions

  • Deepayan Sarkar at Oct 18, 2006 at 10:00 pm

    On 10/18/06, juan f poyatos wrote:
    Dear all,
    I am trying to include confidence intervals in a xyplot.

    This is what I am doing:
    xyplot(x ~ y|z, alpha = 1,band = "global",panel = panel.locfit)
    (more specifically, in my case x is a binary response from a logistic
    regression model)

    The output plot was fine but it did not include the confidence intervals
    Anyone knows how to do it? (xYplot did not work either)
    Well, panel.locfit doesn't have any options to draw confidence bands,
    so you'll have to write a panel function that does. Shouldn't be hard
    to extend panel.locfit if you know how to extract that information
    from a locfit object.

    -Deepayan
  • Dieter Menne at Oct 19, 2006 at 7:49 am
    Deepayan Sarkar <deepayan.sarkar <at> gmail.com> writes:
    On 10/18/06, juan f poyatos <jpoyatos <at> cnio.es> wrote:
    Dear all,
    I am trying to include confidence intervals in a xyplot.
    ...
    Well, panel.locfit doesn't have any options to draw confidence bands,
    so you'll have to write a panel function that does. Shouldn't be hard
    to extend panel.locfit if you know how to extract that information
    from a locfit object.
    plot.locfit has bands. I think Juan mixed trellis and standard plot
    documentation.


    x <- rnorm(100)
    y <- dnorm(x) + rnorm(100) / 5
    plot(locfit(y~x), band="global")
  • Juan f poyatos at Oct 19, 2006 at 8:24 am
    But it is *within* a trellis plot when I cannot plot the bands!

    Building up on Dieter's example:

    x <- rnorm(100)
    y <- dnorm(x) + rnorm(100) / 5
    plot(locfit(y~x), band="global")

    Plots two nice confidence bands.

    But try this
    z <- dnorm(y) + rnorm(100) / 3
    Z <- equal.count(z, number = 4, overlap = .1)
    xyplot(z ~ y|Z, alpha = 1,band = "global",panel = panel.locfit)

    and you will not see the bands,

    indeed band is completely ignored as
    xyplot(z ~ y|Z, alpha = 1,band = "rubbish",panel = panel.locfit)

    works fine but without the bands!!

    - juan

    On Thu, 2006-10-19 at 07:49 +0000, Dieter Menne wrote:
    Deepayan Sarkar <deepayan.sarkar <at> gmail.com> writes:
    On 10/18/06, juan f poyatos <jpoyatos <at> cnio.es> wrote:
    Dear all,
    I am trying to include confidence intervals in a xyplot.
    ...
    Well, panel.locfit doesn't have any options to draw confidence bands,
    so you'll have to write a panel function that does. Shouldn't be hard
    to extend panel.locfit if you know how to extract that information
    from a locfit object.
    plot.locfit has bands. I think Juan mixed trellis and standard plot
    documentation.


    x <- rnorm(100)
    y <- dnorm(x) + rnorm(100) / 5
    plot(locfit(y~x), band="global")

    ______________________________________________
    R-help at stat.math.ethz.ch 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.
    --
    Juan F. Poyatos
    Structural and Computational Biology Programme
    Spanish National Cancer Centre (CNIO)
    Melchor Fernandez Almagro, 3/E-28029 Madrid SPAIN
    Phone:+34 912 246 900/Fax: +34 912 246 980

    http://bioinfo.cnio.es/~jpoyatos/




    **NOTA DE CONFIDENCIALIDAD** Este correo electr?nico, y en s...{{dropped}}
  • Deepayan Sarkar at Oct 19, 2006 at 5:52 pm

    On 10/19/06, juan f poyatos wrote:
    But it is *within* a trellis plot when I cannot plot the bands!

    Building up on Dieter's example:

    x <- rnorm(100)
    y <- dnorm(x) + rnorm(100) / 5
    plot(locfit(y~x), band="global")

    Plots two nice confidence bands.

    But try this
    z <- dnorm(y) + rnorm(100) / 3
    Z <- equal.count(z, number = 4, overlap = .1)
    xyplot(z ~ y|Z, alpha = 1,band = "global",panel = panel.locfit)

    and you will not see the bands,

    indeed band is completely ignored as
    xyplot(z ~ y|Z, alpha = 1,band = "rubbish",panel = panel.locfit)

    works fine but without the bands!!
    And why does that come as a surprise to you?

    Since you seem to have missed the point of the previous replies, let
    me spell it out for you. A function does what it is instructed to do,
    not what you _want_ it to do. The most reliable way to figure out what
    those instructions are is to look at the source code of that function.
    Since this is not very user friendly, R also requires that all
    functions be documented, and specifically, that the documentation for
    any function, say foo, can be accessed by typing help(foo). Since you
    are using the function panel.locfit, you are supposed to look at
    help(panel.locfit), which does not claim to have any support for
    bands.

    In this case, the source of panel.locfit is actually simpler:

    panel.locfit
    function (x, y, subscripts, z, xyz.labs, xyz.axes, xyz.mid, xyz.minmax,
    xyz.range, col.regions, at, drape, contour, region, groups,
    ...)
    {
    panel.xyplot(x, y, ...)
    args <- list(x = x, y = y, ...)
    ok <- names(formals(locfit.raw))
    llines.locfit(do.call("locfit.raw", args[ok[ok %in% names(args)]]))
    }

    (removing the irrelevant part)

    -Deepayan
    - juan

    On Thu, 2006-10-19 at 07:49 +0000, Dieter Menne wrote:
    Deepayan Sarkar <deepayan.sarkar <at> gmail.com> writes:
    On 10/18/06, juan f poyatos <jpoyatos <at> cnio.es> wrote:
    Dear all,
    I am trying to include confidence intervals in a xyplot.
    ...
    Well, panel.locfit doesn't have any options to draw confidence bands,
    so you'll have to write a panel function that does. Shouldn't be hard
    to extend panel.locfit if you know how to extract that information
    from a locfit object.
    plot.locfit has bands. I think Juan mixed trellis and standard plot
    documentation.


    x <- rnorm(100)
    y <- dnorm(x) + rnorm(100) / 5
    plot(locfit(y~x), band="global")

    ______________________________________________
    R-help at stat.math.ethz.ch 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.
    --
    Juan F. Poyatos
    Structural and Computational Biology Programme
    Spanish National Cancer Centre (CNIO)
    Melchor Fernandez Almagro, 3/E-28029 Madrid SPAIN
    Phone:+34 912 246 900/Fax: +34 912 246 980

    http://bioinfo.cnio.es/~jpoyatos/




    **NOTA DE CONFIDENCIALIDAD** Este correo electr?nico, y en s...{{dropped}}



    ______________________________________________
    R-help at stat.math.ethz.ch 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.


    --
    http://www.stat.wisc.edu/~deepayan/

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupr-help @
categoriesr
postedOct 18, '06 at 8:47a
activeOct 19, '06 at 5:52p
posts5
users3
websiter-project.org
irc#r

People

Translate

site design / logo © 2022 Grokbase