[R] Adding Grid lines

2006-08-22 Thread Arun Kumar Saha
Dear all R users,

Can anyone please tell me how to add grid lines in any plot in R including
in Histogram, QQ plot etc?

Thanks and regards,
Arun

[[alternative HTML version deleted]]

__
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] [R-pkgs] New version of glmmML

2006-08-22 Thread Göran Broström
On 8/21/06, Martin Maechler [EMAIL PROTECTED] wrote:
 Hi Göran,

  GB == Göran Broström [EMAIL PROTECTED]
  on Mon, 21 Aug 2006 11:12:49 +0200 writes:

 GB A new version, 0.65-1, of glmmML is now on CRAN. It is a major rewrite
 GB of the inner structures, so frequent updates (bug fixes) may be
 GB expected for some time.


 GB News:

 []

 Sorry for my lazy question :

What does the package do that lmer() does not?

Hi Martin,

most of the things I mentioned in the announcement. To appreciate it I
think you have to study 'lmer' as well (defeat your laziness!;). One
thing I didn't mention is the possibility to fit a model at a fixed
value of the standard deviation of the random effects. Utilising that,
it is easy to create a profile likelihood (as a function of sigma),
which can be very helpful in certain cases.

HTH,

Göran

__
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] return tree from .Call

2006-08-22 Thread Prof Brian Ripley
Please see the posting guide: low-level programming questions to R-devel.

On Mon, 21 Aug 2006, Sender wrote:

 Hello:
 
 I was hoping to get some advice about how to return a tree (basically a
 linked list -- with each node containing a parent, left, and right  node
 pointers) from a C routine back into R. Each node itself contains several
 attributes (a double, a char *, an int, and a void * )
 
 Initially I was thinking I could just return to R a SEXP containing a
 pointer to the Root Node, but then realized that the pointer would be
 useless since C probably frees the memory after I leave the routine.

That's not true in general: it depends how you allocated them.  With 
malloc, you need to do a free.  External pointer types and finalizers are 
available for just this, and you can also use the memory of R structures.

 Since trees vary in length (or height) I need to be able to loop thru the
 tree until all Nodes have been visited and saved in a SEXP. I'm really new
 to handling R objects from within C, and converting and returning a large
 tree structure is daunting. Here is some rough code I was thinking about
 using to do this.  Any suggestions or help will be greatly appreciated!

Since elements of a protected list are protected, you can simplify the use 
of PROTECTs (and may have to in order to avoid overflows) by linking into 
a list at allocation time.  Do node first, then its elements.

 SEXP list ;
 
 PROTECT( list = allocVector(VECSXP, tree-size) ) ;
 
 for( i = 0; i  tree-size; ++i ){
  SEXP node, tree_double, tree_char, tree_int, tree_voidPTR ;
 
  PROTECT( tree_double = NEW_NUMERIC( tree-weight ) ) ;
  PROTECT( tree_char = NEW_CHARACTER( tree-name ) ) ;
  PROTECT( tree_int = NEW_INTEGER( tree-exons ) ) ;
  PROTECT( tree_voidPTR = NEW_CHARACTER( tree-data ) ) ;   ??? not sure
 about this...
 
  PROTECT( node = allocVector( VECSXP, 4 ) ) ;
  SET_VECTOR_ELT( node, 0, tree_double) ;
  SET_VECTOR_ELT( node, 1, tree_char) ;
  SET_VECTOR_ELT( node, 2, tree_int) ;
  SET_VECTOR_ELT( node, 3, tree_voidPTR ) ;
 
  SET_VECTOR_ELT( list, i, node ) ;
 }
 
 UNPROTECT( tree-size * 4 ) ;  ??? Tricky..
 return( list ) ;
 
 Look reasonable ?
 
 THANKS !
 
   [[alternative HTML version deleted]]
 
 __
 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.
 

-- 
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

__
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] Adding Grid lines

2006-08-22 Thread Uwe Ligges


Arun Kumar Saha wrote:
 Dear all R users,
 
 Can anyone please tell me how to add grid lines in any plot in R including
 in Histogram, QQ plot etc?

Have you ever typed ?grid before posting?

Uwe Ligges


 Thanks and regards,
 Arun
 
   [[alternative HTML version deleted]]
 
 __
 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-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] Adding Grid lines

2006-08-22 Thread Bjørn-Helge Mevik
Perhaps ?grid will help you.

-- 
Bjørn-Helge Mevik

__
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] ANN: 'weaver' package, caching for Sweave

2006-08-22 Thread Seth Falcon
Hi all,

I've added a new package 'weaver' to the BioC repository:

http://www.bioconductor.org/packages/1.9/bioc/html/weaver.html

The weaver package provides extensions to the Sweave utilities
included in R's base package.  The focus of the extensions is on
caching computationally expensive (time consuming) code chunks in
Sweave documents.

Why would you want to cache code chunks?  If your Sweave document
includes one or more code chunks that take a long time to compute, you
may find it frustrating to make small changes to the document.  Each
run requires recomputing the expensive code chunks.  If these chunks
aren't changing, you can benefit from the caching provided by weaver.

To install:

  source(http://bioconductor.org/biocLite.R;)
  biocLite(weaver)

If you give it a try and have any feedback, drop me a note.

Best Wishes,

+ seth

___
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.


[R] Successive subsets from a vector?

2006-08-22 Thread kone
I'd like to pick every imbricated five character long subsets from a 
vector. I guess there is some efficient way to do this without loops...
Here is a for-loop-version and a model for output:

VECTOR=c(1,4,2,6,5,0,11,10,4,3,6,8,6);

ADDRESSES=c();
for(i in 1:(length(VECTOR)-4)){
ADDRESSES[i]=paste(VECTOR[i:(i+4)],collapse=) 
}

  ADDRESSES
[1] 14265   42650   265011  6501110 5011104 0111043 
1110436 104368
[9] 43686


Atte Tenkanen
University of Turku, Finland

[[alternative text/enriched version deleted]]

__
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] How to share variables

2006-08-22 Thread Sergio Martino
Hi

Thanks again. I hope not to waste to much of your time.

I delete some lines of your answer

 Each time myfun is run a new environment is created to hold
 its local variables.  The parent of that environment is e in
 this example by construction.  So e and the environment that
 is temporarily created to hold myfun's variables are distinct.

This means that the enviroment is duplicated, ie it is present twince in
memory?
I must keep some big variables and it will be a waste of memory; moreover if
I update a value it will be lost.

  If I can use inside myfun the variable as e$dat (without changing the
  enviroment (no environment(myfun) - e statement)) than it will be ok.

 Yes you can.  You can either make sure that e is visible to myfun
 via normal scoping rules or pass it explicitly:

 e - new.env()
 e$dat - 1:3
 myfun - function(x) sum(x + e$dat)
 myfun(10)


Hit!!!
It solves the problem.
A small drawback is that I need to modify the name of each occurrence of the
variable.


 # or passing e explicitly

 myfun2 - function(x, e) sum(x + e$dat)
 myfun2(10, e)


Any overhead in passing the environment? Is it a pointer?

Sergio

__
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] Fwd: Re: Finney's fiducial confidence intervals of LD50

2006-08-22 Thread i.m.s.white
Finney's method for finding the confidence interval for a ratio of
parameters is quite simple and is probably described in his book
'Probit analysis'. It is also known as Fieller's method so an
RSiteSearch on 'Fieller' might show something useful.


On Mon, Aug 21, 2006 at 08:46:24AM -0700, carlos riveira wrote:
 thanks a lot Renaud. 
   but i was interested in Finney's fiducial confidence intervals of LD50 so 
 to obtain comparable results with SPSS. 

   But your reply leads me to the next question: does anybody know what is the 
 best method (asymptotic,  bootstrap etc.) for calculating confidence 
 intervals of LD50? 

   i could get rid of Finney's fiducial confidence intervals but only if 
 there was a better method..

   any idea? 

   
 
 Renaud Lancelot [EMAIL PROTECTED] wrote:
   Date: Mon, 21 Aug 2006 16:35:49 +0200
 From: Renaud Lancelot [EMAIL PROTECTED]
 To: carlos riveira [EMAIL PROTECTED]
 Subject: Re: [R] Finney's fiducial confidence intervals of LD50
 CC: r-help@stat.math.ethz.ch
 
 Sorry there was a typo in my previous reply:
 
  D50 - 10^c(logD50 + c(0, -1.96, 1.96) * attr(logD50, SE))
  names(D50) - c(D50, lower, upper)
  D50
 D50 lower upper
 140.8353 103.3171 191.9777
 
 Best,
 
 Renaud
 
 2006/8/21, Renaud Lancelot :
  I don't know what Finney's fiducial confidence interval is but if your
  problem is to handle the output of dose.p (from MASS), you can do as
  follows:
 
   library(MASS)
   Response - c(0, 7, 26, 27, 0, 5, 13, 29, 0, 4, 11, 25)
   Tot - rep(30.5, 12)
   Dose - rep(c(10, 40, 160, 640), 3)
   fm - glm(Response/Tot ~ log10(Dose), family = quasibinomial(link = 
   probit))
   logD50 - dose.p(fm, cf = 1:2, p = 0.5)
   D50 - 10^c(logD50 + c(1, -1.96, 1.96) * attr(logD50, SE))
   names(D50) - c(D50, lower, upper)
   D50
  D50 lower upper
  164.9506 103.3171 191.9777
 
  Best,
 
  Renaud
 
  2006/8/21, carlos riveira :
   I am working with Probit regression (I cannot switch to logit) can 
   anybody help me in finding out how to obtain with R Finney's fiducial 
   confidence intervals for the levels of the predictor (Dose) needed to 
   produce a proportion of 50% of responses(LD50, ED50 etc.)?
   If the Pearson chi-square goodness-of-fit test is significant (by 
   default), a heterogeneity factor should be used to calculate the limits.
  
   Response-c(0,7,26,27,0,5,13,29,0,4,11,25)
   Tot-rep(30.5,12)
   Dose-rep(c(10,40,160,640),3)
   probit-glm(formula = Response/Tot~ log10(Dose), family=quasibinomial
   (link=probit))
   D50- round(10^(dose.p(probit,cf=1:2,p=0.5)))
  
   #This is what SPSS calculates. I would like to reproduce these results 
   with R:
   #SPSS RESULTS:
   #PRNT50= 140,83525
   #CI = 98,37857;205,34483
   #Regr.coeff= 1,91676 (S.E.=0,16765)
   #Intercept=-4,11856 (S.E.=0,36355)
   Thanks a lot for your help.
  
   Carlos
  
   __
  
  
  
   [[alternative HTML version deleted]]
  
   __
   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.
  
 
 
  --
  Renaud LANCELOT
  D?partement Elevage et M?decine V?t?rinaire (EMVT) du CIRAD
  Directeur adjoint charg? des affaires scientifiques
 
  CIRAD, Animal Production and Veterinary Medicine Department
  Deputy director for scientific affairs
 
  Campus international de Baillarguet
  TA 30 / B (B?t. B, Bur. 214)
  34398 Montpellier Cedex 5 - France
  T?l +33 (0)4 67 59 37 17
  Secr. +33 (0)4 67 59 39 04
  Fax +33 (0)4 67 59 37 95
 
 
 
 -- 
 Renaud LANCELOT
 D?partement Elevage et M?decine V?t?rinaire (EMVT) du CIRAD
 Directeur adjoint charg? des affaires scientifiques
 
 CIRAD, Animal Production and Veterinary Medicine Department
 Deputy director for scientific affairs
 
 Campus international de Baillarguet
 TA 30 / B (B?t. B, Bur. 214)
 34398 Montpellier Cedex 5 - France
 T?l +33 (0)4 67 59 37 17
 Secr. +33 (0)4 67 59 39 04
 Fax +33 (0)4 67 59 37 95
 
 
   
 -
 
   [[alternative HTML version deleted]]
 

 __
 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.


-- 

