Re: [R] OC curve in Quality Control

2003-12-26 Thread Philippe Glaziou
WilDscOp [EMAIL PROTECTED] wrote:
 Can anyone please help me about any of the following questions:
 
 1. How can i find factorial of any number in R? I tried
prod(170:1) # to find factorial of 170 or 170!
 Is it the only procedure - or R has any better process / operational 
 character to calculate factorial? Also, is it possible to calculate 
 factorial of 500? Or is there any statistical table available for this?


 gamma(x+1) # gives x! 

As for the factorial of 500, I would go for a log transformation:

 lgamma(501)
[1] 2611.330

But if you really need to see all the digits of 500!, PARI
http://pari.math.u-bordeaux.fr/ --or rather its shell, may be
called from within R. It returns all digits of that large number
in a fraction of a second on my old laptop:

 system.time(system(echo '500!' | gp))
[...]
%1 = 12201368259911100687012387854230469262535743428031928421
9241358838584537315388199760549644750220328186301361647714820
[about a thousand other digits follow]
Good bye!
[1] 0.00 0.00 0.05 0.03 0.02


For a more readable output:

 system(echo '500!*1.0' | gp)
[...]
%1 = 1.220136825991110068701238785 E1134



 
 2. Is there any direct procedure / package in R to find permutation / 
 combination?


To permute the elements of a vector, you may use:

 perm - function(v)sample(v,size=length(v),replace=FALSE)
 v - 1:8
 v
[1] 1 2 3 4 5 6 7 8
 set.seed(101)
 perm(v)
[1] 3 1 5 4 7 6 2 8


Re combinations, does the function choose() do what you are
looking for?

 
 3. Can i find Probability Density of Hypergeometric Disribution in R, 
 given all values of the parameter? I can not find any table of 
 Hypergeometric Disribution (if such tables are available on the internet, 
 please let me know).

Does dhyper() do what you are looking for? 

-- 
Philippe Glaziou
Epidemiologist

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Sweave question

2003-12-26 Thread Jason Turner
Rafael A. Irizarry wrote:

Using Sweave in the tools library (R version 1.8.0: sorry i havent 
upgraded), it seems i cant use if statements in R chunks that make graphs. 
i have this:

fig=TRUE,echo=F=
par(mfrow=c(1,1))
if(exists(x)) 
	plot(x,x)
else{
  plot(1,1,type=n)
  text(1,1,data not available.\n)
}
@

and I get this error:

Error:  chunk 6
Error in parse(file, n, text, prompt) : parse error
any help is appreciated.

Whenever you get an error message, copy and paste it into an R session 
(interactive) and see what happens.  At least then you'll know where the 
problem is, and whether it's a Sweave problem or a problem with your R 
syntax (in this case, it's the second option. sorry).

This problem is almost, but not quite, a FAQ.

The problem is that the if(...) is syntactically complete after the 
first plot() command.  The else { appears out of nowhere, as far as 
the R interpreter is concerned, and this makes no sense.

The fixes:

1) Always do this:

if(something) {
  do something
} else {
  do something else
}
Note exactly (!) where the curly braces are, relative to the else.

2) wrap the whole thing in curly braces.

{
   if(something)
 do somthing
   else {
 do something else
   }
}
Cheers

Jason

--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Plot a sphere

2003-12-26 Thread Uwe Ligges


Spencer Graves wrote:
 
   A hemisphere is relatively easy;  try the following:
 
   x - seq(-1, 1, length=21)
   Z - outer(x, x, function(x, y)sqrt(1-x^2-y^2))
   persp(x=x, y=x, z=Z)
 
   A contour plot is also relatively easy:
 
   image(x=x, y=x, z=Z)
   contour(x=x, y=x, z=Z, add=T)
 
   However, if you want an honest perspective plot of a sphere
 complete with the underside, etc., I know of nothing in R that could do
 that.  S-Plus has perspp, which could be used.  However, that seems to
 be one of the few features available in S-Plus that is not currently
 available in R.


The R package rgl by Adler and Nenadic can plot spheres. It is
available at 
http://wsopuppenkiste.wiso.uni-goettingen.de/~dadler/rgl/
 --- and looks like it will shortly become a CRAN package.

Uwe Ligges


