Re: [R] help change auto.key colors in xyplot

2009-02-13 Thread Deepayan Sarkar
On Fri, Feb 13, 2009 at 11:22 AM, Dieter Menne
dieter.me...@menne-biomed.de wrote:
 Dimitri Liakhovitski ld7631 at gmail.com writes:

 the code below works just fine to produce a dotplot. However, I am not
 successful changing the color of the lines in the legend (auto.key).
 If I add col=..., it only changes the color of the letters in the
 legend, but not the color of the lines.

 I prefer to set pch and friends outside the panel function to
 avoid clutter, and to set the parameters globally, thus forcing
 my plots to be similar. This is a matter of taste, though.

 On Windows, the key looks a bit ugly now.

 Group 1 o 
 Group
 2   o-

[That's because the code got wrapped around, breaking Group 2.]

 I am not very happy that the lwd is not honored by the key.
 Lines in lwd 2 (plot) and in lwd 1 (default key) do have a quite
 different subjective color hue. Any way around this, Deepayan?

For the typical situation where you want the same colors for lines and
points, I find the

  par.settings = simpleTheme(col=..., lwd=...)

construct very useful. Also note the slightly different key:

dotplot(c(d[[1]],d[[3]])~rep(d[[2]],2),
groups=rep(c(Group 1,Group 2), each=nrow(d)),
main=list(Chart Title,cex=1),
type=b,

par.settings = simpleTheme(col=c(blue,red),
   pch=20, cex=1.3, lwd=2),
auto.key = list(space = top, points = FALSE,
lines = TRUE, type = b),

xlab=list(Title for X,cex=.9,font=2),
ylab=list(Title for Y,cex=.9,font=2),
panel = function(y,x,...) {
panel.grid(h = -1, v = -1,
   col = gray, lty =dotted)
panel.superpose(x,y,... )
ltext(x, y, labels=round(y,3),cex=.8,col=black,font=2,
  adj=c(-0.2,1))
})

For different colors for lines and points, you do need to be more
verbose, and change the line and symbol settings separately:


trellis.par.set(superpose.line = list(col=c(blue,red), lwd = 2),
superpose.symbol = list(cex = 1.3, pch = 20),
reference.line = list(col = gray, lty =dotted))


dotplot(c(d[[1]],d[[3]])~rep(d[[2]],2),
groups=rep(c(Group 1,Group 2), each=nrow(d)),
main=list(Chart Title,cex=1),
type=b,
auto.key = list(space = top, points = TRUE, lines = TRUE),
xlab=list(Title for X,cex=.9,font=2),
ylab=list(Title for Y,cex=.9,font=2),
panel = function(y,x,...) {
panel.grid(h = -1, v = -1)
panel.xyplot(x, y, ...)
ltext(x, y, labels=round(y,3),
  cex=.8,col=black,font=2,
  adj=c(-0.2,1))
})

-Deepayan

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


Re: [R] help change auto.key colors in xyplot

2009-02-13 Thread hadley wickham
On Fri, Feb 13, 2009 at 1:22 PM, Dieter Menne
dieter.me...@menne-biomed.de wrote:
 Dimitri Liakhovitski ld7631 at gmail.com writes:

 the code below works just fine to produce a dotplot. However, I am not
 successful changing the color of the lines in the legend (auto.key).
 If I add col=..., it only changes the color of the letters in the
 legend, but not the color of the lines.

 I prefer to set pch and friends outside the panel function to
 avoid clutter, and to set the parameters globally, thus forcing
 my plots to be similar. This is a matter of taste, though.

 On Windows, the key looks a bit ugly now.

 Group 1 o 
 Group
 2   o-

 I am not very happy that the lwd is not honored by the key.
 Lines in lwd 2 (plot) and in lwd 1 (default key) do have a quite
 different subjective color hue. Any way around this, Deepayan?

 (Besides using ggplot2, as Hadley would argue ??)

And here is a ggplot2 solution ;)

df - data.frame(
  x = rep(d[[2]], 2),
  y = c(d[[1]], d[[3]]),
  group = rep(c(Group 1, Group 2), each = 3)
)

ggplot(df, aes(x, y, group = group)) +
  geom_point(aes(colour = group), size = 3) +
  geom_line(aes(colour = group), size = 1.5) +
  geom_text(aes(label = y, y = y + 0.02), vjust = 0, size = 4)