*I.White   *
*University of Edinburgh   *
*Ashworth Laboratories, West Mains Road*
*Edinburgh EH9 3JT *
*Fax: 0131 650 6564   Tel: 0131 650 5490   *
*E-mail: [EMAIL PROTECTED]  *

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

Re: [R] Successive subsets from a vector?

2006-08-22 Thread Prof Brian Ripley
embed(VECTOR, 5)[, 5:1]

gives the subsets, so something like

apply(embed(VECTOR, 5)[, 5:1], 1, paste, collapse=)

does the job.

The following is a bit more efficient

ind - 1:(length(VECTOR)-4)
do.call(paste, c(lapply(0:4, function(j) VECTOR[ind+j]), sep=))

but by looking at how embed() works it could be made as efficient.

Larger example:

VECTOR - sample(1:10, 1e5, replace=TRUE)
 system.time(apply(embed(VECTOR, 5)[, 5:1], 1, paste, collapse=))
[1] 5.73 0.05 5.81   NA   NA
 system.time({ind - 1:(length(VECTOR)-4)
+ do.call(paste, c(lapply(0:4, function(j) VECTOR[ind+j]), sep=))
+ })
[1] 1.00 0.01 1.01   NA   NA

The loop method took 195 secs.  Just assigning to an answer of the correct 
length reduced this to 5 secs.  e.g. use

ADDRESSES - character(length(VECTOR)-4)

Moral: don't grow vectors repeatedly.

On Tue, 22 Aug 2006, kone wrote:

 I'd like to pick every imbricated five character long subsets from a 
 vector. I guess there is some efficient way to do this without loops...
 Here is a for-loop-version and a model for output:
 
 VECTOR=c(1,4,2,6,5,0,11,10,4,3,6,8,6);
 
 ADDRESSES=c();

You do not need the semicolons, and they just confuse readers.

 for(i in 1:(length(VECTOR)-4)){
   ADDRESSES[i]=paste(VECTOR[i:(i+4)],collapse=) 
 }
 
   ADDRESSES
 [1] 14265   42650   265011  6501110 5011104 0111043 
 1110436 104368
 [9] 43686
 
 
 Atte Tenkanen
 University of Turku, Finland
 
   [[alternative text/enriched version deleted]]
 
 __
 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.
 

-- 
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

__
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] Successive subsets from a vector?

2006-08-22 Thread jim holtman
 VECTOR=c(1,4,2,6,5,0,11,10,4,3,6,8,6)
 x - lapply(seq(length(VECTOR)-4),function(z)paste(VECTOR[z:(z+4)],
collapse=''))
 unlist(x)
[1] 14265   42650   265011  6501110 5011104 0111043 1110436
104368  43686



On 8/22/06, kone [EMAIL PROTECTED] wrote:

 I'd like to pick every imbricated five character long subsets from a
 vector. I guess there is some efficient way to do this without loops...
 Here is a for-loop-version and a model for output:

 VECTOR=c(1,4,2,6,5,0,11,10,4,3,6,8,6);

 ADDRESSES=c();
 for(i in 1:(length(VECTOR)-4)){
ADDRESSES[i]=paste(VECTOR[i:(i+4)],collapse=)
 }

  ADDRESSES
 [1] 14265   42650   265011  6501110 5011104 0111043
 1110436 104368
 [9] 43686


 Atte Tenkanen
 University of Turku, Finland

[[alternative text/enriched version deleted]]

 __
 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.




-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

[[alternative HTML version deleted]]

__
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] Rgraphviz installation Problem

2006-08-22 Thread j.joshua thomas
Dear Robert,

Thanks for your time.
I have downloaded Rgraphviz (windows binary) from www.bioconductor.org
and put inside R2.3.0 library then  i installed from the local zip
its says package 'graph' couldnot be loaded.

Am i doing the installation correctly? Still the new user.

Can you guide me sir?

JJ

-- 
Lecturer J. Joshua Thomas
KDU College Penang Campus
Research Student,
University Sains Malaysia

[[alternative HTML version deleted]]

__
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] big numbers

2006-08-22 Thread Robin Hankin
Hi

Can I get R to handle really big numbers?I am not interested
in more than (say) 10 sig figs, but I would like to deal with numbers
up to, say, 10^1.

If

a - 10^1
b - pi* a

I would like  a+b to return 3.1415926e1.


Toy example, illustrating why I can't deal with log(a) and log(b),   
follows.



f - function(a,n=100){
   out - rep(0,n)
   out[1] - a
   for(i in 2:n){
 out[i] - sum(exp(out[1:i])) + rexp(1)
   }
   return(log(out))
}


then f(1,10)  has infinities in it, even though the values should be  
moderate size.

What are my options here?

--
Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743

__
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] Rgraphviz installation Problem

2006-08-22 Thread Gabor Csardi
You also need to install the 'graph' package, i think it is also available
from bioconductor.org. Other packages might be needed as well

Gabor

On Tue, Aug 22, 2006 at 06:42:31PM +0800, j.joshua thomas wrote:
 Dear Robert,
 
 Thanks for your time.
 I have downloaded Rgraphviz (windows binary) from www.bioconductor.org
 and put inside R2.3.0 library then  i installed from the local zip
 its says package 'graph' couldnot be loaded.
 
 Am i doing the installation correctly? Still the new user.
 
 Can you guide me sir?
 
 JJ
 
 -- 
 Lecturer J. Joshua Thomas
 KDU College Penang Campus
 Research Student,
 University Sains Malaysia
 
   [[alternative HTML version deleted]]
 
 __
 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.

-- 
Csardi Gabor [EMAIL PROTECTED]MTA RMKI, ELTE TTK

__
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] Successive subsets from a vector?

2006-08-22 Thread Atte Tenkanen
Thanks!

I have used tons of for- and while-loops (I'm ashamed to reveal these scripts, 
but I'm primarily a musician;-) 
http://users.utu.fi/attenka/SetTheoryScripts.r), taken some or more cup of 
cocoa and mostly been happy ;-) Now I got so many new ways to do these things, 
that it takes a while to ruminate all the ideas here.

Atte

embed(VECTOR, 5)[, 5:1]
 
 gives the subsets, so something like
 
apply(embed(VECTOR, 5)[, 5:1], 1, paste, collapse=)
 
 does the job.
 
 The following is a bit more efficient
 
ind - 1:(length(VECTOR)-4)
do.call(paste, c(lapply(0:4, function(j) VECTOR[ind+j]), sep=))
 
 but by looking at how embed() works it could be made as efficient.
 
 Larger example:
 
 VECTOR - sample(1:10, 1e5, replace=TRUE)
  system.time(apply(embed(VECTOR, 5)[, 5:1], 1, paste, collapse=))
 [1] 5.73 0.05 5.81   NA   NA
  system.time({ind - 1:(length(VECTOR)-4)
 + do.call(paste, c(lapply(0:4, function(j) VECTOR[ind+j]), sep=))
 + })
 [1] 1.00 0.01 1.01   NA   NA
 
 The loop method took 195 secs.  Just assigning to an answer of the 
 correct 
 length reduced this to 5 secs.  e.g. use
 
ADDRESSES - character(length(VECTOR)-4)
 
 Moral: don't grow vectors repeatedly.
 
 On Tue, 22 Aug 2006, kone wrote:
 
  I'd like to pick every imbricated five character long subsets 
 from a 
  vector. I guess there is some efficient way to do this without 
 loops... Here is a for-loop-version and a model for output:
  
  VECTOR=c(1,4,2,6,5,0,11,10,4,3,6,8,6);
  
  ADDRESSES=c();
 
 You do not need the semicolons, and they just confuse readers.
 
  for(i in 1:(length(VECTOR)-4)){
  ADDRESSES[i]=paste(VECTOR[i:(i+4)],collapse=) 
  }
  
ADDRESSES
  [1] 14265   42650   265011  6501110 5011104 0111043 
  1110436 104368
  [9] 43686
  
  
  Atte Tenkanen
  University of Turku, Finland
  
  [[alternative text/enriched version deleted]]
  
  __
  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.
  
 
 -- 
 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


__
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] listing a sequence of vectors in a matrix

2006-08-22 Thread Sara-Jane Dunn
Hi,
 
I'm having trouble applying the matrix function. I'd like to be able to
create a matrix of vectors filled in by rows, which are not all the same
length, and so I need it to fill in NAs where applicable. 
 
It's easiest to explain with a simple example:
 
Suppose vec = c(3,4,5). How can I form a matrix of the vectors 1:vec[j]
for j=1:3?
i.e. 1   2   3   NA NA 
  1   2   3   4   NA  
  1   2   3   45
I've tried matrix(c(1:vec[j]),nrow=max(j),ncol=max(vec)) but it will
only give me a matrix with repeated values for j=1, like   1  2  3  1 
2
3  1  2  3  1
2  3  1  2  3
 
Also using the list function hasn't got me anywhere either..
 
Any help/ideas would be greatly appreciated!
 
Many thanks,
Sara-Jane Dunn

--  
This message (and any attachments) is for the recipient only...{{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.


Re: [R] aggregate example : where is the state.region variable?

2006-08-22 Thread John Kane

--- MARK LEEDS [EMAIL PROTECTED] wrote:

 these people/experts provide all these packages and
 documentation as a FAVOR 
 and for the fact that they enjoy spreading
 knowledge/statistical computing 
 abilities etc.  It's not their job so I think
 criticism of the docs and the 
 fact that they use a variable from another place is
 kind of harsh.
 
  Mark
 

I am very appeciative of the time, expertise and great
helpfulness that I have seen in the R community.  

If there is no criticism of R then how do we find out
about problems that may exist?

 - Original Message - 
 From: John Kane [EMAIL PROTECTED]
 To: Gabor Grothendieck [EMAIL PROTECTED]
 Cc: R R-help r-help@stat.math.ethz.ch
 Sent: Monday, August 21, 2006 6:59 PM
 Subject: Re: [R] aggregate example : where is the
 state.region variable?
 
 
 
  --- Gabor Grothendieck [EMAIL PROTECTED]
  wrote:
 
  Its not part of state.x77.  Its a completely
  separate variable.
  Try ls(package:datasets) and notice its in the
  list
  or try ?state.region and note that its a variable
 in
  datasets.
 
  Thanks. I was wondering if it was going something
 like
  that.
 
  However, it is a bloody stupid example, at least
 to a
  newbie.  A call to another data.set in what is
  supposed to be a simple example is very confusing.
 
  When someone is apparently illustrating a function
  with a simple one line command I don't expect them
 to
  call another data set, apparently create a new
  variable (Region), and use that new variable as
 the
  grouping variable without a word of explanation of
  what the example is doing.
 
  If I sound a bit annoyed it is because I am. It
 might
  be nice to have an example illlustate the
 funtion,not
  do a couple of other undocumented things as well.
 
 
  On 8/21/06, John Kane [EMAIL PROTECTED] wrote:
   I was looking ?aggregate and ran the first
 example
  
aggregate(state.x77, list(Region =
 state.region),
   mean)
  
   The variables in state.x77 appear to be :
state.x77
   Population Income Illiteracy Life Exp Murder HS
  Grad
   Frost   Area
  
   Where is the state.region variable coming
 from?
  
   __
   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-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-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] boxplot order of the levels

2006-08-22 Thread Thomas Kuster
hello

i drew a boxplot with:
 boxplot(voxit$AGE ~ voxit$A02X)
and the boxes are from left to right:
Ja Leer Nein wn k.A.

 levels(voxit$A02X)
[1] Ja   Leer Nein wn   k.A. 98
there are no entries with 98

but i want:
Ja Nein Leer wn k.A.

how can i change the order of the boxes

bye
thomas

__
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] How to interrupt running computation?

2006-08-22 Thread Lothar Schmid
If I start a computation in R, how can I interrupt it?
I' using R 2.1.0.

Thanks for your help,

Lothar

__
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] How to share variables