hope this helps.
   spencer graves
 
 Derick Schoonbee wrote:
 
  Hi,
 
  I'm new to R (and math ;) Would somebody please be so kind as to
  direct me in plotting a 3D sphere?
 
  I tried something in the lines of:
  
  y - x - seq(-pi, pi, length=pi*10)
  f - function(x,y)
  {
  z - sqrt(pi - x^2 - y^2)
  #z[is.na(z)] - 0
  z
  }
  z - outer(x, y, f)
 
  persp(x, y, z, theta = 120, phi = 30)
  
 
  I've also tried:  make.surface.grid(...) .. persp( as.surface(
  grid, z) ) ... with the same result: 'Incomplete' demi sphere and
  others..
 
  Any suggestions/solutions would be appreaciated.
 
  Regards,
  Derick
 
  PS:Merry X-mas ;)
 
  __
  [EMAIL PROTECTED] mailing list
  https://www.stat.math.ethz.ch/mailman/listinfo/r-help
 
 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Plot a sphere

2003-12-26 Thread Derick Schoonbee
Thanks for the reply. The results are exactly the same as what I'm getting.
Now I'm thinking in the lines of:
z1 - outer(x, y, f)
z2 - -outer(x, y, f)
So, I want to attach the two hemispheres. But then I need to figure out how 
append vectors z1  z2 and then 'feed' this to persp..

hmm, I'll look into it.

Regards,
D.
From: Spencer Graves [EMAIL PROTECTED]
To: Derick Schoonbee [EMAIL PROTECTED]
CC: [EMAIL PROTECTED]
Subject: Re: [R] Plot a sphere
Date: Thu, 25 Dec 2003 17:38:01 -0800
 A hemisphere is relatively easy;  try the following:

 x - seq(-1, 1, length=21)
 Z - outer(x, x, function(x, y)sqrt(1-x^2-y^2))
 persp(x=x, y=x, z=Z)
 A contour plot is also relatively easy:

 image(x=x, y=x, z=Z)
 contour(x=x, y=x, z=Z, add=T)
 However, if you want an honest perspective plot of a sphere complete 
with the underside, etc., I know of nothing in R that could do that.  S-Plus 
has perspp, which could be used.  However, that seems to be one of the few 
features available in S-Plus that is not currently available in R.

  hope this helps.  spencer graves

Derick Schoonbee wrote:

Hi,

I'm new to R (and math ;) Would somebody please be so kind as to direct me 
in plotting a 3D sphere?

I tried something in the lines of:

y - x - seq(-pi, pi, length=pi*10)
f - function(x,y)
{
z - sqrt(pi - x^2 - y^2)
#z[is.na(z)] - 0
z
}
z - outer(x, y, f)
persp(x, y, z, theta = 120, phi = 30)

I've also tried:  make.surface.grid(...) .. persp( as.surface( grid, z) 
) ... with the same result: 'Incomplete' demi sphere and others..

Any suggestions/solutions would be appreaciated.

Regards,
Derick
PS:Merry X-mas ;)

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Problems converting output from Sweave to PDf

2003-12-26 Thread Uwe Ligges


Thon de Boer wrote:
 
 I am having trouble converting the output from Sweave
 into a valid PDF file.
 
 I have created a simple .Rnw file which will become a
 full vignette at some point, but during the
 intermediate testing, I got errors from texi2dvi.
 This is what I have done.
 
 0) Using a Windows Xp system
 1) Created a file called GeneSpring.Rnw
 2) Convert this to Tex using Sweave(GeneSpring.Rnw)
 from within R
 3) Since I don't have LATEX for windows, I used
 texi2dvi from the CYGWIN package
 4) When I run the command in Cygwin 'texi2dvi -c -p
 GeneSpring.tex' I get the error shown below.
 5) When I edit the GeneSpring.tex file and comment out
 the line
 
 \usepackage{C:/PROGRA~1/SILICO~1/GENESP~1/data/rw1081/share/texmf/Sweave}

Well, cygwin misinterprets the path. Specify it in a way cygwin
understands, e.g.:
/cygdrive/c/.
or even better, install a LaTeX environment for Windows.

