[R] Questions about bwplot

2007-05-21 Thread Klaus Nordhausen
Dear R-experts,

I have some questions about boxplots with lattice.
My data is similar as in the example below, I have two factors
(Goodness of Fit and Algorithms) and data values but in each panels the scales 
are quite different, therefore the normal boxplots produced by

set.seed(1)
GOF - factor(rep(c(GOF1,GOF2,GOF3),each=40))
Alg - rep(factor(rep(c(A1,A2,A3,R1),each=10)),3)
Value - c(runif(40),rnorm(40),rnorm(30,10,3),rnorm(10,20,3))
test.data - data.frame(Alg=Alg,GOF=GOF,Value=Value)

library(lattice)
bwplot(Value ~ Alg | GOF, data = test.data, as.table=T, layout=c(1,3))

are not very informative.

Then I used

bwplot(Value ~ Alg | GOF, data = test.data, scale=list(relation=free), 
as.table=T, layout=c(1,3))

from which my first question arises:

Is it possible to have no vertical space between the panels though they have 
different y-scales when using the
argument scale=list(relation=free)?

Then I would like to modify the boxplot - actually I'm not interested so much 
in the boxes of factor R1 (=random guess)
but would rather have a horizontal line in each panel at the median of R1 for 
the given panel, and only the boxes for levels
A1, A2 and A3 - and the horizontal line I would like only if it would fall in 
the plotting area when only plotting the boxes
for the levels A1, A2 and A3 (this means in the third panel the line should not 
be there).

My attempt 

test.data$ind - ifelse(Alg==R1,1,0)
my.boxpanel - function(x, y, subscripts, groups, ...) {
orig - groups[subscripts] == 0
panel.bwplot(x[orig], y[orig], ...)
panel.abline(h=median(y[!orig]))
  }
bwplot(Value ~ Alg | GOF, data = test.data, scale=list(relation=free),
as.table=T, groups=ind, layout=c(1,3),panel=my.boxpanel,
drop.unused.levels=T,
xlim=c(A1,A2,A3),
ylim=list(c(0,1),c(-2,2),c(0,17)))

requires that I know the range of the yaxis and at the xaxis leaves space for 
the box of R1. Can that be avoided?

Then my last question - I would like to emphasise the best factor=algorithm in 
each panel by coloring its box.
However best means in the first two panels lowest median and in the last 
panel highest median. Can this be done?
I managed it only when in all panels the lowest median box should be filled 
with color.

trellis.device(color = FALSE)
my.boxpanel2 - function(x, y, subscripts, groups, ...) {
orig - groups[subscripts] == 0
medians-tapply(y[orig],x[orig],median)
medians2-medians[!is.na(medians)]
cols-grey((1-as.numeric(medians2==min(medians2))/3))
z-x[orig]
levels(z)-c(A1,A2,A3,NA)
w-y[orig]
panel.bwplot(z, w, fill=cols, ...)
panel.abline(h=median(y[!orig]))
  }  

bwplot(Value ~ Alg | GOF, data = test.data, scale=list(relation=free),
as.table=T, groups=ind, layout=c(1,3),panel=my.boxpanel2, 
drop.unused.levels=T, xlim=c(A1,A2,A3),
ylim=list(c(0,1),c(-2,2),c(0,17)))

It would be great if you could help me with this plot!

Thanks in advance,

Klaus
--

__
R-help@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.


[R] [R-pkgs] new packages 'ICS' and 'ICSNP'

2007-05-16 Thread Klaus Nordhausen
Dear R useRs,

The new contributed packages 'ICS' and 'ICSNP' are available on CRAN.

Descriptions:

The 'ICS' package implements the 2 scatter matrix transformation to 
obtain an invariant coordinate system or independent components, 
depending on the underlying assumptions. The result of the 
transformation is an object of the S4 class ics which is provided by 
this package. Besides generic functions to create and work with ics 
objects the package contains also some scatter matrices and two tests 
for multinormality.


The 'ICSNP' package contains tools for nonparametric multivariate 
analysis, including the estimation of location and shape as well as some 
tests for location and independence. Shape matrices from this package 
can be used as one of the scatter matrices needed in the package ICS 
whereas the tests of this package can be used for testing in the 
framework of invariant coordinates or independent components obtained 
from the package ICS. The parametric Hotelling’s T test serves as a 
reference for the nonparametric location tests.

Suggestions, bug reports and other comments are very welcome.

Best wishes,

Klaus, Seija, Hannu and Dave

-- 
Klaus Nordhausen
Researcher
Tampere School of Public Health
FIN-33014 University of Tampere

phone:  +358 3 3551 7086
fax:+358 3 3551 6057
e-mail: [EMAIL PROTECTED]