2006-08-22 Thread Gabor Grothendieck
On 8/22/06, Sergio Martino [EMAIL PROTECTED] wrote:
 Hi

 Thanks again. I hope not to waste to much of your time.

 I delete some lines of your answer

  Each time myfun is run a new environment is created to hold
  its local variables.  The parent of that environment is e in
  this example by construction.  So e and the environment that
  is temporarily created to hold myfun's variables are distinct.

 This means that the enviroment is duplicated, ie it is present twince in
 memory?

Each time myfun starts up a new environment comes into being
that contains x and each time it completes that environment is
destroyed.

 I must keep some big variables and it will be a waste of memory; moreover if
 I update a value it will be lost.

If you update a local variable then its lost upon exit (of course you
could return the variable or return the environment inside the
function) but if you update it in e then its not lost.


   If I can use inside myfun the variable as e$dat (without changing the
   enviroment (no environment(myfun) - e statement)) than it will be ok.
 
  Yes you can.  You can either make sure that e is visible to myfun
  via normal scoping rules or pass it explicitly:
 
  e - new.env()
  e$dat - 1:3
  myfun - function(x) sum(x + e$dat)
  myfun(10)
 

 Hit!!!
 It solves the problem.
 A small drawback is that I need to modify the name of each occurrence of the
 variable.

That's why in an earlier example we set the environment of myfun
to e.



  # or passing e explicitly
 
  myfun2 - function(x, e) sum(x + e$dat)
  myfun2(10, e)
 

 Any overhead in passing the environment? Is it a pointer?

?system.time

to experiment with timings.


 Sergio



__
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] Successive subsets from a vector?

2006-08-22 Thread hadley wickham
 The loop method took 195 secs.  Just assigning to an answer of the correct
 length reduced this to 5 secs.  e.g. use

 ADDRESSES - character(length(VECTOR)-4)

 Moral: don't grow vectors repeatedly.

Other languages (eg. Java) grow the size of the vector independently
of the number of observations in it (I think Java doubles the size
whenever the vector is filled), thus changing O(n) behaviour to O(log
n).  I've always wondered why R doesn't do this.

Hadley

__
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] How to interrupt running computation?

2006-08-22 Thread Sarah Goslee
On 8/22/06, Lothar Schmid [EMAIL PROTECTED] wrote:
 If I start a computation in R, how can I interrupt it?
 I' using R 2.1.0.

Hi Lothar,

What do you mean by interrupt - cancel completely and
return to the prompt? Or pause, then resume? Your operating
system would be helpful too.

If the former, try Esc on Windows or Ctrl-C on Linux.
If the latter, Ctrl-Z will send your R session to the background
on Linux, and fg will bring it back. I don't think there's a
Windows equivalent.

Sarah


-- 
Sarah Goslee
http://www.stringpage.com

__
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] How to interrupt running computation?

2006-08-22 Thread Stefan Grosse
Lothar,

Which system do you use? Windows, Linux, Mac?

Stefan




Lothar Schmid schrieb:
 If I start a computation in R, how can I interrupt it?
 I' using R 2.1.0.

 Thanks for your help,

 Lothar

 __
 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-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] boxplot order of the levels

2006-08-22 Thread Marc Schwartz
On Tue, 2006-08-22 at 14:27 +0200, Thomas Kuster wrote:
 hello
 
 i drew a boxplot with:
  boxplot(voxit$AGE ~ voxit$A02X)
 and the boxes are from left to right:
 Ja Leer Nein wn k.A.
 
  levels(voxit$A02X)
 [1] Ja   Leer Nein wn   k.A. 98
 there are no entries with 98
 
 but i want:
 Ja Nein Leer wn k.A.
 
 how can i change the order of the boxes
 
 bye
 thomas

See the following post from last week:

https://stat.ethz.ch/pipermail/r-help/2006-August/111289.html

HTH,

Marc Schwartz

__
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] listing a sequence of vectors in a matrix

2006-08-22 Thread Gabor Grothendieck
Here are two solutions.  seq(length = ...) instead of
just seq(...) is so that v can possibly contain zeros.

# data
v - 3:5

# solution 1 - rbind/lapply
f - function(n) {
s = seq(length = n)
replace(rep(NA, max(v)), s, s)
}
do.call(rbind, lapply(v, f))

# solution 2 - loop
mat - matrix(NA, length(v), max(v))
for(i in seq(v)) {
s - seq(length = v[i])
mat[i, s] - s
}


On 8/22/06, Sara-Jane Dunn [EMAIL PROTECTED] wrote:
 Hi,

 I'm having trouble applying the matrix function. I'd like to be able to
 create a matrix of vectors filled in by rows, which are not all the same
 length, and so I need it to fill in NAs where applicable.

 It's easiest to explain with a simple example:

 Suppose vec = c(3,4,5). How can I form a matrix of the vectors 1:vec[j]
 for j=1:3?
 i.e. 1   2   3   NA NA
  1   2   3   4   NA
  1   2   3   45
 I've tried matrix(c(1:vec[j]),nrow=max(j),ncol=max(vec)) but it will
 only give me a matrix with repeated values for j=1, like   1  2  3  1
 2