Uwe Ligges




 and try to convert to PDF again, it will successfully
 convert the TEX file to PDF.
 
 It seems that the Sweave library causes some problems
 in the parsing of the TEX file. Is there something I
 forgot to do?
 
 Thanks,
 
 Thon
 
 - OUTPUT FROM texi2dvi -
 
 /usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/cygdrive/c/Perl/bin/:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/Program
 Files/ATI Technologies/ATI Control
 Panel:/cygdrive/c/Program Files/Common Files/Adaptec
 Shared/System:/cygdrive/c/Program
 Files/TEC100/BIN:/cygdrive/c/Program
 Files/bin:/cygdrive/c/Program
 Files/SiliconGenetics/GeneSpring/data/rw1081/bin
 This is pdfTeXk, Version 3.14159-1.10b (Web2C 7.4.5)
  %-line parsing enabled.
 (/tmp/GeneSpring.tex{/usr/share/texmf/pdftex/config/pdftex.cfg}
 LaTeX2e 2001/06/01
 Babel v3.7h and hyphenation patterns for american,
 french, german, ngerman, n
 ohyphenation, loaded.
 (/usr/share/texmf/tex/latex/base/article.cls
 Document Class: article 2001/04/21 v1.4e Standard
 LaTeX document class
 (/usr/share/texmf/tex/latex/base/size10.clo))
 ! Missing \endcsname inserted.
 to be read again
\protect
 l.9 \begin
   {document}
 ?
 
 ! LaTeX Error: Missing \begin{document}.
 
 See the LaTeX manual or LaTeX Companion for
 explanation.
 Type  H return  for immediate help.
  ...
 
 l.9 \begin
   {document}
 ?
 
 -- TEX FILE --
 
 % \VignetteIndexEntry{GeneSpring contents}
 % \VignetteDepends{GeneSpring}
 % \VignetteKeywords{Interface}
 % \VignettePackage{GeneSpring}
 
 \documentclass{article}
 
 \usepackage{C:/PROGRA~1/SILICO~1/GENESP~1/data/rw1081/share/texmf/Sweave}
 \begin{document}
 
 \author{Thon de Boer}
 
 \title{Using R with GeneSpring}
 
 \maketitle
 
 \copyright{2003 Silicon Genetics}
 
 \section{Introduction}
 
 This package contains a number of functions to
 facilitate the integration
 of R code into the Gene Expression analysis program
 GeneSpring, by Silicon Genetics.
 Available functions include:
 
 \begin{itemize}
 \item \texttt{GSload.int()} - Read GeneSpring
 experiment interpretation from file and return a
 GeneSpring gene expression object (GSint)
 \item \texttt{GSload.intBC()} - Read GeneSpring
 experiment interpretation from file and return a
 BioConductor gene expressioon object (exprSet)
 \item \texttt{GSload.exp()} - Read GeneSpring
 experiment from file and return a GeneSpring gene
 expression object (GSint)
 \item \texttt{GSload.expBC()} - Read GeneSpring
 experiment from file and return a BioConductor gene
 expressioon object (exprSet)
 \item \texttt{GSint()} - Create a GeneSpring gene
 expression object (GSint)
 \item \texttt{GSint2BC()} - Convert a GeneSpring gene
 expression object (GSint) to a BioConductor gene
 expression object (exprSet)
 \item \texttt{BC2GSint()} - Convert a BioConductor
 gene expression object (exprSet) to a GeneSpring gene
 expression object (GSint)
 \item \texttt{GSload.genelist()} - Read a GeneSpring
 GeneSpring gene list from file
 \item \texttt{GSsave.genelist()} - Save a GeneSpring
 GeneSpring gene list to file
 \item \texttt{GSsave.exp()} - Save a GeneSpring gene
 expression object (GSint) to file
 \end{itemize}
 
 For more information on using thi spackage with
 GeneSpring, go to the Silicon Genetics website.
 
 \end{document}
 
 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] Plot a sphere

2003-12-26 Thread Branimir K. Hackenberger
To plot the sphere in R I find the best scatterplot3d package as
follows:

library(scatterplot3d)
a=seq(-pi,pi, length=100)
x=c(rep(1, 100) %*% t(cos(a)))
y=c(cos(a) %*% t(sin(a)))
z=c(sin(a) %*% t(sin(a)))
scatterplot3d(x, y, z, type=l)

Best regards

Branimir K. Hackenberger

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] loop and read.table

2003-12-26 Thread lefebure tristan
Hi,
I would like to open several tables with a loop, using something like :
-
$ ls
1.txt   2.txt   3.txt   4.txt
$ R
 for (i in 1:4)  tabi-read.table(i.txt)