The legends are pretty good at figuring out exactly what should be
displayed, based on what you've used in the graphic.

Hadley

-- 
http://had.co.nz/

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


Re: [R] Optimizing Multiple Models...any suggestions?

2009-02-13 Thread Paul Heinrich Dietrich

Hi Max,
Thanks for the suggestion, that's exactly what I was looking for.  Thanks
again.

Paul
-- 
View this message in context: 
http://www.nabble.com/Optimizing-Multiple-Models...any-suggestions--tp21979556p22006494.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] second axis title orientation

2009-02-13 Thread Jörg Groß

Hi,

I have added a second y-axis via axis() to a plot.
Then I tried to add an y axis title.

But the axis() function seems to have no argument like ylab.

and if I add a title with title() the text is centered at the first  
axis, not the second defined one.



Is there a way to add an axis-title that orientates it's position at  
the last defined axis?


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


Re: [R] second axis title orientation

2009-02-13 Thread Gabor Grothendieck
There is an example in:

library(zoo)
example(plot.zoo)

See ?plot.zoo


On Fri, Feb 13, 2009 at 6:19 PM, Jörg Groß jo...@licht-malerei.de wrote:
 Hi,

 I have added a second y-axis via axis() to a plot.
 Then I tried to add an y axis title.

 But the axis() function seems to have no argument like ylab.

 and if I add a title with title() the text is centered at the first axis,
 not the second defined one.


 Is there a way to add an axis-title that orientates it's position at the
 last defined axis?

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


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


[R] PCA functions

2009-02-13 Thread glenn
Hi All, would appreciate an answer on this if you have a moment;

 

Is there a function (before I try and write it !) that allows the input of a
covariance or correlation matrix to calculate PCA, rather than the actual
data as in princomp()

 

Regards

 

Glenn


[[alternative HTML version deleted]]

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


[R] question about tool collisions

2009-02-13 Thread Carl Witthoft
Recently I got introduced to two packages:  {seewave}  and {audio} . 
Turns out they both have a tool to call a system audio tool, and in both 
cases the name of the tool is play().   Naturally these two tools do 
slightly different things with different arguments.


So, what should a user do, and more to the point, what should R do?  If 
I've learned the right things about environments, I could include some 
require() statements inside scripts to guarantee the right things are 
loaded (and only loaded for that script).
But in general when there are two commands with the same name, it means 
that if I distribute code which uses the command, a random user 
elsewhere might have the other package loaded and bad things would happen.



In a perfect world, there would be some R control database that people 
would check packages into.  The database (or some poor volunteer) would 
verify there were no naming conflicts with other posted packages, and so 
on.  Failing that,  what are good rules for fail-safing code, or 
figuring out how to check that some package I've loaded didn't blow away 
some other tools I previously loaded?



Carl

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


Re: [R] second axis title orientation

2009-02-13 Thread Alexandre Swarowsky
?mtext

On Sat, 2009-02-14 at 00:19 +0100, Jörg Groß wrote:
 Hi,
 
 I have added a second y-axis via axis() to a plot.
 Then I tried to add an y axis title.
 
 But the axis() function seems to have no argument like ylab.
 
 and if I add a title with title() the text is centered at the first  
 axis, not the second defined one.
 
 
 Is there a way to add an axis-title that orientates it's position at  
 the last defined axis?
 
 __
 R-help@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.
-- 
Alexandre Swarowsky
Soils and Biogeochemistry Graduate Group
University of California at Davis
One Shields Avenue 
Davis CA 95618
Office: (530)752-4131
cell: (530)574-3028

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


Re: [R] question about tool collisions

2009-02-13 Thread Bert Gunter
See the warn.conflicts arguments of require() and library(). People
thought about this a long time ago.

-- Bert Gunter

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Carl Witthoft
Sent: Friday, February 13, 2009 4:05 PM
To: r-help@r-project.org
Subject: [R] question about tool collisions

Recently I got introduced to two packages:  {seewave}  and {audio} . 
Turns out they both have a tool to call a system audio tool, and in both 
cases the name of the tool is play().   Naturally these two tools do 
slightly different things with different arguments.

So, what should a user do, and more to the point, what should R do?  If 
I've learned the right things about environments, I could include some 
require() statements inside scripts to guarantee the right things are 
loaded (and only loaded for that script).
But in general when there are two commands with the same name, it means 
that if I distribute code which uses the command, a random user 
elsewhere might have the other package loaded and bad things would happen.