3  1  2  3  1
2  3  1  2  3

 Also using the list function hasn't got me anywhere either..

 Any help/ideas would be greatly appreciated!

 Many thanks,
 Sara-Jane Dunn

 --
 This message (and any attachments) is for the recipient only...{{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.


__
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] listing a sequence of vectors in a matrix

2006-08-22 Thread Robin Hankin

Hi



  f - function(a,n){(1:a)[1:n]}
  t(sapply(c(2,3,4,4,4,5,6),f,n=5))
  [,1] [,2] [,3] [,4] [,5]
[1,]12   NA   NA   NA
[2,]123   NA   NA
[3,]1234   NA
[4,]1234   NA
[5,]1234   NA
[6,]12345
[7,]12345
 
 


HTH

rksh





On 22 Aug 2006, at 12:29, Sara-Jane Dunn wrote:

 Hi,

 I'm having trouble applying the matrix function. I'd like to be  
 able to
 create a matrix of vectors filled in by rows, which are not all the  
 same
 length, and so I need it to fill in NAs where applicable.

 It's easiest to explain with a simple example:

 Suppose vec = c(3,4,5). How can I form a matrix of the vectors 1:vec 
 [j]
 for j=1:3?
 i.e. 1   2   3   NA NA
   1   2   3   4   NA
   1   2   3   45
 I've tried matrix(c(1:vec[j]),nrow=max(j),ncol=max(vec)) but it will
 only give me a matrix with repeated values for j=1, like   1  2  3  1
 2
 3  1  2  3  1
 2  3  1  2  3

 Also using the list function hasn't got me anywhere either..

 Any help/ideas would be greatly appreciated!

 Many thanks,
 Sara-Jane Dunn

 --  
 This message (and any attachments) is for the recipient on...{{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.


Re: [R] listing a sequence of vectors in a matrix

2006-08-22 Thread Robin Hankin
Gabor makes a good point about seq() vs a:b [a common gotcha
for me].


I'll revise my original function to:

  f - function(a,n){(seq(length=a))[1:n]}
  t(sapply(c(2,3,4,4,4,5,6,0),f,n=5))
  [,1] [,2] [,3] [,4] [,5]
[1,]12   NA   NA   NA
[2,]123   NA   NA
[3,]1234   NA
[4,]1234   NA
[5,]1234   NA
[6,]12345
[7,]12345
[8,]   NA   NA   NA   NA   NA
 




rksh

On 22 Aug 2006, at 13:55, Gabor Grothendieck wrote:

 Here are two solutions.  seq(length = ...) instead of
 just seq(...) is so that v can possibly contain zeros.

 # data
 v - 3:5

 # solution 1 - rbind/lapply
 f - function(n) {
   s = seq(length = n)
   replace(rep(NA, max(v)), s, s)
 }
 do.call(rbind, lapply(v, f))

 # solution 2 - loop
 mat - matrix(NA, length(v), max(v))
 for(i in seq(v)) {
   s - seq(length = v[i])
   mat[i, s] - s
 }


 On 8/22/06, Sara-Jane Dunn [EMAIL PROTECTED] wrote:
 Hi,

 I'm having trouble applying the matrix function. I'd like to be  
 able to
 create a matrix of vectors filled in by rows, which are not all  
 the same
 length, and so I need it to fill in NAs where applicable.

 It's easiest to explain with a simple example:

 Suppose vec = c(3,4,5). How can I form a matrix of the vectors  
 1:vec[j]
 for j=1:3?
 i.e. 1   2   3   NA NA
  1   2   3   4   NA
  1   2   3   45
 I've tried matrix(c(1:vec[j]),nrow=max(j),ncol=max(vec)) but it will
 only give me a matrix with repeated values for j=1, like   1  2  3  1
 2
3  1  2  3  1
2  3  1  2  3

 Also using the list function hasn't got me anywhere either..

 Any help/ideas would be greatly appreciated!

 Many thanks,
 Sara-Jane Dunn

 --
 This message (and any attachments) is for the recipient only... 
 {{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.


 __
 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.

--
Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743

__
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] aggregate example : where is the state.region variable?

2006-08-22 Thread Martin Maechler
 Gabor == Gabor Grothendieck [EMAIL PROTECTED]
 on Mon, 21 Aug 2006 21:03:49 -0400 writes:

Gabor It is worthwhile to note that what is being
Gabor illustrated here is aggregating a numeric matrix by a
Gabor factor using the aggregate.default method and, of
Gabor course, a factor can't be part of a numeric matrix.

Gabor Of course, that is not say that the examples could
Gabor not be improved in terms of clarity, simplicity and
Gabor comprehensiveness (there is no example of
Gabor aggregate.data.frame).

yes, thank you, Gabor . 
and we (the R developers) have accepted and incorporated
quite a few constructive proposals for improvement.

Just offending the original authors (bloody ..) without adding
any constructive proposal for improvement doesn't really help.
You can always get the money back you paid for R.
You can also decide to leave this mailing list and get the money
back you paid for that service.  Unfortunately, we can't get the
time and energy back we've lost when dealing with such postings...

Martin Maechler, ETH Zurich

Gabor On 8/21/06, John Kane [EMAIL PROTECTED] wrote:
  --- Gabor Grothendieck [EMAIL PROTECTED] wrote:
 
  Its not part of state.x77.  Its a completely  separate
 variable.   Try ls(package:datasets) and notice its in
 the  list  or try ?state.region and note that its a
 variable in  datasets.
 
 Thanks. I was wondering if it was going something like
 that.
 
 However, it is a bloody stupid example, at least to a
 newbie.  A call to another data.set in what is supposed
 to be a simple example is very confusing.
 
 When someone is apparently illustrating a function with a
 simple one line command I don't expect them to call
 another data set, apparently create a new variable
 (Region), and use that new variable as the grouping
 variable without a word of explanation of what the
 example is doing.
 
 If I sound a bit annoyed it is because I am. It might be
 nice to have an example illlustate the funtion,not do a
 couple of other undocumented things as well.
 
 
  On 8/21/06, John Kane [EMAIL PROTECTED] wrote:   I
 was looking ?aggregate and ran the first example
  
   aggregate(state.x77, list(Region = state.region),  
 mean)
  
   The variables in state.x77 appear to be :   
 state.x77   Population Income Illiteracy Life Exp
 Murder HS  Grad   Frost Area
  
   Where is the state.region variable coming from?
  
   __  
 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.
  
 
 
 
 __ Do You
 Yahoo!?  Tired of spam?  Yahoo! Mail has the best spam
 protection around http://mail.yahoo.com
 

Gabor __
Gabor R-help@stat.math.ethz.ch mailing list
Gabor https://stat.ethz.ch/mailman/listinfo/r-help PLEASE
Gabor do read the posting guide
Gabor http://www.R-project.org/posting-guide.html and
Gabor provide commented, minimal, self-contained,
Gabor reproducible code.

__
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] R2WinBugs

2006-08-22 Thread Andrew Gelman
We had set R2WinBugs to use the burnin as the adaptive phase.  I think 
this was changed very slightly in the latest version of R2WinBUGS so 
that the adaptive phase would equal burnin minus 1.  This was to allow 
DIC to be calculated.  So I think it should work OK now.  If you send an 
example I can take a look.

Andrew

Uwe Ligges wrote:



 Bowden, J.M. wrote:

 Hi all,


 I am having problems using the R2Winbugs function

 When I perform an analysis directly in Winbugs I can specify that the
 first 'n' iterations are to be done using an 'adaptive' phase. After
 this phase the markov chain seems to mix a lot better.


 I don't seem to be able to specify R2winbugs to carry out this adaptive
 phase, I can just specify the burnin length but this (to my knowledge)
 is not the same thing.

 As a result my models are not fitting as well as I would like, has
 anyone had a similar experience?


 I think this is a question for Andrew Gelman (CCing), who wrote the 
 underlying code for automatically setting the adaptive phase.

 Uwe Ligges


 Jack

 __
 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.


-- 
Andrew Gelman
Professor, Department of Statistics
Professor, Department of Political Science
[EMAIL PROTECTED]
www.stat.columbia.edu/~gelman

Statistics department office:
  Social Work Bldg (Amsterdam Ave at 122 St), Room 1016
  212-851-2142
Political Science department office:
  International Affairs Bldg (Amsterdam Ave at 118 St), Room 731
  212-854-7075

Mailing address:
  1255 Amsterdam Ave, Room 1016
  Columbia University
  New York, NY 10027-5904
  212-851-2142
  (fax) 212-851-2164

__
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] How to interrupt running computation?

2006-08-22 Thread Lothar Schmid
I'm using Linux.
And I'd like just to cancel a running computation, not the entire R prompt.

Lothar

__
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] Finney's fiducial confidence intervals of LD50

2006-08-22 Thread carlos riveira
Thanks for the tip! 
  unfortunately though conf limits calculated with Fieller and delta methods do 
not seem to be in agreement with (and seem to be worse than..) my SPSS 
results.. Am i doing something wrong? 
  thanks a lot in advance for your help!! 
   
  An RSiteSearch on 'Fieller' gave me the following 2 posts
  one from S.B.Cox using fieller's conf limits, and one from Varadhan using 
delta method:
   
  1-Fieller's Conf Limits and EC50's
  From: Stephen B. Cox stephen.cox 
Date: Wed, 13 Jul 2005 11:42:52 -0500
   
  ec.calc-function(obj,conf.level=.95,p=.5) { 
call - match.call() 

 coef = coef(obj) 
 vcov = summary.glm(obj)$cov.unscaled 
 b0-coef[1] 
 b1-coef[2] 
 var.b0-vcov[1,1] 
 var.b1-vcov[2,2] 
 cov.b0.b1-vcov[1,2] 
 alpha-1-conf.level 
 zalpha.2 - -qnorm(alpha/2) 
 gamma - zalpha.2^2 * var.b1 / (b1^2) 
 eta = family(obj)$linkfun(p) #based on calcs in VR's dose.p 
   EC50 - (eta-b0)/b1 
   const1 - (gamma/(1-gamma))*(EC50 + cov.b0.b1/var.b1) 
   const2a - var.b0 + 2*cov.b0.b1*EC50 + var.b1*EC50^2 - 
gamma*(var.b0 - cov.b0.b1^2/var.b1) 
   const2 - zalpha.2/( (1-gamma)*abs(b1) )*sqrt(const2a) 
   LCL - EC50 + const1 - const2 
 UCL - EC50 + const1 + const2 
   conf.pts - c(LCL,EC50,UCL) 
 names(conf.pts) - c(Lower,EC50,Upper) 
   return(conf.pts,conf.level,call=call) 
 } 

   
  #when i apply it to my data (see below)
# i get with Fieller's method by Cox

# Lower EC50Upper 
  #11.47628 140.8351 8423.78
  # while SPSS gives me: 
  # Lower EC50Upper 
  #98,37857  140,83525  205,34483



   
library(MASS)
  Response-c(0,7,26,27,0,5,13,29,0,4,11,25)
  Tot-rep(30.5,12)
  Dose-rep(c(10,40,160,640),3)
  probit-glm(formula = Response/Tot~ log10(Dose), family=quasibinomial
  (link=probit))
  ec.calc(probit,conf.level=.95,p=.5)
$conf.pts
   Lower EC50Upper 
1.059801 2.148711 3.925507 
  $conf.level
[1] 0.95
  $call
ec.calc(obj = probit, conf.level = 0.95, p = 0.5)
  Warning message:
multi-argument returns are deprecated in: return(conf.pts, conf.level, call = 
call) 

  2-Fieller's Conf Limits and EC50's
  From: Ravi Varadhan rvaradha 
Date: Thu, 14 Jul 2005 09:44:47 -0400
   
  varEC50 - 1/b1^2 * (var.b0 + EC50^2*var.b1 + 2*EC50*cov.b0.b1) 

  LCL - EC50 - zalpha.2 * sqrt(varEC50) 
UCL - EC50 + zalpha.2 * sqrt(varEC50) 


#when i apply it to my data 
# i get with delta method by varadhan

# Lower EC50Upper 
  # 46.15749 140.8351 429.7151
  # while SPSS gives me: 
  # Lower EC50Upper 
  #98,37857  140,83525  205,34483


  
i.m.s.white [EMAIL PROTECTED] wrote:
  Finney's method for finding the confidence interval for a ratio of
parameters is quite simple and is probably described in his book
'Probit analysis'. It is also known as Fieller's method so an
RSiteSearch on 'Fieller' might show something useful.


On Mon, Aug 21, 2006 at 08:46:24AM -0700, carlos riveira wrote:
 thanks a lot Renaud. 
 but i was interested in Finney's fiducial confidence intervals of LD50 so to 
 obtain comparable results with SPSS. 
 
 But your reply leads me to the next question: does anybody know what is the 
 best method (asymptotic, bootstrap etc.) for calculating confidence intervals 
 of LD50? 
 
 i could get rid of Finney's fiducial confidence intervals but only if there 
 was a better method..
 
 any idea? 
 
 
 
 Renaud Lancelot wrote:
 Date: Mon, 21 Aug 2006 16:35:49 +0200
 From: Renaud Lancelot 
 To: carlos riveira 
 Subject: Re: [R] Finney's fiducial confidence intervals of LD50
 CC: r-help@stat.math.ethz.ch
 
 Sorry there was a typo in my previous reply:
 
  D50 - 10^c(logD50 + c(0, -1.96, 1.96) * attr(logD50, SE))
  names(D50) - c(D50, lower, upper)
  D50
 D50 lower upper
 140.8353 103.3171 191.9777
 
 Best,
 
 Renaud
 
 2006/8/21, Renaud Lancelot :
  I don't know what Finney's fiducial confidence interval is but if your
  problem is to handle the output of dose.p (from MASS), you can do as
  follows:
 
   library(MASS)
   Response - c(0, 7, 26, 27, 0, 5, 13, 29, 0, 4, 11, 25)
   Tot - rep(30.5, 12)
   Dose - rep(c(10, 40, 160, 640), 3)
   fm - glm(Response/Tot ~ log10(Dose), family = quasibinomial(link = 
   probit))
   logD50 - dose.p(fm, cf = 1:2, p = 0.5)
   D50 - 10^c(logD50 + c(1, -1.96, 1.96) * attr(logD50, SE))
   names(D50) - c(D50, lower, upper)
   D50
  D50 lower upper
  164.9506 103.3171 191.9777
 
  Best,
 
  Renaud
 
  2006/8/21, carlos riveira :
   I am working with Probit regression (I cannot switch to logit) can 
   anybody help me in finding out how to obtain with R Finney's fiducial 
   confidence intervals for the levels of the predictor (Dose) needed to 
   produce a proportion of 50% of responses(LD50, ED50 etc.)?
   If the Pearson chi-square goodness-of-fit test is significant (by 
   default), a heterogeneity factor should be 

[R] :Circular-Linear Correlation

2006-08-22 Thread Agnes Blukacz
Dear All,

I'm looking for code that does circular-linear correlations as proposed
by Mardia (1976).

Thank you,

Agnes

__
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] How to interrupt running computation?

2006-08-22 Thread Sarah Goslee
Then Ctrl-C should do the trick.

Sarah

On 8/22/06, Lothar Schmid [EMAIL PROTECTED] wrote:
 I'm using Linux.
 And I'd like just to cancel a running computation, not the entire R prompt.

 Lothar


-- 
Sarah Goslee
http://www.stringpage.com

__
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] summary(lm ... conrasts=...)

2006-08-22 Thread Ted Harding
Hi Folks,

I've encountered something I hadn't been consciously
aware of previously, and I'm wondering what the
explanation might be.

In (on another list) using R to demonstrate the difference
between different contrasts in 'lm' I set up an example
where Y is sampled from three different normal distributions
according to the levels (A,B,C) of a factor X:

Y-c(rnorm(mean=0,n=12),rnorm(mean=2,n=12),rnorm(mean=4,n=12))
X-factor(c(rep(A,12),rep(B,12),rep(C,12)))

Then I do a summary(lm(Y~X)...) using first Treatment contrasts
and then Helmert contrasts. Here are the coefficient parts
of the results in each case:


summary(lm(Y~X,contrasts=list(X=contr.treatment)))
Coefficients:
Estimate Std. Error t value Pr(|t|)
(Intercept)   0.2303 0.3220   0.715  0.47944
XB1.3057 0.4554   2.867  0.00716 **
XC3.4204 0.4554   7.511 1.23e-08 ***


summary(lm(Y~X,contrasts=list(X=contr.helmert)))
Coefficients:
Estimate Std. Error t value Pr(|t|)
(Intercept)   1.8057 0.1859   9.713 3.34e-11 ***
X10.6529 0.2277   2.867  0.00716 **
X20.9225 0.1315   7.017 5.00e-08 ***


What I'm wondering is why the effect names are X.B
and X.C for Treatment, and X1, X2 for Helmert.

Why not X.B and X.C in both cases? Just as XB
contrasts B with the overall mean and XC contrasts C
with the overall mean, XA being implicit, in the
Treatment contrasts, so X1 contrasts B with A and
X2 contrasts C with (A+B) in Helmert, so there
is to my mind just as definite an association of B
with the first contrast, and C with the second, in
the Helmert case as in the Treatment case!

I know it's just a matter of notation, but in the
Helmert case the association with the names of the
factor levels has been lost, and it could be useful
to have it explicit. (Or is it intended simply as a
reminder that one is using a particular system of
contrasts?)

Thanks, and best wishes to all,
Ted.


E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 22-Aug-06   Time: 14:45:17
-- XFMail --

__
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] big numbers

2006-08-22 Thread Roger D. Peng
The 'gmp' package may be of use here, but I'm not sure.

-roger

Robin Hankin wrote:
 Hi
 
 Can I get R to handle really big numbers?I am not interested
 in more than (say) 10 sig figs, but I would like to deal with numbers
 up to, say, 10^1.
 
 If
 
 a - 10^1
 b - pi* a
 
 I would like  a+b to return 3.1415926e1.
 
 
 Toy example, illustrating why I can't deal with log(a) and log(b),   
 follows.
 
 
 
 f - function(a,n=100){
out - rep(0,n)
out[1] - a
for(i in 2:n){
  out[i] - sum(exp(out[1:i])) + rexp(1)
}
return(log(out))
 }
 
 
 then f(1,10)  has infinities in it, even though the values should be  
 moderate size.
 
 What are my options here?
 
 --
 Robin Hankin
 Uncertainty Analyst
 National Oceanography Centre, Southampton
 European Way, Southampton SO14 3ZH, UK
   tel  023-8059-7743
 
 __
 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.
 

-- 
Roger D. Peng  |  http://www.biostat.jhsph.edu/~rpeng/

__
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] new version of The R Guide available on CRAN