___
R-packages mailing list
[EMAIL PROTECTED]
https://stat.ethz.ch/mailman/listinfo/r-packages

__
R-help@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.


Re: [R] Tail area of sum of Chi-square variables

2007-03-30 Thread Klaus Nordhausen
Hi,

thanks everyone! 

pchisqsum() in the survey package does exactly what I was looking for!

Best wishes,

Klaus


 Original-Nachricht 
Datum: Thu, 29 Mar 2007 07:45:15 -0700 (PDT)
Von: Thomas Lumley [EMAIL PROTECTED]
An: S Ellison [EMAIL PROTECTED]
CC: [EMAIL PROTECTED], [EMAIL PROTECTED], r-help@stat.math.ethz.ch, [EMAIL 
PROTECTED]
Betreff: Re: [R] Tail area of sum of  Chi-square variables

 
 The Satterthwaite approximation is surprisingly good, especially in the 
 most interesting range in the right tail (say 0.9 to 0.999). There is also
 another, better, approximation with a power of a chi-squared distribution 
 that has been used in the survey literature.
 
 However, since it is easy to write down the characteristic function and 
 perfectly feasible to invert it by numerical integration, we might as well
 use the right answer.
 
   -thomas
 
 On Thu, 29 Mar 2007, S Ellison wrote:
  I was wondering if there are any R functions that give the tail area
  of a sum of chisquare distributions of the type:
  a_1 X_1 + a_2 X_2
  where a_1 and a_2 are constants and X_1 and X_2 are independent
  chi-square variables with different degrees of freedom.
 
  You might also check out Welch and Satterthwaite's (separate) papers on
 effective degrees of freedom for compound estimates of variance, which led
 to a thing called the welch-satterthwaite equation by one (more or less
 notorious, but widely used) document called the ISO Guide to Expression of
 Uncertainty in Measurement (ISO, 1995). The original papers are
  B. L. Welch, J. Royal Stat. Soc. Suppl.(1936)  3 29-48
  B. L. Welch, Biometrika, (1938) 29 350-362
  B. L. Welch, Biometrika, (1947) 34 28-35
 
  F. E. Satterthwaite, Psychometrika (1941) 6 309-316
  F. E. Satterthwaite, Biometrics Bulletin, (1946) 2 part 6 110-114
 
  The W-S equation - which I believe is a special case of Welch's somewhat
 more general treatment - says that if you have multiple independent
 estimated variances v[i] (could be more or less equivalent to your a_i X_i?) 
 with
 degrees of freedom nu[i], the distribution of their sum is approximately a
 scaled chi-squared distribution with effective degrees of freedom
 nu.effective given by
 
  nu.effective =  sum(v[i])^2 / sum((v[i]^2)/nu[i] )
 
  If I recall correctly, with an observed variance s^2 (corresponding to
 the sum(v[i] above if those are observed varianes), nu*(s^2 /sigma^2) is
 distributed as chi-squared with degrees of freedom nu, so the scaling factor
 for quantiles would come out of there (depending whether you're after the
 tail areas for s^2 given sigma^2 or for a confidence interval for sigma^2
 given s^2)
 
  However, I will be most interested to see what a more exact calculation
 provides!
 
  Steve Ellison
 
 
  ***
  This email and any attachments are confidential. Any use,
 co...{{dropped}}
 
  __
  R-help@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.
 
 
 Thomas Lumley Assoc. Professor, Biostatistics
 [EMAIL PROTECTED] University of Washington, Seattle

-- 
Feel free - 10 GB Mailbox, 100 FreeSMS/Monat ...

__
R-help@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.


[R] Tail area of sum of Chi-square variables

2007-03-29 Thread Klaus Nordhausen
Dear R experts, 

I was wondering if there are any R functions that give the tail area
of a sum of chisquare distributions of the type:
 a_1 X_1 + a_2 X_2
where a_1 and a_2 are constants and X_1 and X_2 are independent chi-square 
variables with different degrees of freedom.

Thanks,

Klaus
-- 
Feel free - 5 GB Mailbox, 50 FreeSMS/Monat ...

__
R-help@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.


Re: [R] wireplot margins and additional z-axis

2006-09-13 Thread Klaus Nordhausen
Dear Deepayan,

sorry for not being clear - but my problem has nothing to do with the aspect. 
If I create the eps the following way

library(lattice)
plot.vol- wireframe(volcano,
   aspect = c(1,1.5), 
scales=list(arrows=F),zlab=list(Z-axis,rot=90))

postscript(example_plot_3.eps, width = 14.0/2.54, height = 19.0/2.54,
horizontal = FALSE, onefile = FALSE,paper=special)
trellis.par.set(axis.line,list(alpha=1,col=1,lty=1,lwd=1))
print(plot.vol)
dev.off() 

The plot is still not in the left bottom corner of the file. There is a lot of 
space below the outer box line. If I include this eps in latex it will also 
include this space and if I put for example the figure caption below it I have 
this huge gap between actual graph and caption.

And for comparison, if I create with xyplot an eps like

postscript(example_plot_4.eps, width = 14.0/2.54, height = 19.0/2.54,
horizontal = FALSE, onefile = FALSE,paper=special)

Depth - equal.count(quakes$depth, number=8, overlap=.1)
 plot.depth-xyplot(lat ~ long | Depth, data = quakes)
 update(trellis.last.object(),
strip = strip.custom(strip.names = TRUE, strip.levels = TRUE),
par.strip.text = list(cex = 0.75),
aspect = iso)

print(plot.depth)
dev.off()

the figure is really in the left bottom corner and included in latex has not 
that gap between caption and actual figure.

I hope this describes my problem better.

Klaus



 On 9/12/06, Klaus Nordhausen [EMAIL PROTECTED] wrote:
  Dear Deepayan,
 
  thanks for your reply, the change of the aspect does however not solve
 my problem with the space below the graph on the .eps
  I attached the .eps (still with the old aspect) so that it is maybe
 clearer what my
  problem is.
 
 No, it's not clearer; this is basically the same EPS that I got, so it
 gives me no new information. What do you get with the new aspect? If
 it's not what you want, you'll have to explain what you want more
 clearly. Also, don't make the panel borders transparent, as it makes
 it difficult to understand what's going on.
 
 Deepayan
 
  Any other suggestions?
 
  Klaus
 
 
Dear R experts,
   
it would be very kind if you could help me with two wireplot
 problems.
   
First, when I make a wireplot and transform it into an .eps using
 the
   postscript function the eps-file leaves always a lot of space below
 the plot,
   as if it would leave space for a legend or something like that.
How can i get the plot into the bottom corner without the space
 below?
   The space is not there when I just display the plot in R on my screen
 (I use
   R.2.3.1 on Windows XP). Or in general, how can I get the margins on
 all
   sides as small as possible since I wnat to include the eps into a
 report and
   do not need the space around.
   
The following code has the space on the eps:
   
library(lattice)
 plot.vol - wireframe(volcano, aspect = 1, scales=list(arrows=F)
   ,zlab=list(Z-axis,rot=90))
   
  
   Perhaps you want something like
  
   aspect = c(1, 1.5)
  
   instead.
  
postscript(example_plot.eps, width = 14.0/2.54, height =
 19.0/2.54,
horizontal = FALSE, onefile = FALSE,paper=special)
   
trellis.par.set(axis.line,list(alpha=1,col=1,lty=0,lwd=1))
   
print(plot.vol)
   
dev.off()
   
   
Secondly, is it possible to add to the wireplot a further z-axis. I
   found only how to choose at which veritcal line I want the tickmarks
 and label,
   but is it also possible to have it at two vertical lines?
   
  
   No (but it shouldn't be too hard to add that feature; I'll have to
 check).
  
   Deepayan
  

-- 



Echte DSL-Flatrate ab 0,- Euro* http://www.gmx.net/de/go/dsl

__
R-help@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.


[R] wireplot margins and additional z-axis

2006-09-11 Thread Klaus Nordhausen
Dear R experts,

it would be very kind if you could help me with two wireplot problems.

First, when I make a wireplot and transform it into an .eps using the 
postscript function the eps-file leaves always a lot of space below the plot, 
as if it would leave space for a legend or something like that.
How can i get the plot into the bottom corner without the space below? The 
space is not there when I just display the plot in R on my screen (I use 
R.2.3.1 on Windows XP). Or in general, how can I get the margins on all sides 
as small as possible since I wnat to include the eps into a report and do not 
need the space around.

The following code has the space on the eps:

library(lattice)
 plot.vol - wireframe(volcano, aspect = 1, scales=list(arrows=F) 
,zlab=list(Z-axis,rot=90))

postscript(example_plot.eps, width = 14.0/2.54, height = 19.0/2.54,
horizontal = FALSE, onefile = FALSE,paper=special)

trellis.par.set(axis.line,list(alpha=1,col=1,lty=0,lwd=1))

print(plot.vol)

dev.off()


Secondly, is it possible to add to the wireplot a further z-axis. I found only 
how to choose at which veritcal line I want the tickmarks and label, but is it 
also possible to have it at two vertical lines?

Thank you very much for your help!

Klaus
-- 



Echte DSL-Flatrate ab 0,- Euro* http://www.gmx.net/de/go/dsl

__
R-help@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.