Error in file(file, r) : unable to open connection
In addition: Warning message:
cannot open file `i.txt'
--

thanks for any help

Tristan Lefebure

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] loop and read.table

2003-12-26 Thread Uwe Ligges
lefebure tristan wrote:
Hi,
I would like to open several tables with a loop, using something like :
-
$ ls
1.txt   2.txt   3.txt   4.txt
$ R
for (i in 1:4)  tabi-read.table(i.txt)
Since i is within a character string, it cannot be used as a variable in 
your case. You may paste() is together: paste(i, .txt, sep=), or 
even better, read the directories contents with list.files() and proceed 
over the result as in:

 tab - lapply(list.files(pattern=^?[[:digit:]]\.txt), read.table)

Uwe Ligges

Error in file(file, r) : unable to open connection
In addition: Warning message:
cannot open file `i.txt'
--
thanks for any help

Tristan Lefebure

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] loop and read.table

2003-12-26 Thread Prof Brian Ripley
On Fri, 26 Dec 2003, lefebure tristan wrote:

 I would like to open several tables with a loop, using something like :
 -
 $ ls
 1.txt 2.txt   3.txt   4.txt
 $ R
  for (i in 1:4)  tabi-read.table(i.txt)

Use read.table(paste(i, txt, sep=.))

 Error in file(file, r) : unable to open connection
 In addition: Warning message:
 cannot open file `i.txt'
 --

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] Multiple dependent variables

2003-12-26 Thread Simon CHAMAILLE
Dear friends,
I'm stuck with the following problem:
I would like to do a multiple regression with muliple dependent variables, and i don't 
know how to write my formula in the model. Someone in previous messages offered the 
cbind method, but the result is just as many regression as the number of dependent 
variables, it is just a time saving method; i'm looking for a method closer to a 
MANOVA, but without factors. well, a standard multiple rgression with multiple 
dependent variable, i.e. looking for variables that are significant in all the 
dependent variables.
If one of you have an idea, I welcome it.
and happy new year to all
simon
[[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Plot a sphere

2003-12-26 Thread David Brahm
Derick Schoonbee [EMAIL PROTECTED] wrote:
 Would somebody please be so kind as to direct me in plotting a 3D sphere?

Here's one way.  I generate an empty 3D plot with persp, then fill it with
polygons transformed with trans3d (as found in the help for persp).  I
didn't do hidden surface removal (you didn't mention whether you wanted it),
but if you do, just reorder the polygons from back to front and paint them
a solid color (e.g. col=red), so hidden ones get painted over.

pmat - persp(0:1, 0:1, matrix(,2,2), xlim=c(-1,1), ylim=c(-1,1), zlim=c(-1,1),
  theta=25, phi=30, expand=.9, xlab=X, ylab=Y, zlab=Z)

trans3d - function(x,y,z, pmat) {  # From the help for persp
  tr - cbind(x,y,z,1) %*% pmat
  list(x = tr[,1]/tr[,4], y= tr[,2]/tr[,4])
}

theta - seq(0, 2*pi, length=51)
phi   - seq(0,   pi, length=26)
x - cos(theta) %o% sin(phi)
y - sin(theta) %o% sin(phi)
z - rep(1, length(theta)) %o% cos(phi)

for (j in seq(phi)[-1]) for (i in seq(theta)[-1]) {
  idx - rbind(c(i-1,j-1), c(i,j-1), c(i,j), c(i-1,j))
  polygon(trans3d(x[idx], y[idx], z[idx], pmat))
}
-- 
  -- David Brahm ([EMAIL PROTECTED])

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] loop and read.table

2003-12-26 Thread Gabor Grothendieck


And if your intention is to create 4 data frames with
names tab1, tab2, tab3, tab4 then combine Prof. Riley's
advice with assign like this:

for(i in 1:4) 
   assign( paste(tab, i, sep=), 
   read.table(paste(i, txt, sep=.)) )

---
Date: Fri, 26 Dec 2003 14:07:45 + (GMT) 
From: Prof Brian Ripley [EMAIL PROTECTED]
To: lefebure tristan [EMAIL PROTECTED] 
Cc: [EMAIL PROTECTED] 
Subject: Re: [R] loop and read.table 

 
 
On Fri, 26 Dec 2003, lefebure tristan wrote:

 I would like to open several tables with a loop, using something like :
 -
 $ ls
 1.txt  2.txt  3.txt  4.txt
 $ R
  for (i in 1:4) tabi-read.table(i.txt)

Use read.table(paste(i, txt, sep=.))

 Error in file(file, r) : unable to open connection
 In addition: Warning message:
 cannot open file `i.txt'
 --

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] re| Dr Ward on List protocol