In a perfect world, there would be some R control database that people 
would check packages into.  The database (or some poor volunteer) would 
verify there were no naming conflicts with other posted packages, and so 
on.  Failing that,  what are good rules for fail-safing code, or 
figuring out how to check that some package I've loaded didn't blow away 
some other tools I previously loaded?


Carl

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

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


Re: [R] Bootstrap or Wilcoxons' test?

2009-02-13 Thread Murray Cooper

Charlotta,

I'm not sure what you mean when you say simple linear
regression. From your description you have two groups
of people, for which you recorded contaminant concentration.
Thus, I would think you would do something like a t-test to
compare the mean concentration level. Where does the
regression part come in? What are you regressing?

As for the Wilcoxnin test, it is often thought of as a
nonparametric t-test equivalent. This is only true if the
observations were drawn, from a population with the
same probability distribution. The null hypothesis of
the Wilcoxin test is actually the observations were
drawn, from the same probability distribution.
Thus if your two samples had say different variances,
there means could be the same, but since the variances
are different, the Wilcoxin could give you a significant result.

Don't know if this all makes sense, but if you have more
questions, please e-mail your data and a more detailed
description of what analysis you used and I'd be happy
to try and help out.

Murray M Cooper, Ph.D.
Richland Statistics
9800 N 24th St
Richland, MI, USA 49083
Mail: richs...@earthlink.net

- Original Message - 
From: Charlotta Rylander z...@nilu.no

To: r-help@r-project.org
Sent: Friday, February 13, 2009 3:24 AM
Subject: [R] Bootstrap or Wilcoxons' test?



Hi!



I'm comparing the differences in contaminant concentration between 2
different groups of people ( N=36, N=37). When using a simple linear
regression model I found no differences between groups, but when 
evaluating

the diagnostic plots of the residuals I found my independent variable to
have deviations from normality (even after log transformation). Therefore 
I

have used bootstrap on the regression parameters ( R= 1000  R=1) and
this confirms my results , i.e., no differences between groups ( and the
distribution is log-normal). However, when using wilcoxons' rank sum test 
on

the same data set I find differences between groups.



Should I trust the results from bootstrapping or from wilcoxons' test?



Thanks!



Regards



Lotta Rylander


[[alternative HTML version deleted]]

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



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


Re: [R] question about tool collisions

2009-02-13 Thread Marc Schwartz
on 02/13/2009 06:05 PM Carl Witthoft wrote:
 Recently I got introduced to two packages:  {seewave}  and {audio} .
 Turns out they both have a tool to call a system audio tool, and in both
 cases the name of the tool is play().   Naturally these two tools do
 slightly different things with different arguments.
 
 So, what should a user do, and more to the point, what should R do?  If
 I've learned the right things about environments, I could include some
 require() statements inside scripts to guarantee the right things are
 loaded (and only loaded for that script).
 But in general when there are two commands with the same name, it means
 that if I distribute code which uses the command, a random user
 elsewhere might have the other package loaded and bad things would happen.
 
 
 In a perfect world, there would be some R control database that people
 would check packages into.  The database (or some poor volunteer) would
 verify there were no naming conflicts with other posted packages, and so
 on.  Failing that,  what are good rules for fail-safing code, or
 figuring out how to check that some package I've loaded didn't blow away
 some other tools I previously loaded?

In addition to Bert's excellent recommendation (as well as ?conflicts),
this is one of the key reasons for using namespaces.

It would appear, from a review of the tarballs for both packages, that
audio is using a namespace, but seewave does not. You might make a
recommendation to the latter's author to implement a namespace for his
package. That would help avoid the collisions in third party code.

audio does export the play() function, so you can use:

  audio::play(...)

to differentiate that function from:

  seewave::play(...)

None of this is a guarantee of course, if other play() functions should
be loaded or come into being, which is why namespaces are a safer approach.

See also:

  http://cran.r-project.org/doc/manuals/R-intro.html#Namespaces

HTH,

Marc Schwartz

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


[R] Outlier Detection for timeseries

2009-02-13 Thread Pele

Hello R users,

Can someone tell if there is a package in R that can do outlier detection
that give outputs simiilar to what I got from SAS  below.

Many thanks in advance for any help!

  Outlier Details
   