2006-08-22 Thread Owen, Jason
Hello,

Version 2.2 of The R Guide is available for download in
the Contributed Documents section on CRAN.  The R Guide
is written for the beginning R user.  I use the guide in my
undergraduate probability and math stat sequence, but anyone
with a basic understanding of statistics (who wants to learn
R) should find it useful.

This updated version includes sections on multiple comparisons,
optimization, along with some improvements suggested by fellow
R users from around the world.  The entire document is under
60 pages in length.

Jason
--
Assistant Professor of Statistics
Mathematics and Computer Science Department
University of Richmond, Virginia 23173
(804) 289-8081   fax:(804) 287-6664
http://www.mathcs.richmond.edu/~wowen

This is R. There is no if. Only how.
Simon (Yoda) Blomberg

__
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] Link

2006-08-22 Thread Paul Artes

Its a very nice document. Here is the link:

http://cran.r-project.org/doc/contrib/Owen-TheRGuide.pdf


-- 
View this message in context: 
http://www.nabble.com/new-version-of-%22The-R-Guide%22-available-on-CRAN-tf2146496.html#a5926389
Sent from the R help forum at Nabble.com.

__
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] aggregate example : where is the state.region variable?

2006-08-22 Thread Richard M. Heiberger
 there is
 no factor in the dataset but why there is not one and
 why a call to another dataset is totally opaque.  

The reason is purely historical.  The state dataset is about
10 years older than the data.frame concept.  At the time the
state.* variables were constructed it was not possible to put
numeric data and factor data into the same rectangular structure.

__
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] listing a sequence of vectors in a matrix

2006-08-22 Thread Gabor Grothendieck
Here is another variation using Robin's idea of t(sapply(...))

v - c(3:5, 0)
t(sapply(lapply(v, function(n) seq(length = n)), length-, max(v) ))

# which can be shortened even further for the case where
# there are no zeros in v

v - 3:5
t(sapply(lapply(v, seq), length-, max(v) ))

On 8/22/06, Robin Hankin [EMAIL PROTECTED] wrote:
 Gabor makes a good point about seq() vs a:b [a common gotcha
 for me].


 I'll revise my original function to:

   f - function(a,n){(seq(length=a))[1:n]}
   t(sapply(c(2,3,4,4,4,5,6,0),f,n=5))
  [,1] [,2] [,3] [,4] [,5]
 [1,]12   NA   NA   NA
 [2,]123   NA   NA
 [3,]1234   NA
 [4,]1234   NA
 [5,]1234   NA
 [6,]12345
 [7,]12345
 [8,]   NA   NA   NA   NA   NA
  




 rksh

 On 22 Aug 2006, at 13:55, Gabor Grothendieck wrote:

  Here are two solutions.  seq(length = ...) instead of
  just seq(...) is so that v can possibly contain zeros.
 
  # data
  v - 3:5
 
  # solution 1 - rbind/lapply
  f - function(n) {
s = seq(length = n)
replace(rep(NA, max(v)), s, s)
  }
  do.call(rbind, lapply(v, f))
 
  # solution 2 - loop
  mat - matrix(NA, length(v), max(v))
  for(i in seq(v)) {
s - seq(length = v[i])
mat[i, s] - s
  }
 
 
  On 8/22/06, Sara-Jane Dunn [EMAIL PROTECTED] wrote:
  Hi,
 
  I'm having trouble applying the matrix function. I'd like to be
  able to
  create a matrix of vectors filled in by rows, which are not all
  the same
  length, and so I need it to fill in NAs where applicable.
 
  It's easiest to explain with a simple example:
 
  Suppose vec = c(3,4,5). How can I form a matrix of the vectors
  1:vec[j]
  for j=1:3?
  i.e. 1   2   3   NA NA
   1   2   3   4   NA
   1   2   3   45
  I've tried matrix(c(1:vec[j]),nrow=max(j),ncol=max(vec)) but it will
  only give me a matrix with repeated values for j=1, like   1  2  3  1
  2
 3  1  2  3  1
 2  3  1  2  3
 
  Also using the list function hasn't got me anywhere either..
 
  Any help/ideas would be greatly appreciated!
 
  Many thanks,
  Sara-Jane Dunn
 
  --
  This message (and any attachments) is for the recipient only...
  {{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.
 
 
  __
  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.

 --
 Robin Hankin
 Uncertainty Analyst
 National Oceanography Centre, Southampton
 European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743



__
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] lean and mean lm/glm?

2006-08-22 Thread Thomas Lumley
On Mon, 21 Aug 2006, Damien Moore wrote:


 For very large regression problems there is the biglm package (put you
 data into a database, read in 500,000 rows at a time, and keep updating
 the fit).

 thanks. I took a look at biglm and it seems pretty easy to use and, 
 looking at the source, avoids much of the redundancy of lm. Correct me 
 if i'm wrong, but I think it would be virtually impossible to extend to 
 glm, because of the non-linearity in glm models.

No, it is quite straightforward if you are willing to make multiple passes 
through the data.  It is hard with a single pass and may not be possible 
unless the data are in random order.

Fisher scoring for glms is just an iterative weighted least squares 
calculation using a set of 'working' weights and 'working' response. These 
can be defined chunk by chunk and fed to biglm.  Three iterations should 
be sufficient.

-thomas

__
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] Escaping ' character

2006-08-22 Thread Srinivas Iyyer
Dear marc: thank you for your tip. 

  cat(x.new, \n)
 3\',5\'-cyclic-nucleotide phosphodiesterase activity
 

here cat is printing on screen. 

how can I direct the output to an object. 

I cannot do:

y - cat(x.new, \n)

is there any other way.

thanks
srini



 Try this:
 
  x - 3',5'-cyclic-nucleotide phosphodiesterase
 activity
 
  x
 [1] 3',5'-cyclic-nucleotide phosphodiesterase
 activity
 
  gsub(', ', x)
 [1] 3\\',5\\'-cyclic-nucleotide phosphodiesterase
 activity
 
 
 Note that I use gsub() to replace both instances of
 the ', whereas sub()
 will only replace the first.
 
 The escape character itself needs to be escaped when
 used within the
 replacement regex, since the \ is a metacharacter.
 You end up with
 four \s since R also treats the \ specially.
 
 When you cat() the output, you get:
 
  x.new
 [1] 3\\',5\\'-cyclic-nucleotide phosphodiesterase
 activity
 
  cat(x.new, \n)
 3\',5\'-cyclic-nucleotide phosphodiesterase activity
 
 
 HTH,
 
 Marc Schwartz
 
 


__
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] HH and Rcmdr.HH packages available

2006-08-22 Thread Richard M. Heiberger
The software for my recent book
 Statistical Analysis and Data Display
 Richard M. Heiberger and Burt Holland
 http://springeronline.com/0-387-40270-5

is now available as an R package from the book's website.
The package has been submitted to CRAN.

Description: Support software for Statistical Analysis and Data
Display (Springer, ISBN 0-387-40270-5).  This contemporary
presentation of statistical methods features extensive use of
graphical displays for exploring data and for displaying the
analysis. The authors demonstrate how to analyze data---showing
code, graphics, and accompanying computer listings---for all the
methods they cover. They emphasize how to construct and
interpret graphs, discuss principles of graphical design, and
show how accompanying traditional tabular results are used to
confirm the visual impressions derived directly from the
graphs. Many of the graphical formats are novel and appear
here for the first time in print. All chapters have exercises.



Software that adds additional functions to Rcmdr 1.7 is now available from
my website and has been submitted to CRAN.
http://astro.ocis.temple.edu/~rmh/Rcmdr.HH/

Description: Our introductory course spends time on several topics
that are not yet in the R Commander.  Therefore we wrote the menu
items and make them available.

__
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] Comparing pre-post effect sizes and areas under the curve, resp.

2006-08-22 Thread Wilmar Igl
Hello!

Does anybody know how to compare pre-post-effect sizes of different 
variables from the same sample with statistical tests? I have the same 
problem with areas under the curve (AUC) from ROC-Analysis.

Any recommendations on references or programms are welcome!

Thank you,

Will

__
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] [R-pkgs] ANN: 'weaver' package, caching for Sweave

2006-08-22 Thread Seth Falcon
Hi again,

Sorry for the noise, but I need to make a correction:

Seth Falcon [EMAIL PROTECTED] writes:
 To install:

   source(http://bioconductor.org/biocLite.R;)
   biocLite(weaver)

At present, the above install sequence will _only_ work if you are
using a development version of R.

If you are using the current R release, you will have to work a bit
harder to install (put weaver works there too):

First install weaver's dependencies:

  digest (on CRAN)

  codetools:
http://bioconductor.org/packages/1.9/omegahat/html/codetools.html

Then install weaver:
http://www.bioconductor.org/packages/1.9/bioc/html/weaver.html

Finally, I will try to make Windows binaries available by the end of
the week.

+ seth

___
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] Successive subsets from a vector?

2006-08-22 Thread Prof Brian Ripley
On Tue, 22 Aug 2006, hadley wickham wrote:

  The loop method took 195 secs.  Just assigning to an answer of the correct
  length reduced this to 5 secs.  e.g. use
 
  ADDRESSES - character(length(VECTOR)-4)
 
  Moral: don't grow vectors repeatedly.
 
 Other languages (eg. Java) grow the size of the vector independently
 of the number of observations in it (I think Java doubles the size
 whenever the vector is filled), thus changing O(n) behaviour to O(log
 n).  I've always wondered why R doesn't do this.

At one point at least that was too expensive on memory/address space (and 
it may still be for 32-bit OSes). There is even a 'truelength' field in 
the vector header to allow for such a strategy, and the strategy is used 
in scan() and elsewhere.

In my experience it is relatively rare not to know the vector length in 
advance in R code.

-- 
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

__
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] 3 September Courses: (1) Regression Modeling Strategies in R/Splus, (2) R/Splus Advanced Programming, (3) R/Splus Fundamentals

2006-08-22 Thread Sue Turner
XLSolutions Corporation (www.xlsolutions-corp.com) is proud to announce
our September courses: 

(1) Regression Modeling Strategies in R/Splus --- by Prof Frank Harrell 
   http://xlsolutions-corp.com/Rstats2.htm 
   *** Washington DC, September 28-29, 2006 *** 
(2) R/Splus Advanced Programming --- by the R Development Core Team
Guru! 
   *** New York City / September 11-12,2006*** 
 http://www.xlsolutions-corp.com/Radv.htm  
(3) R/Splus Fundamentals and Programming Techniques 
  
   *** Raleigh / September 12-13, 2006 *** 
 http://www.xlsolutions-corp.com/Rfund.htm 
  
Ask for group discount and reserve your seat Now - Earlybird Rates.
Payment due after the class! Email Sue Turner:  [EMAIL PROTECTED]


(1) Regression Modeling Strategies at  
http://xlsolutions-corp.com/Rstats2.htm 
(2) R/Splus Advanced Programming   
Course Outline: 
- Overview of R/S fundamentals: Syntax and Semantics
- Class and Inheritance in R/S-Plus
- Concepts, Construction and good use of language objects
- Coercion and efficiency
- Object-oriented programming in R and S-Plus
- Advanced manipulation tools: Parse, Deparse, Substitute, etc.
- How to fully take advantage of Vectorization
- Generic and Method Functions
- Search path, databases and frames Visibility
- Working with large objects
- Handling Properly Recursion and iterative calculations
- Managing loops; For (S-Plus) and for() loops
- Consequences of Lazy Evaluation
- Efficient Code practices for large computations
- Memory management and Resource monitoring
- Writing R/S-Plus functions to call compiled code
- Writing and debugging compiled code for R/S-Plus system
- Connecting R/S-Plus to External Data Sources
- Understanding the structure of model fitting functions in R/S-Plus
- Designing and Packaging efficiently a new model function  
It'll also deal with lots of S-Plus efficiency issues and any special
topics from participants is welcome. 
(3) R/Splus Fundamentals and Programming Techniques 
   