2003-12-26 Thread Steve Wisdom

Andrew C. Ward [EMAIL PROTECTED] :

With respect to 'tone' and 'friendliness', perhaps all that
is meant or needed is that people be polite and respectful.

I shake my head as often at rude answers

Oh, by gosh, by golly.

I don't think an occasional dose of 'real life', via a jab from the
Professor, will cause any lasting harm to the cosseted  emolumated students
and academics on the List.

On a Wall St trading desk, for example, every day one is kicked in the head
more brutally by clients, superiors, counterparts, the markets  etc, than
ever one would be by the Professor.

Plus, the Professor's jabs are good Schadenfreudic fun for the rest of us. .

Regards,

Steve Wisdom
Westport CT US

ps/ In the interest of full disclosure, I own four of the Professor's books

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Multiple dependent variables

2003-12-26 Thread Peter Dalgaard
Simon CHAMAILLE [EMAIL PROTECTED] writes:

 Dear friends,
 I'm stuck with the following problem:
 I would like to do a multiple regression with muliple dependent variables, and i 
 don't know how to write my formula in the model. Someone in previous messages 
 offered the cbind method, but the result is just as many regression as the number of 
 dependent variables, it is just a time saving method; i'm looking for a method 
 closer to a MANOVA, but without factors. well, a standard multiple rgression with 
 multiple dependent variable, i.e. looking for variables that are significant in all 
 the dependent variables.
 If one of you have an idea, I welcome it.
 and happy new year to all
 simon

Some of this stuff appears to be not quite implemented, but have a
look at

 summary(manova(cbind(y1,y2)~x1+x2))
  Df   Pillai approx F num Df den Df Pr(F)
x1 1 0.079014 0.257378  2  6 0.7812
x2 1 0.006782 0.020485  2  6 0.9798
Residuals  7
 summary(manova(cbind(y1,y2)~x2+x1))
  Df   Pillai approx F num Df den Df Pr(F)
x2 1 0.006930 0.020936  2  6 0.9794
x1 1 0.078886 0.256927  2  6 0.7815

The annoying thing is that drop1 and friends are not there, so you
have to arrange terms so that the sequential tests make sense.
However, all the bits are clearly there.

Another annoying thing is that manova() is not analogous to anova().

-- 
   O__   Peter Dalgaard Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics 2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark  Ph: (+45) 35327918
~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] re| Dr Ward on List protocol

2003-12-26 Thread Rolf Turner
Steve Wisdom wrote:

 I don't think an occasional dose of 'real life', via a jab from the
 Professor, will cause any lasting harm to the cosseted  emolumated
 students and academics on the List.
 
 On a Wall St trading desk, for example, every day one is kicked in
 the head more brutally by clients, superiors, counterparts, the
 markets  etc, than ever one would be by the Professor.
 
 Plus, the Professor's jabs are good Schadenfreudic fun for the rest
 of us.

U, there's more than ***one*** rude professor who contributes to
the list.

Although I play in a very minor league academically, I like to think
that my capacity for rudeness is right up there with the best of
them! :-)

cheers,

Rolf Turner
[EMAIL PROTECTED]

P. S.  My New Oxford Dictionary lists the word ``emolument'' as a noun,
but does not list a verb ``emolumate''.  (???)

R. T.

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] Dr Ward on List protocol

2003-12-26 Thread Patrick Gamble
Shouldn't posters who do not do obvious research before asking their
questions have this forcefully pointed out to them? I think they should.
It may put people off posting, but it may also make them do the work.

As a longtime lurker who pays a lot of money for good statistical advice,
I have an idea of what it would cost in the real world to have questions 
answered by the people on this list, though the money is not the only 
measure, I know.

So it's not a resource that should be treated too lightly, and I think the 
onus should be on the questioners rather than the respondents to take this
on board.

Seems to me the list has worked pretty well so far, and I frankly don't see 
the need for a change.

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] Re: OC curve in Quality Control