Approx
Chi-
Prob
   ObsTime ID Type  Estimate  Square
ChiSq

12   12.00Additive 2792544.6  186.13   
.0001
13   13.00Additive  954302.1   21.23   
.0001
15   15.00Shift63539.3   
9.060.0026

-- 
View this message in context: 
http://www.nabble.com/Outlier-Detection-for-timeseries-tp22008448p22008448.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Bootstrap or Wilcoxons' test?

2009-02-13 Thread David Winsemius
I must disagree with both this general characterization of the  
Wilcoxon test and with the specific example offered. First, we ought  
to spell the author's correctly and then clarify that it is the  
Wilcoxon rank-sum test that is being considered. Next, the WRS test is  
a test for differences in the location parameter of independent  
samples conditional on the samples having been drawn from the same  
distribution. The WRS test would have no discriminatory power for  
samples drawn from the same distribution having equal location  
parameters but only different with respect to unequal dispersion. Look  
at the formula, for Pete's sake. It summarizes differences in ranking,  
so it is in fact designed NOT to be sensitive to the spread of the  
values in the sample. It would have no power, for instance, to test  
the variances of two samples, both with a mean of 0, and one having a  
variance of 1 with the other having a variance of 3.  One can think of  
the WRS as a test for unequal medians.


--
David Winsemius, MD. MPH
Heritage Laboratories


On Feb 13, 2009, at 7:48 PM, Murray Cooper wrote:


Charlotta,

I'm not sure what you mean when you say simple linear
regression. From your description you have two groups
of people, for which you recorded contaminant concentration.
Thus, I would think you would do something like a t-test to
compare the mean concentration level. Where does the
regression part come in? What are you regressing?

As for the Wilcoxnin test, it is often thought of as a
nonparametric t-test equivalent. This is only true if the
observations were drawn, from a population with the
same probability distribution. The null hypothesis of
the Wilcoxin test is actually the observations were
drawn, from the same probability distribution.
Thus if your two samples had say different variances,
there means could be the same, but since the variances
are different, the Wilcoxin could give you a significant result.

Don't know if this all makes sense, but if you have more
questions, please e-mail your data and a more detailed
description of what analysis you used and I'd be happy
to try and help out.

Murray M Cooper, Ph.D.
Richland Statistics
9800 N 24th St
Richland, MI, USA 49083
Mail: richs...@earthlink.net

- Original Message - From: Charlotta Rylander z...@nilu.no
To: r-help@r-project.org
Sent: Friday, February 13, 2009 3:24 AM
Subject: [R] Bootstrap or Wilcoxons' test?



Hi!



I'm comparing the differences in contaminant concentration between 2
different groups of people ( N=36, N=37). When using a simple linear
regression model I found no differences between groups, but when  
evaluating
the diagnostic plots of the residuals I found my independent  
variable to
have deviations from normality (even after log transformation).  
Therefore I
have used bootstrap on the regression parameters ( R= 1000   
R=1) and
this confirms my results , i.e., no differences between groups  
( and the
distribution is log-normal). However, when using wilcoxons' rank  
sum test on

the same data set I find differences between groups.



Should I trust the results from bootstrapping or from wilcoxons'  
test?




Thanks!



Regards



Lotta Rylander


[[alternative HTML version deleted]]

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



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


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


Re: [R] Bootstrap or Wilcoxons' test?

2009-02-13 Thread Murray Cooper

First of all, sorry for my typing mistakes.

Second, the WRS test is most certainly not a test for unequal medians.
Although under specified models it would be. Just as under specified
models it can be a test for other measures of location. Perhaps I did not
word my explanation correctly, but I did not mean to imply that it would
be a test of equality of variance. It is plain and simple a test for the 
equality

of distributions. When the results of a properly applied parametric test do
not agree with the WRS, it is usually do to a difference in the empirical
density function of the two samples.

Murray M Cooper, Ph.D.
Richland Statistics
9800 N 24th St
Richland, MI, USA 49083
Mail: richs...@earthlink.net

- Original Message - 
From: David Winsemius dwinsem...@comcast.net

To: Murray Cooper myrm...@earthlink.net
Cc: Charlotta Rylander z...@nilu.no; r-help@r-project.org
Sent: Friday, February 13, 2009 9:19 PM
Subject: Re: [R] Bootstrap or Wilcoxons' test?