Course outline. 
- An Overview of R and S
- Data Manipulation and Graphics
- Using Lattice Graphics
- A Comparison of R and S-Plus
- How can R Complement SAS?
- Writing Functions
- Avoiding Loops
- Vectorization
- Statistical Modeling
- Project Management
- Techniques for Effective use of R and S
- Enhancing Plots
- Using High-level Plotting Functions
- Building and Distributing Packages (libraries)
- Connecting; ODBC, Rweb, Orca via sockets and via Rjava 
Email us for group discounts.
Email Sue Turner: [EMAIL PROTECTED]
Phone: 206-686-1578
Visit us: www.xlsolutions-corp.com/training.htm
Please let us know if you and your colleagues are interested in this
class to take advantage of group discount. Register now to secure your
seat! 
Cheers,
Elvis Miller, PhD
Manager Training.
XLSolutions Corporation
206 686 1578
www.xlsolutions-corp.com
[EMAIL PROTECTED]  
3 Courses - (1) Regression Modeling Strategies in R/Splus (2) R/Splus
Advanced Programming (3) R/Splus Fundamentals

__
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] HH and Rcmdr.HH packages available

2006-08-22 Thread Michael Kubovy
Dear R-helpers,

For those of you who wish to use the useful and interesting HH  
package on the Mac: I successfully downloaded the package from http:// 
astro.temple.edu/~rmh/HH/HH_1.4.tar.gz
Safari routinely upacks archives, so after downloading I had to (in  
the Terminal)
gzip Desktop/H_1.4.tar
and then installed it with the command
sudo R CMD INSTALL Desktop/HH_1.4.tar.gz
_
Professor Michael Kubovy
University of Virginia
Department of Psychology
USPS: P.O.Box 400400Charlottesville, VA 22904-4400
Parcels:Room 102Gilmer Hall
 McCormick RoadCharlottesville, VA 22903
Office:B011+1-434-982-4729
Lab:B019+1-434-982-4751
Fax:+1-434-982-4766
WWW:http://www.people.virginia.edu/~mk9y/

__
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] NonLinearLeastSquares Trust-Region

2006-08-22 Thread Martin Ivanov
Hello!

I am running R-2.3.1-i386-1 on Slackware Linux 10.2. I am a former matlab user, 
moving to R. In matlab, via the cftool, I performed nonlinear curve fitting 
using the method nonlinear least squares with the Trust-Region algorithm 
and not using robust fitting. Is it possible to perform the same  analysis in 
R? I read quite a lot of R documentation, but I could not find an alternative 
solution. If there is such, please forgive my ignorance (I am a newbie in R) 
and tell me which function from which package is capable of performing the same 
analysis. If the same analysis is not possible to carry out in R, I would be 
grateful if you suggest to me some alternative procedure. I found that the 
nls function performs nonlinear least squares. The problem is that I do not 
want to implement the Gauss-Newton algorithm. In the worst case I would be 
contented with the Levenberg-Marquardt algorithm, if it is implemented in R. 
R nls's documentation mentions the  port  package and the 
  ‘nl2sol’ algorithm, but I could not find that package in the CRAN repository, 
so that I could read and judge whether that algorithm would be appropriate.

Thank you very much in advance. I am looking forward to your answer.
Regards,
Martin

-
http://ide.li/ - портал за българите по света. Статии, новини, форуми, снимки, 
информация.

__
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] Escaping ' character

2006-08-22 Thread Marc Schwartz (via MN)
On Tue, 2006-08-22 at 07:32 -0700, Srinivas Iyyer wrote:
 Dear marc: thank you for your tip. 
 
   cat(x.new, \n)
  3\',5\'-cyclic-nucleotide phosphodiesterase activity
  
 
 here cat is printing on screen. 
 
 how can I direct the output to an object. 
 
 I cannot do:
 
 y - cat(x.new, \n)
 
 is there any other way.
 
 thanks
 srini

Srini,

Going back to your initial post, try something like the following using
paste():

 x - 3',5'-cyclic-nucleotide phosphodiesterase activity

 x.new - gsub(', ', x)

#Note the escaping of the single quotes here:
 sql.cmd - paste(fetch_count_fterm_sql(\', (x.new), \');, 
   sep = )

# Beware any line wrapping here
 sql.cmd
[1] fetch_count_fterm_sql('3\\',5\\'-cyclic-nucleotide phosphodiesterase 
activity');


This way the character vector 'sql.cmd' has the full sql query, which
you can then pass to your statement processing code.

I'm not sure how you are passing the code, but if in a text file as
input, you can do something like:

 sink(sqlfile.txt)
 cat(sql.cmd, \n)
 sink()


Where the text file 'sqlfile.txt' will contain the single line:

fetch_count_fterm_sql('3\',5\'-cyclic-nucleotide phosphodiesterase activity'); 

See ?sink for more information.

HTH,

Marc

__
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] Authoring a book

2006-08-22 Thread Tom Backer Johnsen
Me and some colleagues are planning to write a textbook together
(Statistics using R) where the target audience for the book is
psychologists and students of psychology.

We thought that it might be a good idea to use a Wiki when writing the
text.  Is that a good idea?  Does anybody have any experience in that
direction?  What alternatives are there?

The tool (Wiki) would have to be able to handle tables and
mathematical formulas in some manner, and of course, some mechanism to
export the contents to a word processor in the final stages.

I have my own server, Windows, based on Apache, PhP, and MySQL.

Tom

__
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] summary(lm ... conrasts=...)

2006-08-22 Thread Prof Brian Ripley
On Tue, 22 Aug 2006, [EMAIL PROTECTED] wrote:

 Hi Folks,
 
 I've encountered something I hadn't been consciously
 aware of previously, and I'm wondering what the
 explanation might be.

Try

 contr.helmert(letters[1:3])
  [,1] [,2]
a   -1   -1
b1   -1
c02
 contr.treatment(letters[1:3])
  b c
a 0 0
b 1 0
c 0 1

and note the difference in column names.

Those who made the decision to use those column names determined this.
I agreed with them that labelling the second Helmert contrast here as 'c' 
would be confusing, especially easy to confuse with treatment contrasts.
However, I thought the treatment contrasts should be labelled b-a and c-a.
We also had arguments about xc vs x.c vs x:c.  AFAIR brevity won.

Once you know how it is done, it is easy to change the behaviour, of 
course: just roll your own contrasts function with the colnames you want.

 In (on another list) using R to demonstrate the difference
 between different contrasts in 'lm' I set up an example
 where Y is sampled from three different normal distributions
 according to the levels (A,B,C) of a factor X:
 
 Y-c(rnorm(mean=0,n=12),rnorm(mean=2,n=12),rnorm(mean=4,n=12))
 X-factor(c(rep(A,12),rep(B,12),rep(C,12)))
 
 Then I do a summary(lm(Y~X)...) using first Treatment contrasts
 and then Helmert contrasts. Here are the coefficient parts
 of the results in each case:

Just coef() or print() gives you the coefficient names: this is not done 
by summary().

 summary(lm(Y~X,contrasts=list(X=contr.treatment)))
 Coefficients:
 Estimate Std. Error t value Pr(|t|)
 (Intercept)   0.2303 0.3220   0.715  0.47944
 XB1.3057 0.4554   2.867  0.00716 **
 XC3.4204 0.4554   7.511 1.23e-08 ***
 
 
 summary(lm(Y~X,contrasts=list(X=contr.helmert)))
 Coefficients:
 Estimate Std. Error t value Pr(|t|)
 (Intercept)   1.8057 0.1859   9.713 3.34e-11 ***
 X10.6529 0.2277   2.867  0.00716 **
 X20.9225 0.1315   7.017 5.00e-08 ***
 
 
 What I'm wondering is why the effect names are X.B
 and X.C for Treatment, and X1, X2 for Helmert.
 
 Why not X.B and X.C in both cases? Just as XB
 contrasts B with the overall mean and XC contrasts C
 with the overall mean, XA being implicit, in the
 Treatment contrasts, so X1 contrasts B with A and
 X2 contrasts C with (A+B) in Helmert, so there
 is to my mind just as definite an association of B
 with the first contrast, and C with the second, in
 the Helmert case as in the Treatment case!
 
 I know it's just a matter of notation, but in the
 Helmert case the association with the names of the
 factor levels has been lost, and it could be useful
 to have it explicit. (Or is it intended simply as a
 reminder that one is using a particular system of
 contrasts?)
 
 Thanks, and best wishes to all,
 Ted.
 
 
 E-Mail: (Ted Harding) [EMAIL PROTECTED]
 Fax-to-email: +44 (0)870 094 0861
 Date: 22-Aug-06   Time: 14:45:17
 -- XFMail --

-- 
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

__
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] lean and mean lm/glm?

2006-08-22 Thread Charles C. Berry
On Mon, 21 Aug 2006, Damien Moore wrote:


 For very large regression problems there is the biglm package (put you
 data into a database, read in 500,000 rows at a time, and keep updating
 the fit).

 thanks. I took a look at biglm and it seems pretty easy to use and, 
 looking at the source, avoids much of the redundancy of lm. Correct me 
 if i'm wrong, but I think it would be virtually impossible to extend to 
 glm, because of the non-linearity in glm models.

 I might hack around at the source code for glm.fit -- I think I can 
 avoid some of the redundancy involved in that routine pretty easily, but 
 it will mean rewriting the summary output code...


Damien,

If you know what is 'under the hood' of glm, you can use the biglm
approach to perform a one-step update of the coefficients of a glm model.

There is plenty of theory for one-step estimators that use consistent 
estimates as starting values.

You can probably get a good starting value by averaging all of the results 
returned by slicing the data set into smaller pieces and running glm.fit 
on each of them.