2003-12-26 Thread WilDscOp
Dear All,

First of all, thanks to Philippe Glaziou and Andrew C. Ward for their 
nice and very helpful e-mail. Well..
- ---
For Number 1 problem: about http://pari.math.u-bordeaux.fr/, sorry i 
didnot understand what to download or what to call! From 
http://pari.math.u-bordeaux.fr/download.html can you please tell me what 
should i download and how to use(i could not find any doc)? An exact link 
for download may be helpful:)
- ---
For Number 2 problem: perm function is a very nice one. And yes choose() 
works fine for me. Also gregmisc package 
http://cran.r-project.org/bin/windows/contrib/1.9/gregmisc_0.8.7.zip is good.
- ---
For Number 3 problem: i had some problem using dhyper() because i cannot 
match the parameters there. I used
 N-5000; n-50; D-seq(0,500,1); d-0 # (For d = 1 i just recalculated 
it with d-1)
 hypg - (choose(D, d)* choose((N-D), (n-d)) / choose(N,n))
instead and it surves my purpose. Anyway, is there any better procedure? I 
could not find Hypergeometric() in the base.
- ---
For Number 5 problem: I did as follows:
# For type A OC curve
 N-5000; n-50; D-seq(1,500,1); d1-0; d2-1; p-(seq(1,500,1)/5000); 
Pa-((choose(D, d1)* choose((N-D), (n-d1)) / choose(N,n)) + (choose(D, d2)* 
choose((N-D), (n-d2)) / choose(N,n))); plot(p,Pa,pch=o, main=Type A 
\nOperating Characteristic Curve, sub=Using Hypergeometric Distribution, 
xlab=Proportion defective, ylab=Probability of Acceptance, 
xlim=c(0.00,0.10), ylim=c(0.00,1.00), type=p, axes =T, col=1) # here, p = D/N
# For type B OC curve
 N-5000; n-50; D-seq(0,500,1); d1-0; d2-1; p-(seq(0,500,1)/5000); 
Pa1- dpois(0, (n*p), log = FALSE); Pa2- dpois(1, (n*p), log = FALSE); 
Pa-Pa1+Pa2;  plot(p,Pa,pch=o, main=Type B \nOperating Characteristic 
Curve, sub=Using Poisson as an approximation of Binomial Distribution, 
xlab=Proportion defective, ylab=Probability of Acceptance, 
xlim=c(0.00,0.10), ylim=c(0.00,1.00), type=p, axes =T, col=1)
And these works fine.

Thank you for your time.

___

Mohammad Ehsanul Karim [EMAIL PROTECTED]
Institute of Statistical Research and Training
University of Dhaka, Dhaka- 1000, Bangladesh
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] draft of posting guide

2003-12-26 Thread Thomas Lumley

Rather than a separate beginners' mailing list or a posting guide, perhaps
what we need is a separate mailing list for discussing posting style?

-thomas

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] different results by re-ordering vector: bug?

2003-12-26 Thread Carlos Soares
Dear R users,

I obtain the following behavior which I cannot understand. Given a file 
mydata with the following numbers:
0.171409662475182
0.15817339510258108
0.32230311052283256
0.14890800794176043
0.17074784910655194
0.16611515552614162
0.41
0.16611515552614162
0.41760423560555926
0.11978821972203839

I read the data and perform some calculations:
a - 1-read.table(mydata)$V1
m - outer(a, a, /)
diag(m) - NA
mean.row - apply(m, 1, mean, na.rm=TRUE)
which yield the same value for indices 6 and 8 of mean.row, as would be 
expected because values 6 and 8 of the original vector are the same:
 mean.row[6]==mean.row[8]
[1] TRUE

However, if I reorder the values as follows:
a - 1-read.table(mydata)$V1[c(10,2,8,9,7,3,1,4,5,6)]
and repeat the calculations:
m - outer(a, a, /)
diag(m) - NA
mean.row - apply(m, 1, mean, na.rm=TRUE)
mean.row[6]==mean.row[8]
The values for indices 10 and 3 of mean.row, which correspond to 6 and 8 
in the previous calculations, are not the same anymore:
 mean.row[10]==mean.row[3]
[1] FALSE

I understand that limited precision causes incorrect results but I 
wouldn't expect ordering operations to do the same. I couldn't find any 
information in the site about this. Maybe it's a bug with my version:
 R.version