I must disagree with both this general characterization of the  Wilcoxon 
test and with the specific example offered. First, we ought  to spell the 
author's correctly and then clarify that it is the  Wilcoxon rank-sum test 
that is being considered. Next, the WRS test is  a test for differences in 
the location parameter of independent  samples conditional on the samples 
having been drawn from the same  distribution. The WRS test would have no 
discriminatory power for  samples drawn from the same distribution having 
equal location  parameters but only different with respect to unequal 
dispersion. Look  at the formula, for Pete's sake. It summarizes 
differences in ranking,  so it is in fact designed NOT to be sensitive to 
the spread of the  values in the sample. It would have no power, for 
instance, to test  the variances of two samples, both with a mean of 0, and 
one having a  variance of 1 with the other having a variance of 3.  One can 
think of  the WRS as a test for unequal medians.


--
David Winsemius, MD. MPH
Heritage Laboratories


On Feb 13, 2009, at 7:48 PM, Murray Cooper wrote:


Charlotta,

I'm not sure what you mean when you say simple linear
regression. From your description you have two groups
of people, for which you recorded contaminant concentration.
Thus, I would think you would do something like a t-test to
compare the mean concentration level. Where does the
regression part come in? What are you regressing?

As for the Wilcoxnin test, it is often thought of as a
nonparametric t-test equivalent. This is only true if the
observations were drawn, from a population with the
same probability distribution. The null hypothesis of
the Wilcoxin test is actually the observations were
drawn, from the same probability distribution.
Thus if your two samples had say different variances,
there means could be the same, but since the variances
are different, the Wilcoxin could give you a significant result.

Don't know if this all makes sense, but if you have more
questions, please e-mail your data and a more detailed
description of what analysis you used and I'd be happy
to try and help out.

Murray M Cooper, Ph.D.
Richland Statistics
9800 N 24th St
Richland, MI, USA 49083
Mail: richs...@earthlink.net

- Original Message - From: Charlotta Rylander z...@nilu.no
To: r-help@r-project.org
Sent: Friday, February 13, 2009 3:24 AM
Subject: [R] Bootstrap or Wilcoxons' test?



Hi!



I'm comparing the differences in contaminant concentration between 2
different groups of people ( N=36, N=37). When using a simple linear
regression model I found no differences between groups, but when 
evaluating
the diagnostic plots of the residuals I found my independent  variable 
to
have deviations from normality (even after log transformation). 
Therefore I
have used bootstrap on the regression parameters ( R= 1000   R=1) 
and
this confirms my results , i.e., no differences between groups  ( and 
the
distribution is log-normal). However, when using wilcoxons' rank  sum 
test on

the same data set I find differences between groups.



Should I trust the results from bootstrapping or from wilcoxons'  test?



Thanks!



Regards



Lotta Rylander


[[alternative HTML version deleted]]

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



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





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

[R] several ifelse problems...

2009-02-13 Thread kathie

Dear R users,

From the code below, I try to compute y value. (In fact, y looks like a
trapezoid)

--

x - seq(0,1,.01) 
y - ifelse(abs(x-.5)=0.3,0,
ifelse(abs(w-.5)=0.4,-1, 
   ifelse((0.1w  w0.2),10*x-2,-10*x+8)))

--

So, results are...

--
 x
  [1] 0.00 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.10 0.11 0.12 0.13
0.14
 [16] 0.15 0.16 0.17 0.18 0.19 0.20 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28
0.29
 [31] 0.30 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.40 0.41 0.42 0.43
0.44
 [46] 0.45 0.46 0.47 0.48 0.49 0.50 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58
0.59
 [61] 0.60 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.70 0.71 0.72 0.73
0.74
 [76] 0.75 0.76 0.77 0.78 0.79 0.80 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88
0.89
 [91] 0.90 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.00

 y
  [1] -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1  8  8  8  8  8  8  8  8  8  0  0  0 
0  0
 [26]  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 
0  0
 [51]  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 
0  0
 [76]  0  0  0  0  0  8  8  8  8  8  8  8  8  8  8 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1
[101] -1
 

--

However, even though the results show that y=8 for x=0.11, when x=0.11,
actual y value is -0.9.  And, y=-0.8 for x=0.88.  I cannot understand the
above results.

Any comments will be greatly appreciated.