Chuck


 cheers
 Damien


 --- On Mon 08/21, Greg Snow  [EMAIL PROTECTED]  wrote:From: Greg Snow 
 [mailto: [EMAIL PROTECTED]: [EMAIL PROTECTED], [EMAIL PROTECTED]: Mon, 21 Aug 
 2006 12:01:06 -0600Subject: RE: [R] lean and mean lm/glm?

 For very large regression problems there is the biglm package (put you
 data into a database, read in 500,000 rows at a time, and keep updating
 the fit).

 This has not been extended to glm yet.

 Hope this helps,


 -- 
 Gregory (Greg) L. Snow Ph.D.
 Statistical Data Center
 Intermountain Healthcare
 [EMAIL PROTECTED]
 (801) 408-8111


 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Damien Moore
 Sent: Monday, August 21, 2006 11:49 AM
 To: r-help@stat.math.ethz.ch
 Subject: [R] lean and mean lm/glm?


 Hi All: I'm new to R and have a few questions about getting R to run
 efficiently with large datasets.

 I'm running R on Windows XP with 1Gb ram (so about 600mb-700mb after the
 usual windows overhead). I have a dataset that has 4 million
 observations and about 20 variables. I want to run probit regressions on
 this data, but can't do this with more than about 500,000 observations
 before I start running out of ram (you could argue that I'm getting
 sufficient precision with 500,000 obs but lets pretend otherwise).
 Loading 500,000 observations into a data frame only takes about 100Mb of
 ram, so that isn't the problem. Instead it seems R uses huge amount of
 memory when running the glm methods. I called the Fortran routines that
 lm and glm use directly but even they create a large number of
 extraneous variables in the output (e.g. the Xs, ys, residuals etc) and
 during processing. For instance (sample code)

 x=runif(100)
 y=3*x+rnorm(100) #I notice this step chews up a lot more than the
 7mb of ram required to store y during processing, but cleans up ok
 afterwards with a gc() call
 X=cbind(x)
 p=ncol(X)
 n=NROW(y)
 ny=NCOL(y)
 tol=1e-7
 #this is the fortran routine called by lm - regressing y on X here z -
 .Fortran(dqrls, qr = X, n = n, p = p, y = y, ny = ny, tol =
 as.double(tol), coefficients = mat.or.vec(p, ny), residuals = y, effects
 = y, rank = integer(1), pivot = 1:p, qraux = double(p), work = double(2
 * p), PACKAGE = base)

 This code runs very quickly - suggesting that in principle R should have
 no problem at all handling very large data sets, but uses 100mb during
 processing and z is about a 20mb object. Scaling this up to a much
 larger dataset with many variables its easy to see i'm going to run into
 problems

 My questions:
 1. are there any memory efficient alternatives to lm/glm in R?
 2. is there any way to prevent the Fortran routine dqrls from
 producing so much output? (I suspect not since its output has to be
 compatible with the summary method, which seems to rely on having a copy
 of all variables instead of just references to the relevant variables -
 correct me if i'm wrong on this) 3. failing 1  2 how easy would it be
 to create new versions of lm and glm that don't use so much memory? (Not
 that I'm volunteering or anything ;) ). There is no need to hold
 individual residuals in memory or make copies of the variables (at least
 for my purposes). How well documented is the source code?

 cheers
 Damien Moore

 __
 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.




[ Part 3.53: Included Message ]


Charles C. Berry(858) 534-2098
  Dept of Family/Preventive Medicine
E mailto:[EMAIL PROTECTED]   UC San Diego
http://biostat.ucsd.edu/~cberry/ La Jolla, San Diego 92093-0717


Re: [R] Rgraphviz installation Problem

2006-08-22 Thread Seth Falcon
j.joshua thomas [EMAIL PROTECTED] writes:

 Dear Robert,

 Thanks for your time.
 I have downloaded Rgraphviz (windows binary) from www.bioconductor.org
 and put inside R2.3.0 library then  i installed from the local zip
 its says package 'graph' couldnot be loaded.

 Am i doing the installation correctly? Still the new user.

 Can you guide me sir?

Questions about BioC packages are best directed to the bioconductor
mailing list.

I would recommend trying:

source(http://bioconductor.org/biocLite.R;)
biocLite(Rgraphviz)


Best,

+ seth

__
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] Successive subsets from a vector?

2006-08-22 Thread Charles C. Berry


Like this:
 do.call( paste, c( list(sep=), lapply(1:5,function(x) 
 VECTOR[x:(length(VECTOR)-5+x)]) ))
[1] 14265   42650   265011  6501110 5011104 0111043 1110436 
104368  43686


HTH,

Chuck

On Tue, 22 Aug 2006, kone wrote:

 I'd like to pick every imbricated five character long subsets from a
 vector. I guess there is some efficient way to do this without loops...
 Here is a for-loop-version and a model for output:

 VECTOR=c(1,4,2,6,5,0,11,10,4,3,6,8,6);

 ADDRESSES=c();
 for(i in 1:(length(VECTOR)-4)){
   ADDRESSES[i]=paste(VECTOR[i:(i+4)],collapse=)
 }

  ADDRESSES
 [1] 14265   42650   265011  6501110 5011104 0111043
 1110436 104368
 [9] 43686


 Atte Tenkanen
 University of Turku, Finland

   [[alternative text/enriched version deleted]]



[ Part 3.64: Included Message ]


Charles C. Berry(858) 534-2098
  Dept of Family/Preventive Medicine
E mailto:[EMAIL PROTECTED]   UC San Diego
http://biostat.ucsd.edu/~cberry/ La Jolla, San Diego 92093-0717

__
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] Selection on dataframe based on order of rows

2006-08-22 Thread Bonfigli Sandro
I have a dataframe with the following structure

iddate value
-
122/08/2006 48
124/08/2006 50
128/08/2006 150
130/08/2006 100
101/09/2006 30
211/08/2006 30
222/08/2006 100
228/08/2006 11
202/09/2006 5
301/07/2006 3
301/08/2006 100
301/09/2006 100
422/08/2006 48
424/08/2006 50
428/08/2006 150
430/08/2006 100
401/09/2006 30
403/09/2006 100
406/09/2006 100


N.B.: dates in european format; ordered dataframe

For each ID I need to select the first occurrence of
all the rows which are the first of at least two with 
value = 50.

Rather convoluted explication. I mean that for each id I have to select
the first row in which value is  50 only if at least the following row 
has value  50 too. If this is not true I repeat the test for all the 
following rows in which value  50 untill I find a record that respects
the condition

this means that with my example dataframe the result is :
iddate value
-
128/08/2006 150
301/08/2006 100
428/08/2006 150

It's clear that a for loop would work but I think that that is a better 
way.

I tried by and could obtain the first row for wich value is  50.

I thought of an iterative process (delete the first row  50, find the 
second row  50, examine if there are rows in the middle) but it
is quite inelegant as if the first value is not the good one I have to 
repeat the process for a a priori unknown number of times.

Thanks in advance for Your help

  Sandro Bonfigli

__
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] Marginal Predicitions from nlme and lme4

2006-08-22 Thread Rick Bilonick
Is there a way (simple or not) to get the marginal prediction from lme
(in nlme) and/or lmer (in lme4)?

Rick B.

__
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] Successive subsets from a vector?

2006-08-22 Thread Gabor Grothendieck
Here is a solution that uses gsub with a negative lookahead perl-style
regexp to do it:

VECTOR - c(1,4,2,6,5,0,11,10,4,3,6,8,6)
e - 
([[:digit:]]+),(?=([[:digit:]]+),([[:digit:]]+),([[:digit:]]+),([[:digit:]]+))
out - gsub(e, \\1\\2\\3\\4\\5 , paste(VECTOR, collapse = ,), perl = TRUE)
head(strsplit(out,  )[[1]], -1)  # uses head from R 2.4.0


On 8/22/06, kone [EMAIL PROTECTED] wrote:
 I'd like to pick every imbricated five character long subsets from a
 vector. I guess there is some efficient way to do this without loops...
 Here is a for-loop-version and a model for output:

 VECTOR=c(1,4,2,6,5,0,11,10,4,3,6,8,6);

 ADDRESSES=c();
 for(i in 1:(length(VECTOR)-4)){
ADDRESSES[i]=paste(VECTOR[i:(i+4)],collapse=)
 }

   ADDRESSES
 [1] 14265   42650   265011  6501110 5011104 0111043
 1110436 104368
 [9] 43686


 Atte Tenkanen
 University of Turku, Finland

[[alternative text/enriched version deleted]]

 __
 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-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] Mac os

2006-08-22 Thread jason pienaar
Dear Sir / Madam

Hi, I have written some code For R that uses for loops to do
2-dimensional grid searches for maximum likelhood combined with
iterated GLS estimation. As can be expected, depending on the szie of
the grid, estimation can take quite some time. However, I have noticed
that the same code run on a windows operating system is much faster
than when run on a Mac (I basically paste the code into the console
and then run things from there). I was wondering if anyone knew if
this is typical, or if there is some good reason for this? (I am not
that familiar with the mac operating system, so might be missing
something obvious). I am writing a user manual for the code and would
like to have some explanation (or possible improvement) for mac users,
so any info on this would be much appreciated
Sincerely
Jason Pienaar

__
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] new version of The R Guide available on CRAN

2006-08-22 Thread Henrik Bengtsson
Hi,

thanks for this.  I'll keep it in mind next time in teaching/referring
someone to R.  BTW, before the R-core guys get you ;)   Just replace
all places where you use library to refer to a package (see all
comments on the definition of these on r-help/r-devel), e.g.

Page 17: FYI, .GlobalEnv is your workspace and the package quantities
are libraries that contain (among other things) the functions and
datasets that we are learning about in this manual.

Cheers

Henrik

On 8/22/06, Owen, Jason [EMAIL PROTECTED] wrote:
 Hello,

 Version 2.2 of The R Guide is available for download in
 the Contributed Documents section on CRAN.  The R Guide
 is written for the beginning R user.  I use the guide in my
 undergraduate probability and math stat sequence, but anyone
 with a basic understanding of statistics (who wants to learn
 R) should find it useful.

 This updated version includes sections on multiple comparisons,
 optimization, along with some improvements suggested by fellow
 R users from around the world.  The entire document is under
 60 pages in length.

 Jason
 --
 Assistant Professor of Statistics
 Mathematics and Computer Science Department
 University of Richmond, Virginia 23173
 (804) 289-8081   fax:(804) 287-6664
 http://www.mathcs.richmond.edu/~wowen

 This is R. There is no if. Only how.
 Simon (Yoda) Blomberg

 __
 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-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] a generic Adaptive Gauss Quadrature function in R?

2006-08-22 Thread Lei Liu
Hi there,

I am using SAS Proc NLMIXED to maximize a likelihood with 
multivariate normal random effects. An example is the two part random 
effects model for repeated measures semi-continous data with a 
cluster at 0. I use the model y ~ general(loglike) statement in 
Proc NLMIXED, so I can specify a general log likelihood function 
constructed by SAS programming statements. Then the likelihood can be 
maximized by AGQ. Is there a similar generic AGQ function in R to let 
me write explicitly the log likelihood and then maximize it 
accordingly? Can nlme do the work? Thanks!

Lei Liu
Assistant Professor
Division of Biostatistics and Epidemiology
Department of Public Health Sciences
School of Medicine
University of Virginia

3181 Hospital West Complex
Charlottesville, VA 22908-0717

1-434-982-3364 (o)
1-434-806-8086 (c)
1-434-243-5787 (f)

[EMAIL PROTECTED]
[EMAIL PROTECTED]

__
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] aggregate example : where is the state.region variable?

2006-08-22 Thread John Kane

--- Richard M. Heiberger [EMAIL PROTECTED] wrote:

  there is
  no factor in the dataset but why there is not one
 and
  why a call to another dataset is totally opaque.  
 
 The reason is purely historical.  The state dataset
 is about
 10 years older than the data.frame concept.  At the
 time the
 state.* variables were constructed it was not
 possible to put
 numeric data and factor data into the same
 rectangular structure.

I see. So originally the example would have been more
obvious.  Thanks

__
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] Question on R Training

2006-08-22 Thread jeffrey ludlow
Dear R users, 
   
  The R Project website doesn't seem to have any links devoted to R training. 
Are there any R trainers out there?
   
  Thank you for your help!
   
  Jeffrey V. Ludlow 
   
   


-

[[alternative HTML version deleted]]

__
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] Marginal Predicitions from nlme and lme4

2006-08-22 Thread Andrew Robinson
Rick,

if by marginal prediction, you mean the prediction without random
effects, then use the level argument.  See ?predict.lme or ?fitted.lme

If not then I don't know :)

Cheers

Andrew

On Tue, Aug 22, 2006 at 02:27:06PM -0400, Rick Bilonick wrote:
 Is there a way (simple or not) to get the marginal prediction from lme
 (in nlme) and/or lmer (in lme4)?
 
 Rick B.
 
 __
 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.

-- 
Andrew Robinson  
Department of Mathematics and StatisticsTel: +61-3-8344-9763
University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599
Email: [EMAIL PROTECTED] http://www.ms.unimelb.edu.au

__
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] how to run ANCOVA?

2006-08-22 Thread Sasha Wolosin
Dear all,

  I would like to know how to run an analysis of covariance in R.  For
example, I have a data frame (data) consisting of two second-degree
categorical variables (diagnosis and gender), one continous
independent variable (age) and one continous dependent variable
(response).

I ran a simple anova to see the effects of diagnosis and gender (and
interaction):

aov.out - aov(response~diagnosis*gender,data)
anova(aov.out)

Now I would like to covary for age, how can I add age as a covariate
to this equation?

Thanks,
Sasha

__
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] error message from lm.ridge() in MASS library

2006-08-22 Thread jz7
Dear all,

I got a wierd problem when using lm.ridge() in MASS library. When my X
matrix has few columns, there is no problem. But when my X matrix gets
larger (over 1000 columns),  I got the following error:

Error in Xs$v %*% a : non-conformable arguments
In addition: Warning messages:
1: longer object length
is not a multiple of shorter object length in: d^2 + rep(lambda,
rep(p, k))
2: longer object length
is not a multiple of shorter object length in: drop(d * rhs)/div