_   
platform i686-pc-linux-gnu
arch i686
os   linux-gnu   
system   i686, linux-gnu 
status   
major1   
minor7.0 
year 2003
month04  
day  16  
language R   

Thanks and best regards,
Carlos
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] different results by re-ordering vector: bug?

2003-12-26 Thread Spencer Graves
 I just got the same answer both times with R 1.8.1 under Windows 
2000 on an IBM Thinkpad T30.  However, if abs(diff(mean.row[c(3,10)])) 
is not much bigger than .Machine$double.esp*sum(abs(mean.row[c(3,10)])), 
then I would not call that a bug.  Rather, it should be considered a 
warning not to expect exact equality in comparing floating point numbers

 Just now, I checked (pi+x-x) == 4*atan(1) and got TRUE for both in 
R 1.8.1 and S-Plus 2000 with x = 1 but FALSE with x = 100. 

 hope this helps. 
 spencer graves

Carlos Soares wrote:

Dear R users,

I obtain the following behavior which I cannot understand. Given a 
file mydata with the following numbers:
0.171409662475182
0.15817339510258108
0.32230311052283256
0.14890800794176043
0.17074784910655194
0.16611515552614162
0.41
0.16611515552614162
0.41760423560555926
0.11978821972203839

I read the data and perform some calculations:
a - 1-read.table(mydata)$V1
m - outer(a, a, /)
diag(m) - NA
mean.row - apply(m, 1, mean, na.rm=TRUE)
which yield the same value for indices 6 and 8 of mean.row, as would 
be expected because values 6 and 8 of the original vector are the same:
 mean.row[6]==mean.row[8]
[1] TRUE

However, if I reorder the values as follows:
a - 1-read.table(mydata)$V1[c(10,2,8,9,7,3,1,4,5,6)]
and repeat the calculations:
m - outer(a, a, /)
diag(m) - NA
mean.row - apply(m, 1, mean, na.rm=TRUE)
mean.row[6]==mean.row[8]
The values for indices 10 and 3 of mean.row, which correspond to 6 and 
8 in the previous calculations, are not the same anymore:
 mean.row[10]==mean.row[3]
[1] FALSE

I understand that limited precision causes incorrect results but I 
wouldn't expect ordering operations to do the same. I couldn't find 
any information in the site about this. Maybe it's a bug with my version:
 R.version
_   platform i686-pc-linux-gnu
arch i686os   linux-gnu   system   i686, 
linux-gnu status   major1   minor
7.0 year 2003month04  
day  16  language R  
Thanks and best regards,
Carlos

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Re: OC curve in Quality Control

2003-12-26 Thread Philippe Glaziou
WilDscOp [EMAIL PROTECTED] wrote:
 For Number 1 problem: about http://pari.math.u-bordeaux.fr/, sorry i 
 didnot understand what to download or what to call! From 
 http://pari.math.u-bordeaux.fr/download.html can you please tell me what 
 should i download and how to use(i could not find any doc)? An exact link 
 for download may be helpful:)


The download page gives links to the sources of PARI.  There is
also a self-installing MS-Windows executable there. As for the
doc, there is a menu item which reads Documentation.  Click on
it, and there you have a user's guide, tutorial, installation
guide, ref card, manual pages. By the way, there are other
packages out there to handle large entities (on a 32-bit machine)
like 500! (Octave, Matlab, Maple, Mathematica, Yacas...). I
suggested that one because I do not know the others. 



 - ---
 For Number 3 problem: i had some problem using dhyper() because i cannot 
 match the parameters there. I used
  N-5000; n-50; D-seq(0,500,1); d-0 # (For d = 1 i just recalculated 
 it with d-1)
  hypg - (choose(D, d)* choose((N-D), (n-d)) / choose(N,n))
 instead and it surves my purpose. Anyway, is there any better procedure? I 
 could not find Hypergeometric() in the base.


You needed phyper for that specific problem, not dhyper (the help
page for dhyper explains what dhyper, phyper, qhyper and rhyper
do).

hypg - phyper(d,D,N-D,n) 

does the job in a slightly more efficient manner. 

I would suggest that you check out the following:

help.search(hypergeometric)
?Hypergeometric 


-- 
Philippe Glaziou
Epidemiologist

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help