Kathryn Lord
-- 
View this message in context: 
http://www.nabble.com/several-%22ifelse%22-problems...-tp22009321p22009321.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Bootstrap or Wilcoxons' test?

2009-02-13 Thread Daniel Malter
 
Hi Charlotta, to be more constructive toward your goal. If you bootstrap the
regression when the regression is ill-specified, the bootstrap may not help
you. Further, a test as difficult as a regression does not seem to be
necessary in your case. A t-test if your dependent variable is
(approxiamately) normal for both groups and if variances are equal or a
Wilcoxon test if your dependent variable is not normal should do. 

The bootstrap should be very powerful if you do NOT perform it on the
regression (again, bootstrapping the regression may just mean to do the
wrong thing over and over again, which is no improvement). Just bootstrap
sample means for the two groups and compare them appropriately (see:
http://www.stat.berkeley.edu/users/rodwong/Stat131a/boot_diff_twomeans.pdf
). Otherwise, rely on the result of the Wilcoxon test as it is likely more
appropriate if your dependent variable is not normal in the two groups.

Daniel

-
cuncta stricte discussurus
-

-Ursprüngliche Nachricht-
Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im
Auftrag von David Winsemius
Gesendet: Friday, February 13, 2009 9:19 PM
An: Murray Cooper
Cc: r-help@r-project.org
Betreff: Re: [R] Bootstrap or Wilcoxons' test?

I must disagree with both this general characterization of the Wilcoxon test
and with the specific example offered. First, we ought to spell the author's
correctly and then clarify that it is the Wilcoxon rank-sum test that is
being considered. Next, the WRS test is a test for differences in the
location parameter of independent samples conditional on the samples having
been drawn from the same distribution. The WRS test would have no
discriminatory power for samples drawn from the same distribution having
equal location parameters but only different with respect to unequal
dispersion. Look at the formula, for Pete's sake. It summarizes differences
in ranking, so it is in fact designed NOT to be sensitive to the spread of
the values in the sample. It would have no power, for instance, to test the
variances of two samples, both with a mean of 0, and one having a variance
of 1 with the other having a variance of 3.  One can think of the WRS as a
test for unequal medians.

--
David Winsemius, MD. MPH
Heritage Laboratories


On Feb 13, 2009, at 7:48 PM, Murray Cooper wrote:

 Charlotta,

 I'm not sure what you mean when you say simple linear
 regression. From your description you have two groups
 of people, for which you recorded contaminant concentration.
 Thus, I would think you would do something like a t-test to
 compare the mean concentration level. Where does the
 regression part come in? What are you regressing?

 As for the Wilcoxnin test, it is often thought of as a
 nonparametric t-test equivalent. This is only true if the
 observations were drawn, from a population with the
 same probability distribution. The null hypothesis of
 the Wilcoxin test is actually the observations were
 drawn, from the same probability distribution.
 Thus if your two samples had say different variances,
 there means could be the same, but since the variances
 are different, the Wilcoxin could give you a significant result.

 Don't know if this all makes sense, but if you have more
 questions, please e-mail your data and a more detailed
 description of what analysis you used and I'd be happy
 to try and help out.

 Murray M Cooper, Ph.D.
 Richland Statistics
 9800 N 24th St
 Richland, MI, USA 49083
 Mail: richs...@earthlink.net

 - Original Message - From: Charlotta Rylander z...@nilu.no
 To: r-help@r-project.org
 Sent: Friday, February 13, 2009 3:24 AM
 Subject: [R] Bootstrap or Wilcoxons' test?


 Hi!



 I'm comparing the differences in contaminant concentration between 2
 different groups of people ( N=36, N=37). When using a simple linear
 regression model I found no differences between groups, but when  
 evaluating
 the diagnostic plots of the residuals I found my independent  
 variable to
 have deviations from normality (even after log transformation).  
 Therefore I
 have used bootstrap on the regression parameters ( R= 1000   
 R=1) and
 this confirms my results , i.e., no differences between groups  
 ( and the
 distribution is log-normal). However, when using wilcoxons' rank  
 sum test on
 the same data set I find differences between groups.



 Should I trust the results from bootstrapping or from wilcoxons'  
 test?



 Thanks!



 Regards



 Lotta Rylander


 [[alternative HTML version deleted]]

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


 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting 

Re: [R] Outlier Detection for timeseries