The R code I use for the calculation is lm.ridge( y ~ x,lambda=seq(1,15,1)).

Please advice.

Thanks a lot!
Jeny

__
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 is wonderful

2006-08-22 Thread justin bem
I have always find heaveyweight solutions while use R. If I were rich, I would 
have made a great donation to R fundation ...
 


[[alternative HTML version deleted]]

__
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] Marginal Predicitions from nlme and lme4

2006-08-22 Thread Rick Bilonick
On Wed, 2006-08-23 at 06:43 +1000, Andrew Robinson wrote:
 Rick,
 
 if by marginal prediction, you mean the prediction without random
 effects, then use the level argument.  See ?predict.lme or ?fitted.lme
 
 If not then I don't know :)
 
 Cheers
 
 Andrew
Thanks. I'm familiar with level in predict and fitted for lme. These
allow you to select the fixed effects and/or the random effects. The
marginal prediction integrates out the random effects and is what a GEE
marginal model produces. From what I've read, the marginal effects seem
to be less desirable than the fixed effects from an lme or a generalized
lme. But I would still like to compute them for comparison.

Rick B.

__
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] rpart output: rule extraction beyond path.rpart()

2006-08-22 Thread Bryant, Benjamin
 

Greetings - 

 

Is there a way to automatically perform what I believe is called rule
extraction (by Quinlan and the machine learning community at least) for
the leaves of trees generated by rpart?  I can use path.rpart() to
automatically extract the paths to the leaves, but these can be
needlessly cumbersome.  For example, one path returned by path.rpart()
might be:

 

[1] root   y=-0.1905 y 0.1495  z=-0.19   z 0.1785 

[6] y=-0.1385 z=-0.153  x 0.37x=-0.363

 

But the y = -0.1905 and z=-.19 are both redundant, given restrictions
placed further down the tree.  Simplifying the paths by hand is feasible
for small trees but quite cumbersome when dimensionality increases.  I
can think of ways to write code to do this automatically, but would
prefer not to if it's already implemented.  I have done extensive
searching and turned up nothing, but I fear I might just be lacking the
right terminology.  Any thoughts?

 

Much appreciated,

-Ben

 

Ben Bryant

Doctoral Fellow

Pardee RAND Graduate School   

[EMAIL PROTECTED]

 

 





This email message is for the sole use of the intended recip...{{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.


Re: [R] Marginal Predicitions from nlme and lme4

2006-08-22 Thread Thomas Lumley
On Tue, 22 Aug 2006, Rick Bilonick wrote:

 On Wed, 2006-08-23 at 06:43 +1000, Andrew Robinson wrote:
 Rick,

 if by marginal prediction, you mean the prediction without random
 effects, then use the level argument.  See ?predict.lme or ?fitted.lme

 If not then I don't know :)

 Cheers

 Andrew
 Thanks. I'm familiar with level in predict and fitted for lme. These
 allow you to select the fixed effects and/or the random effects. The
 marginal prediction integrates out the random effects and is what a GEE
 marginal model produces. From what I've read, the marginal effects seem
 to be less desirable than the fixed effects from an lme or a generalized
 lme. But I would still like to compute them for comparison.


I don't agree that they are less useful, but they are not in general easy 
to obtain from a GLMM.  For any linear link model or a log link model that 
has only random intercepts the marginal and conditional effects are the 
same.  For the probit model there is a conversion formula, but for other 
models they typically require high-dimensional integration to compute.

It's easy just to fit a marginal glm if you want marginal coefficients and 
a mixed model if you want conditional coefficients.

-thomas

__
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] Selection on dataframe based on order of rows

2006-08-22 Thread Gabor Grothendieck
Try this:

# data
DF - structure(list(id = c(1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4,
4, 4, 4, 4, 4, 4), date = structure(c(8, 9, 10, 11, 3, 7, 8,
10, 4, 1, 2, 3, 8, 9, 10, 11, 3, 5, 6), .Label = c(01/07/2006,
01/08/2006, 01/09/2006, 02/09/2006, 03/09/2006, 06/09/2006,
11/08/2006, 22/08/2006, 24/08/2006, 28/08/2006, 30/08/2006
), class = factor), value = c(48, 50, 150, 100, 30, 30, 100,
11, 5, 3, 100, 100, 48, 50, 150, 100, 30, 100, 100)), .Names = c(id,
date, value), class = data.frame, row.names = c(1, 2,
3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19))

f - function(x) {
idx - which(x$value  50  c(x$value[-1], 0)  50)
if (length(idx)  0) x[idx[1],]
}
do.call(rbind, by(DF, DF$id, f))


On 8/22/06, Bonfigli Sandro [EMAIL PROTECTED] wrote:
 I have a dataframe with the following structure

 iddate value
 -
 122/08/2006 48
 124/08/2006 50
 128/08/2006 150
 130/08/2006 100
 101/09/2006 30
 211/08/2006 30
 222/08/2006 100
 228/08/2006 11
 202/09/2006 5
 301/07/2006 3
 301/08/2006 100
 301/09/2006 100
 422/08/2006 48
 424/08/2006 50
 428/08/2006 150
 430/08/2006 100
 401/09/2006 30
 403/09/2006 100
 406/09/2006 100


 N.B.: dates in european format; ordered dataframe

 For each ID I need to select the first occurrence of
 all the rows which are the first of at least two with
 value = 50.

 Rather convoluted explication. I mean that for each id I have to select
 the first row in which value is  50 only if at least the following row
 has value  50 too. If this is not true I repeat the test for all the
 following rows in which value  50 untill I find a record that respects
 the condition

 this means that with my example dataframe the result is :
 iddate value
 -
 128/08/2006 150
 301/08/2006 100
 428/08/2006 150

 It's clear that a for loop would work but I think that that is a better
 way.

 I tried by and could obtain the first row for wich value is  50.

 I thought of an iterative process (delete the first row  50, find the
 second row  50, examine if there are rows in the middle) but it
 is quite inelegant as if the first value is not the good one I have to
 repeat the process for a a priori unknown number of times.

 Thanks in advance for Your help

  Sandro Bonfigli

 __
 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-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] Rtangle in R-2.3.1

2006-08-22 Thread Samprit Banerjee
Simply using Rtangle(file.Rnw) gives the following error message in R-2.3.1. 
It used to work fine with the earlier versions of R. 
   
   Rtangle(qtlbim.Rnw)
Error in Rtangle(qtlbim.Rnw) : unused argument(s) ( ...)
   RtangleSetup(file=qtlbim.Rnw,output=qtlbim.R)
Writing to file qtlbim.R
Error in RtangleSetup(file = qtlbim.Rnw, output = qtlbim.R) :
argument syntax is missing, with no default


-


[[alternative HTML version deleted]]

__
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] Question on R Training

2006-08-22 Thread eugene dalt
Check out with XLSolutions Corp  
[EMAIL PROTECTED]

--- jeffrey ludlow [EMAIL PROTECTED] wrote:

 Dear R users, 

   The R Project website doesn't seem to have any
 links devoted to R training. Are there any R
 trainers out there?

   Thank you for your help!

   Jeffrey V. Ludlow 


 
   
 -
 
   [[alternative HTML version deleted]]
 
 __
 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-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] how to complete this task on data management

2006-08-22 Thread zhijie zhang
Dear friends,
 When i clean my dataset , i met a difficulty
 suppose my data set is :
* data-data.frame(x=c(1:5,1,2,3))
 data
  x
1 1
2 2
3 3
4 4
5 5*
6 1
7 2
8 3
Now i need to add the data which are less than 3.5 at the bottom, not
including the top data, so the results should be :
  x
1 1
2 2
3 3
4 4
5 5
*6 6*
I tried to use  data[data$x3.5,] to do it , but it also delete the first
several numbers,* How to finish it ?*
Thanks very much.
-- 
Kind Regards,
Zhi Jie,Zhang

[[alternative HTML version deleted]]

__
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] glm inside one self-defined function

2006-08-22 Thread Mike Wolfgang
Hi list,

I've searched in R-help and found some related discussions but still could
not understand this type of error. My own function is pretty complex, so I
would not put it here, but the basic algorithm is like this:
myfun-function(k){
  mydata-...#by someway I create a data frame
  mymodel-glm(y~.,family=binomial(),data=mydata)
  ...#some other stuff
}


as I execute this function, it gives error like this
Error in inherits(x, data.frame) : object mydata not found

So I guess glm here tries to find mydata in the parent environment. Why
doesn't it take mydata inside the function? How to let glm correctly
locate it? Is this (scope/environment) mentioned in R manual? Thanks,

Mike

[[alternative HTML version deleted]]

__
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] glm inside one self-defined function

2006-08-22 Thread Bill.Venables
Mike Wolfgang asks:


 From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Mike Wolfgang
 Sent: Wednesday, 23 August 2006 1:31 PM
 To: R-help list
 Subject: [R] glm inside one self-defined function
 
 Hi list,
 
 I've searched in R-help and found some related discussions but still
could
 not understand this type of error. My own function is pretty complex,
so I
 would not put it here, but the basic algorithm is like this:
 myfun-function(k){
   mydata-...#by someway I create a data frame
   mymodel-glm(y~.,family=binomial(),data=mydata)
   ...#some other stuff
 }

I think you are leaving out something.  Here is a test of what you
claim gives a problem (R 2.3.1, Windows):

 myfun - function(n) {
+   z - rnorm(n)
+   mydata - data.frame(x = z, 
+ y = rbinom(n, size = 1, prob = exp(z)/(1+exp(z
+   fm - glm(y ~ x, binomial, mydata)
+   fm
+ }
 
 myfun(100)

Call:  glm(formula = y ~ x, family = binomial, data = mydata) 

Coefficients:
(Intercept)x  
 0.1587   1.0223  

Degrees of Freedom: 99 Total (i.e. Null);  98 Residual
Null Deviance:  137.6 
Residual Deviance: 118.3AIC: 122.3 

Not even a murmur of complaint.  (This also works in S-PLUS 7.0 but
earlier versions of S-PLUS gave a problem rather like the one you note,
curiously.)

Look again at your code and see if the abstract version you give
really matches what you did, may I suggest?

 
 as I execute this function, it gives error like this
 Error in inherits(x, data.frame) : object mydata not found
 
 So I guess glm here tries to find mydata in the parent environment.
Why
 doesn't it take mydata inside the function? How to let glm correctly
 locate it? Is this (scope/environment) mentioned in R manual? Thanks,
 
 Mike

__
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] R is wonderful

2006-08-22 Thread gyadav

Hi All,

I have also similar feelings for R. I really thank each and every one in 
the R community for joining together to Create R and Spread R.

thanks

   Sayonara With Smile  With Warm Regards :-)

  G a u r a v   Y a d a v
  Senior Executive Officer,
  Economic Research  Surveillance Department,
  Clearing Corporation Of India Limited.

  Address: 5th, 6th, 7th Floor, Trade Wing 'C',  Kamala City, S.B. Marg, 
Mumbai - 400 013
  Telephone(Office): - +91 022 6663 9398 ,  Mobile(Personal) (0)9821286118
  Email(Office) :- [EMAIL PROTECTED] ,  Email(Personal) :- 
[EMAIL PROTECTED]



DISCLAIMER AND CONFIDENTIALITY CAUTION:\ \ This message and ...{{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.


Re: [R] how to run ANCOVA?

2006-08-22 Thread Richard M. Heiberger
  aov.out - aov(response~diagnosis*gender,data)

Just add it where you think it belongs in the
sequential sum of squares

To adjust the factors for the covariate use
aov.out - aov(response ~ age + diagnosis*gender, data)

To adjust the covariate for the factors
aov.out - aov(response ~ diagnosis*gender + age, data)

If you want to check for interaction of the factors with the
covariate, then use * instead of + in the formula.

Please note that I added spaces to your statement to improve human legibility.

Rich

__
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.