2009-02-13 Thread stephen sefick
what are you looking for?  I am not familiar with SAS as I am a poor
scientist.  I am not promising anything, but if you were to tell me
what you wanted - method etc. I may know of a package or something
that would work.

Stephen

On Fri, Feb 13, 2009 at 9:16 PM, Pele drdi...@yahoo.com wrote:

 Hello R users,

 Can someone tell if there is a package in R that can do outlier detection
 that give outputs simiilar to what I got from SAS  below.

 Many thanks in advance for any help!

  Outlier Details

 Approx
Chi-
 Prob
   ObsTime ID Type  Estimate  Square
 ChiSq

12   12.00Additive 2792544.6  186.13
 .0001
13   13.00Additive  954302.1   21.23
 .0001
15   15.00Shift63539.3
 9.060.0026

 --
 View this message in context: 
 http://www.nabble.com/Outlier-Detection-for-timeseries-tp22008448p22008448.html
 Sent from the R help mailing list archive at Nabble.com.

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




-- 
Stephen Sefick

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

-K. Mullis

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


[R] superscript

2009-02-13 Thread David Douterlungne


Dear R-users. 
 
I'm struggeling to fix the superscript of a label of a figure axis. For some 
reason R doesn't recognize the hat symbol. 
   
 
  plot(1,1,xlab=ligth intensity (PAR),ylab=expression(mass Pteridium 
rhizomes (gr/0.25m^2)))
 
 
A very similiar scriptline does not give any problem at all: 
 
 plot(1,1,xlab=expression(balsa plot basal area (m^2/ha)),ylab=light 
intensity (PAR))
 
 
Someone?
_

s. It's easy!

aspxmkt=en-us
__
R-help@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.


Re: [R] superscript

2009-02-13 Thread Daniel Moreira
Try:

plot(1,1,xlab=ligth intensity (PAR),ylab=expression(mass Pteridium 
rhizomes (gr/0.25*m^2)))


Daniel Moreira, MD

Research Associate
Duke University Medical Center
DUMC 2626, MSRB-I Room 455
571 Research Drive
Durham, North Carolina 27710
Telephone: (919) 681-7132
Fax: (919) 668-7093
E-mail: daniel.more...@duke.edu




David Douterlungne daviddou...@hotmail.com 
Sent by: r-help-boun...@r-project.org
02/14/2009 12:21 AM

To
r-help@r-project.org
cc

Subject
[R] superscript








Dear R-users. 
 
I'm struggeling to fix the superscript of a label of a figure axis. For 
some reason R doesn't recognize the hat symbol. 
 
 
  plot(1,1,xlab=ligth intensity (PAR),ylab=expression(mass Pteridium 
rhizomes (gr/0.25m^2)))
 
 
A very similiar scriptline does not give any problem at all: 
 
 plot(1,1,xlab=expression(balsa plot basal area (m^2/ha)),ylab=light 
intensity (PAR))
 
 
Someone?
_

s. It's easy!

aspxmkt=en-us
__
R-help@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.


[[alternative HTML version deleted]]

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


Re: [R] several ifelse problems...

2009-02-13 Thread Berwin A Turlach
Dear Kathie,

On Fri, 13 Feb 2009 21:08:25 -0800 (PST)
kathie kathryn.lord2...@gmail.com wrote:

 Dear R users,
 [snip]
 
 However, even though the results show that y=8 for x=0.11, when
 x=0.11, actual y value is -0.9.  And, y=-0.8 for x=0.88.  I cannot
 understand the above results.

It may help you to understand those results when you look at the
difference between
0.1  x  x  0.2
and
0.1  x  x  0.2

Your code used the latter but I strongly suspect you wanted the former.

HTH.

Best wishes,

Berwin

=== Full address =
Berwin A TurlachTel.: +65 6516 4416 (secr)
Dept of Statistics and Applied Probability+65 6516 6650 (self)
Faculty of Science  FAX : +65 6872 3919   
National University of Singapore 
6 Science Drive 2, Blk S16, Level 7  e-mail: sta...@nus.edu.sg
Singapore 117546http://www.stat.nus.edu.sg/~statba

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


Re: [R] Bootstrap or Wilcoxons' test?

2009-02-13 Thread David Winsemius
The Wilcoxon rank sum test is not plain and simple a test equality of  
distributions. If it were such, it would be able to test for  
differences in variance when locations were similar. For that purpose  
it would, in point of fact, be useless. Compare these simple  
situations w.r.t. the WRS:


 x - rnorm(100)  # mean=0, sd=1
 y - rnorm(100, mean=0, sd=4)
 wilcox.test(x,y)

Wilcoxon rank sum test with continuity correction

data:  x and y
W = 4518, p-value = 0.2394
alternative hypothesis: true location shift is not equal to 0

 y - rnorm(100, mean=.2, sd=0)

 wilcox.test(x,y)

Wilcoxon rank sum test with continuity correction

data:  x and y
W = 3900, p-value = 0.004079
alternative hypothesis: true location shift is not equal to 0

It is a test of the equality of location (and the median is a readily  
understood non-parametric measure of location). The test is derived  
under the *assumption* that the samples are drawn from the *same*  
distribution differing only by a shift. If the distributions were not  
of the same family, the test would be invalidated. The wilcox.test  
help page is informative, saying the null hypothesis is that the  
distributions of xand y differ by a location shift of mu. The  
pseudomedian is optionally estimated when conf.int is set to TRUE. I  
also suggest looking at the formula for the statistic. It is available  
with getAnywhere(wilcox.test.default).


If one wants a test for equality of distribution, one could turn to  
a more general test (with loss of power but with at least some  
potential for detecting differences in dispersion) such as the  
Kolmogorov-Smirnov or Kuiper tests. With x and y as above:


 ks.test(x,y)

Two-sample Kolmogorov-Smirnov test

data:  x and y
D = 0.61, p-value  2.2e-16
alternative hypothesis: two-sided

Warning message:
In ks.test(x, y) : cannot compute correct p-values with ties

Returning to the OP's question, rather than worrying about normality  
in samples, the greater threat to validity in regression methods is  
unequal variances across groups or the range of continuous predictors.


--
David Winsemius

On Feb 13, 2009, at 11:12 PM, Murray Cooper wrote:


First of all, sorry for my typing mistakes.

Second, the WRS test is most certainly not a test for unequal medians.
Although under specified models it would be. Just as under specified
models it can be a test for other measures of location. Perhaps I  
did not
word my explanation correctly, but I did not mean to imply that it  
would
be a test of equality of variance. It is plain and simple a test for  
the equality
of distributions. When the results of a properly applied parametric  
test do
not agree with the WRS, it is usually do to a difference in the  
empirical

density function of the two samples.

Murray M Cooper, Ph.D.
Richland Statistics
9800 N 24th St
Richland, MI, USA 49083
Mail: richs...@earthlink.net

- Original Message - From: David Winsemius dwinsem...@comcast.net 


To: Murray Cooper myrm...@earthlink.net
Cc: Charlotta Rylander z...@nilu.no; r-help@r-project.org
Sent: Friday, February 13, 2009 9:19 PM
Subject: Re: [R] Bootstrap or Wilcoxons' test?


I must disagree with both this general characterization of the   
Wilcoxon test and with the specific example offered. First, we  
ought  to spell the author's correctly and then clarify that it is  
the  Wilcoxon rank-sum test that is being considered. Next, the WRS  
test is  a test for differences in the location parameter of  
independent  samples conditional on the samples having been drawn  
from the same  distribution. The WRS test would have no  
discriminatory power for  samples drawn from the same distribution  
having equal location  parameters but only different with respect  
to unequal dispersion. Look  at the formula, for Pete's sake. It  
summarizes differences in ranking,  so it is in fact designed NOT  
to be sensitive to the spread of the  values in the sample. It  
would have no power, for instance, to test  the variances of two  
samples, both with a mean of 0, and one having a  variance of 1  
with the other having a variance of 3.  One can think of  the WRS  
as a test for unequal medians.


--
David Winsemius, MD. MPH
Heritage Laboratories


On Feb 13, 2009, at 7:48 PM, Murray Cooper wrote:


Charlotta,

I'm not sure what you mean when you say simple linear
regression. From your description you have two groups
of people, for which you recorded contaminant concentration.
Thus, I would think you would do something like a t-test to
compare the mean concentration level. Where does the
regression part come in? What are you regressing?

As for the Wilcoxnin test, it is often thought of as a
nonparametric t-test equivalent. This is only true if the
observations were drawn, from a population with the
same probability distribution. The null hypothesis of
the Wilcoxin test is actually the observations were
drawn, from the same probability distribution.
Thus if your two 

<    1   2