Re: [R] Generalized Estimating Equations and log-likelihood calculation

2004-02-18 Thread Prof Brian Ripley
On Wed, 18 Feb 2004 [EMAIL PROTECTED] wrote:

> I'm working with clustered data sets and trying to calculate log-likelihood 
> (and/or AIC, AICc) for my models.  In using the gee and geese packages one 
> gets Wald test output; but apparently there is no no applicable method 
> for "logLik" (log-likelihood)calculation.
> 
> Is anyone aware of a way to calculate log-likelihood for GEE models?

No (as with GLM quasi- models, it is not defined in general).  Even if
there were, you would have find the maximized log-likelihood to find AIC,
and by definition GEE is not ML fitting except in a few special cases.

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

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] surprising revelation

2004-02-18 Thread Rafael A. Irizarry
apologies for the off-topic mail but i cant resist sharing this:
>From CNN:
(http://www.cnn.com/2004/ALLPOLITICS/02/18/elec04.prez.bush.jobs.ap/index.html)

"The White House backed away Wednesday from its own prediction that the
economy will add 2.6 million new jobs before the end of this year, saying
the forecast was the work of number-crunchers and that President Bush was
not a statistician."

i thought i remembered him posting something on this list...
asking about fuzzy math.. and that someone suggested: "do read a
book on arithmetics"

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] boostrapping at R

2004-02-18 Thread Jason Turner
> Friends:
>
> How can I do boostrapping at R?
>
> Thanks

library(boot)
help(boot)

Cheers

Jason

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] boostrapping at R

2004-02-18 Thread Mahmoud K. Okasha
Hi,

After reading your data you can use functions such as :
bts <- numeric (500)
for (i in 1:500) bts[i] <- sample(yourdata, replace=TRUE)

Regards

- Original Message -
From: "Ricardo Huaman" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, February 18, 2004 10:59 PM
Subject: [R] boostrapping at R


> Friends:
>
> How can I do boostrapping at R?
>
> Thanks
>
> Ricardo.
> [[alternative HTML version deleted]]
>
> __
> [EMAIL PROTECTED] mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
>
>

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] latex problem with Sweave output file under Debian

2004-02-18 Thread Friedrich . Leisch
> On Wed, 18 Feb 2004 18:19:48 -0600 (CST),
> Dan Davison (DD) wrote:

  > Could someone tell me how to end the trouble I'm encountering when
  > running latex on the .tex file produced by Sweave()? Sweave() seems to
  > process the example file
  > (http://www.ci.tuwien.ac.at/~leisch/Sweave/example-1.Snw) without
  > problems, and the file example-1.tex produced is the same as in the Sweave
  > manual. However, when I run latex on example-1.tex, many error messages
  > and requests for user input are generated (below). And when I view the
  > .dvi that eventually results with xdvi it is empty apart from a small
  > graphic containing the box plot that shouldbe there; there is no text.
  > latex produces apparently perfect .dvi files when the .tex files are 
  > not produced by Sweave.

[...]

  > ! LaTeX Error: File `ae.sty' not found.

  > Type X to quit or  to proceed,
  > or enter new name. (Default extension: sty)

  > Enter file name: 

  > ! LaTeX Error: File `fancyvrb.sty' not found.

  > Type X to quit or  to proceed,
  > or enter new name. (Default extension: sty)

  > Enter file name: 


Well, both ae.sty and fancyvrb.sty seem not to be installed on your
system ... probably you don't have the tetex-extra package installed.

.f

-- 
---
Friedrich Leisch 
Institut für Statistik Tel: (+43 1) 58801 10715
Technische Universität WienFax: (+43 1) 58801 10798
Wiedner Hauptstraße 8-10/1071  [EMAIL PROTECTED]
A-1040 Wien, Austria http://www.ci.tuwien.ac.at/~leisch

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] NAs introduced by coercion warning?

2004-02-18 Thread Jonathan Greenberg
Its hard for me to pinpoint where this is happening, since I'm working on an
image that¹s about 1 x 2 pixels, and 12 bands deep and I'm using a
set of for-next loops to pull out subsections of data.  I can guarantee the
input values are all floating point values.

To be more specific, I have created a classification tree, and I want to
apply it to that large floating point image (all the band names match up)
and write the prediction (probability) values to a file.  What happens if a
decision tree tries to classify a set of input values that are completely
outside of the range of the input tree?

Here's the code I was using.  I should mention that this worked on a small
subset (400 x 400 pixels) that wouldn't have any "weird" values (negative or
zero).  The output file from this is turning out to be slightly smaller than
it should given the samples,lines,bands and number type, which I why I'm
wondering if the tree is simply dropping those "bad" values rather than
giving them some value (e.g. 0):

## Creating the tree
library(tree)
bands=12
bandnames<-paste(c("B"),1:bands,sep="")
treetraindata=read.csv("classtrainshad040205.csv",header=TRUE)
names(treetraindata)[2:6]<-bandnames[1:5]
names(treetraindata)[8:14]<-bandnames[6:12]
treetraindata$Class_Name<-as.factor(treetraindata$Class_Name)

## Create an overfit tree
treetrain<-tree(Class_Name ~ B1 + B2 + B3 +
B4+B5+B6+B7+B8+B9+B10+B11+B12,treetraindata,mincut=1,minsize=2,mindev=0)

## Extracts a slice of data out of an ENVI BSQ file
envigetslice<-function(fileconnection,samples,lines,bands,interleave,datatyp
e,maxpixels) {
currentloc=seek(fileconnection,where=NA,origin="current")
## If data is integer
if(datatype==3) {
numbersize=2
datatype=integer()
if ((samples*lines)-(currentloc/numbersize) < maxpixels)
maxpixels=(samples*lines)-(currentloc/numbersize)
envislice <-
readBin(fileconnection,integer(),maxpixels,size=numbersize)
newloc=seek(fileconnection,where=NA,origin="current")
if (bands > 1) {
for (i in 1:(bands-1)) {

seek(fileconnection,where=currentloc+(samples*lines*numbersize*i),origin="st
art")
currentslice <-
readBin(fileconnection,integer(),maxpixels,size=numbersize)
envislice=data.frame(envislice,currentslice)
}
}
}
## If data is floating point
if(datatype==4) {
numbersize=4
if ((samples*lines)-(currentloc/numbersize) < maxpixels)
maxpixels=(samples*lines)-(currentloc/numbersize)
envislice <-
readBin(fileconnection,double(),maxpixels,size=numbersize)
newloc=seek(fileconnection,where=NA,origin="current")
if (bands > 1) {
for (i in 1:(bands-1)) {

seek(fileconnection,where=currentloc+(samples*lines*numbersize*i),origin="st
art")
currentslice <-
readBin(fileconnection,double(),maxpixels,size=numbersize)
envislice=data.frame(envislice,currentslice)
}
}
}
seek(fileconnection,where=newloc,origin="start")
envislice
}

## Read ENVI files in subsets
## interleave: 1=bsq
## datatype: (follows ENVI format):
##3: long integer
##4:floating point


## Apply the classifier
imageclasstree<-function(infile,outfile,dectree,samples,lines,bands,interlea
ve,datatype,maxpixels) {

fileconnection<-file(infile,open="rb")
outfileconnection=file(outfile,open="wb")

numpixels = samples * lines
numslices=ceiling(numpixels/maxpixels)
if (numslices == floor(numpixels/maxpixels)) numslices=numslices-1

bandnames<-paste(c("B"),1:bands,sep="")

## Loop for processing images
for(j in 0:numslices) {
print((j/numslices)*100)

envislice<-envigetslice(fileconnection,samples,lines,bands,interleave,dataty
pe,maxpixels)
names(envislice)<-bandnames
predictslice<-predict(treetrain,envislice,type=c("vector"))

predictslice<-as.integer(round(as.vector(t(predictslice*1)),digits=0))
predictslice
writeBin(predictslice,outfileconnection,size=2)
}
close(fileconnection)
close(outfileconnection)
}

imageclasstree("flt4aall","flt4adt", treetrain,11216,18173,12,1,4,25000)

On 2/18/04 2:25 PM, "Sundar Dorai-Raj" <[EMAIL PROTECTED]> wrote:

> 
> 
> Jonathan Greenberg wrote:
> 
>> I'm running a decision tree on a large dataset, and I'm getting multiple
>> instances of "NAs introduced by coercion" (> 50).  What does this mean?
>> 
>> --j
>> 
> 
> My guess would be you're trying to convert from character to numeric and
> are unable to do so. As in,
> 
>> as.numeric("A")
> [1] NA
> Warning message:
> NAs introduced by coercion
>> as.numeric("1")
> [1] 1
>> 
> 
> But without more information from you it's impossible to tell.
> 
> See the posting guide at
> 
> http://www.R-project.org/posting-guide.html
> 
> Regards,
> Sundar
> 


-- 
Jonathan Greenberg
Graduate Group in Ecology, U.C. Davis
http://www.cstars.ucdavis.edu/~jongreen
http://www.cstars.ucdavis.edu
AIM: jgrn307 or jgrn3007

Re: [R] citation() doesn?t work

2004-02-18 Thread Alistair Campbell
Hi,

I am using R 1.8.1 on Windows XP and get the following from calling 
citation():

To cite R in publications, use

  R Development Core Team (2004). R: A language and environment for
  statistical computing. R Foundation for Statistical Computing,
  Vienna, Austria. ISBN 3-900051-00-3, URL http://www.R-project.org.
We have invested a lot of effort in creating R, please cite it when
using it for data analysis.
A BibTeX entry for LaTeX users is

  @Manual{,
 title= {R: A language and environment for
 statistical computing},
 author   = {{R Development Core Team}},
 organization = {R Foundation for Statistical Computing},
 address  = {Vienna, Austria},
 year = 2004,
 note = {ISBN 3-900051-00-3},
 url  = {http://www.R-project.org}
   }


Seems to work.

Alistair Campbell
James Cook University
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Conjugate function found disregard pervious posting...

2004-02-18 Thread Andy Bunn
Sorry for the previous posting. I found the function in ?complex. My
apologies. -Andy

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] NAs introduced by coercion warning?

2004-02-18 Thread Sundar Dorai-Raj


Jonathan Greenberg wrote:

I'm running a decision tree on a large dataset, and I'm getting multiple
instances of "NAs introduced by coercion" (> 50).  What does this mean?
--j

My guess would be you're trying to convert from character to numeric and 
are unable to do so. As in,

> as.numeric("A")
[1] NA
Warning message:
NAs introduced by coercion
> as.numeric("1")
[1] 1
>
But without more information from you it's impossible to tell.

See the posting guide at

http://www.R-project.org/posting-guide.html

Regards,
Sundar
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] boostrapping at R

2004-02-18 Thread Ricardo Huaman
Friends:

How can I do boostrapping at R?

Thanks

Ricardo.
[[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Complex conjugate?

2004-02-18 Thread Jason Turner
> Is there a function in R that returns the complex conjugate of a matrix
> (a la 'CONJ' in IDL or 'Conjugate' in Mathmatica)?
>

?complex

Cheers

Jason

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] building the development version

2004-02-18 Thread Deborah Swayne
Peter Dalgaard writes:
 > 
 > OK, that I can confirm. They do turn up on a checkout without the -P
 > option, but disappear after "cvs up -Pd". Tony, Debbie, did you
 > perhaps configure before attempting to prune the empty dirs? Could you
 > try 
 > 
 > cvs -d ...blabla... co -P R

I've use rsync; I don't know if that makes any difference:
   rsync -rC rsync.r-project.org::r-devel R

In any case, I deleted all the old source code and started over,
and the development version emerged without any difficulty.

Thanks for helping me think about this.

Debby

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Complex conjugate?

2004-02-18 Thread Andy Bunn
Is there a function in R that returns the complex conjugate of a matrix
(a la 'CONJ' in IDL or 'Conjugate' in Mathmatica)?

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] overlay points on plot

2004-02-18 Thread Spencer Graves
 What do you get from the following: 

 class(v)
 class(v[2])
 If class(v) is "list", then class(v[2]) will also be "list".  In 
that case try the following: 

	points(v[[2]],v[[3]])

   
 hope this helps.  spencer graves

femke wrote:

Dear R-help list,

I'm trying to overlay a number of data objects in a plot.  Following an earlier example on the list I've created an empty plot as follows

 

xlim <- range(as.numeric(c("0","1")))
ylim <- range(as.numeric(c("0","25")) )
plot(NA, xlim=xlim, ylim=ylim, xlab="distance", ylab="semivariance")
   

However when I try to plot something on it, I get the following error:

 

points(v[2],v[3])
   

Error in as.double.default(x) : (list) object cannot be coerced to double

A sample of my data looks like the following V[2]:

  gamma
1   0.04
2   0.582500
3   1.574545
4   7.126500
.
and V[3]:

   dist
1   470.0426
2  1045.6365
3  1607.1936

Does anyone have any idea how to fix this?  

Thanks very much,

femke
[[alternative HTML version deleted]]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
 

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] latex problem with Sweave output file under Debian

2004-02-18 Thread Dan Davison
Could someone tell me how to end the trouble I'm encountering when
running latex on the .tex file produced by Sweave()? Sweave() seems to
process the example file
(http://www.ci.tuwien.ac.at/~leisch/Sweave/example-1.Snw) without
problems, and the file example-1.tex produced is the same as in the Sweave
manual. However, when I run latex on example-1.tex, many error messages
and requests for user input are generated (below). And when I view the
.dvi that eventually results with xdvi it is empty apart from a small
graphic containing the box plot that shouldbe there; there is no text.
latex produces apparently perfect .dvi files when the .tex files are 
not produced by Sweave.

Some of the error messages (log file pasted below) that result from the
command latex include: 

kpathsea: Running mktexmf  ecrm1000
! I can't find file `ecrm1000'.
! Font T1/cmr/m/n/10=ecrm1000 at 10.0pt not loadable: Metric (TFM) file 
not found.
! LaTeX Error: File `ae.sty' not found. 
! LaTeX Error: File `fancyvrb.sty' not found. 
! LaTeX Error: Missing \begin{document}.

I downloaded the missing files and tried (I had no idea) putting them in
/usr/share/texmf/tex/latex/graphics/ and /usr/lib/R/share/texmf/ with no
apparent effect. I am using R Version 1.8.1 under Debian linux, with the
tetex Debian-stable package.

Thanks (and apologies if this is OT or if this is too much text),
Dan

Here is the contents of the example-1.log file, with some similar repeated
lines cut out:

This is TeX, Version 3.14159 (Web2C 7.4.5) (format=latex 2004.2.3)  18 FEB
2004 13:01
**example-1.tex
(./example-1.tex
LaTeX2e <2001/06/01>
Babel  and hyphenation patterns for american, french, ngerman,
portuges,
 nohyphenation, loaded.
(/usr/share/texmf/tex/latex/base/article.cls
Document Class: article 2001/04/21 v1.4e Standard LaTeX document class
(/usr/share/texmf/tex/latex/base/size10.clo
File: size10.clo 2001/04/21 v1.4e Standard LaTeX file (size option)
)
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
\abovecaptionskip=\skip41
\belowcaptionskip=\skip42
\bibindent=\dimen102
)
(/usr/lib/R/share/texmf/Sweave.sty
(/usr/share/texmf/tex/latex/base/fontenc.sty
Package: fontenc 2001/06/05 v1.94 Standard LaTeX package
(/usr/share/texmf/tex/latex/base/t1enc.def
File: t1enc.def 2001/06/05 v1.94 Standard LaTeX file
LaTeX Font Info:Redeclaring font encoding T1 on input line 38.
)
! Font T1/cmr/m/n/10=ecrm1000 at 10.0pt not loadable: Metric (TFM) file
not fou
nd.
 
   relax 
l.95 \fontencoding\encodingdefault\selectfont
 
? ^^[[2;5~
Type  to proceed, S to scroll future error messages,
R to run without stopping, Q to run quietly,
I to insert something, E to edit your file,
1 or ... or 9 to ignore the next 1 to 9 tokens of input,
H for help, X to quit.
? 
) (/usr/share/texmf/tex/latex/graphics/graphicx.sty
Package: graphicx 1999/02/16 v1.0f Enhanced LaTeX Graphics (DPC,SPQR)

(/usr/share/texmf/tex/latex/graphics/keyval.sty
Package: keyval 1999/03/16 v1.13 key=value parser (DPC)
[EMAIL PROTECTED]@=\toks14
)
(/usr/share/texmf/tex/latex/graphics/graphics.sty
Package: graphics 2001/07/07 v1.0n Standard LaTeX Graphics (DPC,SPQR)

(/usr/share/texmf/tex/latex/graphics/trig.sty
Package: trig 1999/03/16 v1.09 sin cos tan (DPC)
)
(/usr/share/texmf/tex/latex/config/graphics.cfg
File: graphics.cfg 2001/08/31 v1.1 graphics configuration of teTeX/TeXLive
)
Package graphics Info: Driver file: dvips.def on input line 80.

(/usr/share/texmf/tex/latex/graphics/dvips.def
File: dvips.def 1999/02/16 v3.0i Driver-dependant file (DPC,SPQR)
))
[EMAIL PROTECTED]@height=\dimen103
[EMAIL PROTECTED]@width=\dimen104
)

! LaTeX Error: File `ae.sty' not found.

Type X to quit or  to proceed,
or enter new name. (Default extension: sty)

Enter file name: 

! LaTeX Error: File `fancyvrb.sty' not found.

Type X to quit or  to proceed,
or enter new name. (Default extension: sty)

Enter file name: 
! Undefined control sequence.
l.6 \DefineVerbatimEnvironment
  {Sinput}{Verbatim}{fontshape=sl}
? 

! LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H   for immediate help.
 ...  
  
l.6 \DefineVerbatimEnvironment{S
input}{Verbatim}{fontshape=sl}
? 
Missing character: There is no S in font nullfont!
{...similar lines...}


Missing character: There is no s in font nullfont!
Missing character: There is no l in font nullfont!
! Undefined control sequence.
l.7 \DefineVerbatimEnvironment
  {Soutput}{Verbatim}{}
? 
Missing character: There is no S in font nullfont!
{...similar lines...}

Missing character: There is no i in font nullfont!
Missing character: There is no m in font nullfont!
! Undefined control sequence.
l.8 \DefineV

Re: [R] overlay points on plot

2004-02-18 Thread Tom Blackwell

The solution is found in  help("Subscript").
The subscripting you show inside the function  points()
returns a data frame of one column.  This is indeed a
list and not a vector.  There are several ways to subscript
a data frame that will return one column as a vector.
If you use one of them, this should all work.

The 40 page document "An Introduction to R" may also be
helpful.  In other words, this is pretty thoroughly covered
in the documentation.

-  tom blackwell  -  u michigan medical school  -  ann arbor  -

On Wed, 18 Feb 2004, femke wrote:

>
> Dear R-help list,
>
> I'm trying to overlay a number of data objects in a plot.  Following an earlier 
> example on the list I've created an empty plot as follows
>
> > xlim <- range(as.numeric(c("0","1")))
> > ylim <- range(as.numeric(c("0","25")) )
> > plot(NA, xlim=xlim, ylim=ylim, xlab="distance", ylab="semivariance")
>
> However when I try to plot something on it, I get the following error:
>
> > points(v[2],v[3])
> Error in as.double.default(x) : (list) object cannot be coerced to double
>
> A sample of my data looks like the following V[2]:
>
>gamma
> 1   0.04
> 2   0.582500
> 3   1.574545
> 4   7.126500
> .
>
> and V[3]:
>
> dist
> 1   470.0426
> 2  1045.6365
> 3  1607.1936
> 
>
>
> Does anyone have any idea how to fix this?
>
> Thanks very much,
>
> femke
>   [[alternative HTML version deleted]]
>
> __
> [EMAIL PROTECTED] mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] overlay points on plot

2004-02-18 Thread Spencer Graves
 Checking the documentation on lists:  help.start() -> "An 
Introduction to R" -> "Lists and data frames" -> ... "It is very 
important to distinguish Lst[[1]] from Lst[1]. [[...]] is the operator 
used to select a single element, whereas [...] is a general subscripting 
operator. Thus the former is the first object in the list Lst, and if it 
is a named list the name is not included. The latter is a sublist of the 
list Lst consisting of the first entry only. If it is a named list, the 
name is transferred to the sublist."

 hope this helps.  spencer graves

femke wrote:

Brilliant!   Why the double brackets though?

thanks

femke

- Original Message - 
From: <[EMAIL PROTECTED]>
To: "femke" <[EMAIL PROTECTED]>
Sent: Wednesday, February 18, 2004 1:58 PM
Subject: Re: [R] overlay points on plot

 



have you tried:

points(v[[2]],v[[3]])
__
James Holtman"What is the problem you are trying to solve?"
Executive Consultant  --  Office of Technology, Convergys
[EMAIL PROTECTED]
+1 (513) 723-2929


 "femke"
 <[EMAIL PROTECTED]> To:
   

<[EMAIL PROTECTED]>
 

 Sent by: cc:
 [EMAIL PROTECTED]Subject:  [R] overlay
   

points on plot
 

 ath.ethz.ch

 02/18/2004 13:03







Dear R-help list,

I'm trying to overlay a number of data objects in a plot.  Following an
earlier example on the list I've created an empty plot as follows
   

xlim <- range(as.numeric(c("0","1")))
ylim <- range(as.numeric(c("0","25")) )
plot(NA, xlim=xlim, ylim=ylim, xlab="distance", ylab="semivariance")
 

However when I try to plot something on it, I get the following error:

   

points(v[2],v[3])
 

Error in as.double.default(x) : (list) object cannot be coerced to double

A sample of my data looks like the following V[2]:

  gamma
1   0.04
2   0.582500
3   1.574545
4   7.126500
.
and V[3]:

   dist
1   470.0426
2  1045.6365
3  1607.1936

Does anyone have any idea how to fix this?

Thanks very much,

femke
[[alternative HTML version deleted]]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html


   

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
 

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] overlay points on plot

2004-02-18 Thread DJNordlund
In a message dated 2/18/2004 10:13:53 AM Pacific Standard Time, 
[EMAIL PROTECTED] writes:

>Dear R-help list,
>
>I'm trying to overlay a number of data objects in a plot.  Following an 
earlier example on the >list I've created an empty plot as follows
>
>> xlim <- range(as.numeric(c("0","1")))
>> ylim <- range(as.numeric(c("0","25")) )
>> plot(NA, xlim=xlim, ylim=ylim, xlab="distance", ylab="semivariance")
>
>However when I try to plot something on it, I get the following error:
>
>> points(v[2],v[3])
>Error in as.double.default(x) : (list) object cannot be coerced to double

Try 

points(v[, 2], v[, 3]) ?

Dan Nordlund

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] using names() as a variable in a formula

2004-02-18 Thread Duncan Murdoch
On Wed, 18 Feb 2004 15:44:59 -0500, "femke" <[EMAIL PROTECTED]> wrote
>> v<-variogram(A1~1,loc=~x+y, dataC)


What package is variogram in?  The one in spatial takes different
args.

>> v<-variogram(names(dataC[3])~1,loc=~x+y, dataC)

Doing this sort of thing is tricky.  Your names(dataC[3]) is a
character string; you want something there that would be interpreted
as a name instead.  However, as.name(names(dataC[3])) isn't enough.

I think you need to build up the formula using fairly low level stuff,
something like this:

   formula <- as.call(list(as.name('~'), as.name(names(dataC[3])),
quote(1)))

and then do

  variogram(formula, )

but a formula constructed this way doesn't work in lm(), so it may not
work in variogram either.

Duncan Murdoch

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] overlay points on plot

2004-02-18 Thread femke
Brilliant!   Why the double brackets though?

thanks

femke


- Original Message - 
From: <[EMAIL PROTECTED]>
To: "femke" <[EMAIL PROTECTED]>
Sent: Wednesday, February 18, 2004 1:58 PM
Subject: Re: [R] overlay points on plot


>
>
>
>
> have you tried:
>
>  points(v[[2]],v[[3]])
> __
> James Holtman"What is the problem you are trying to solve?"
> Executive Consultant  --  Office of Technology, Convergys
> [EMAIL PROTECTED]
> +1 (513) 723-2929
>
>
>
>   "femke"
>   <[EMAIL PROTECTED]> To:
<[EMAIL PROTECTED]>
>   Sent by: cc:
>   [EMAIL PROTECTED]Subject:  [R] overlay
points on plot
>   ath.ethz.ch
>
>
>   02/18/2004 13:03
>
>
>
>
>
>
>
> Dear R-help list,
>
> I'm trying to overlay a number of data objects in a plot.  Following an
> earlier example on the list I've created an empty plot as follows
>
> > xlim <- range(as.numeric(c("0","1")))
> > ylim <- range(as.numeric(c("0","25")) )
> > plot(NA, xlim=xlim, ylim=ylim, xlab="distance", ylab="semivariance")
>
> However when I try to plot something on it, I get the following error:
>
> > points(v[2],v[3])
> Error in as.double.default(x) : (list) object cannot be coerced to double
>
> A sample of my data looks like the following V[2]:
>
>gamma
> 1   0.04
> 2   0.582500
> 3   1.574545
> 4   7.126500
> .
>
> and V[3]:
>
> dist
> 1   470.0426
> 2  1045.6365
> 3  1607.1936
> 
>
>
> Does anyone have any idea how to fix this?
>
> Thanks very much,
>
> femke
>  [[alternative HTML version deleted]]
>
> __
> [EMAIL PROTECTED] mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
>
>

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] NAs introduced by coercion warning?

2004-02-18 Thread Jonathan Greenberg
I'm running a decision tree on a large dataset, and I'm getting multiple
instances of "NAs introduced by coercion" (> 50).  What does this mean?

--j

-- 
Jonathan Greenberg
Graduate Group in Ecology, U.C. Davis
http://www.cstars.ucdavis.edu/~jongreen
http://www.cstars.ucdavis.edu
AIM: jgrn307 or jgrn3007
MSN: [EMAIL PROTECTED] or [EMAIL PROTECTED]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] building the development version

2004-02-18 Thread Prof Brian Ripley
On 18 Feb 2004, Peter Dalgaard wrote:

> [EMAIL PROTECTED] (A.J. Rossini) writes:
> 
> > Prof Brian Ripley <[EMAIL PROTECTED]> writes:
> > 
> > > On Wed, 18 Feb 2004, Deborah Swayne wrote:
> > >
> > >> I'm trying to build the current development version of R on an SGI
> > >> running IRIX6.5.  Everything proceeds merrily until I reach the eda
> > >> package.  This is the error message I get if I cd to the appropriate
> > >> directory and type 'make' or 'make all.'  Does this make sense to
> > >> anyone?  -- Thanks, Debby
> > >
> > > There should be no such directory.  Did you do this in a clean build 
> > > directory, as this is what would happen if you try to rebuild over 
> > > sources from a couple of months ago?  Please try again starting in an 
> > > empty build directory.
> > 
> > This directory exists on a clean anonCVS checkout, cvs co, followed
> > with a cvs update -Pd.  Done AFTER Debbie's post, on a new machine.
> 
> There should actually be an eda directory. On my system, with a fresh

Yes, but no eda/src nor eda/man.

> checkout from the developer CVS, it ends up building a package
> containing only
> 
> .noGenerics <- TRUE
> 
> .First.lib <- function(lib, pkg)
> {
> have.stats <- "package:stats" %in% search()
> if(!have.stats) require("stats")
> warning("package ", sQuote("eda"), " has been merged into ",
> sQuote("stats"), call. = FALSE)
> }
> 
> I can't reproduce Debbie's problem though...
> 
> 

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

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] (no subject)

2004-02-18 Thread Thomas Isenbarger
R folks:

this is my first posting, so please forgive me if i have missed 
something on this in the archives or other documentation.

I have been trying to use gplot to draw a network diagram.  can anyone 
suggest a method to minimise the number of edges that cross?  do i need 
to use the stringrepulse mode and tweak some of the parameters?

Cheers,
Tom I.
--
dr tom isenbarger phd
[EMAIL PROTECTED]
harvard medical school department of genetics
massachusetts general hospital department of molecular biology
telephone:  617.726.5973
facsimile:   617.726.6893
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] using names() as a variable in a formula

2004-02-18 Thread Sundar Dorai-Raj


femke wrote:

Greetings List,

I'm having some trouble with the use of the names function in a formula.  Below is an example of something that works (i.e first line), and the second line is the same formula which doesn't.  I want to be able to reference the column of the dataC table so I can run the variogram iteratively with a loop.


v<-variogram(A1~1,loc=~x+y, dataC)
v<-variogram(names(dataC[3])~1,loc=~x+y, dataC)
Error in model.frame(formula, rownames, variables, varnames, extras, extranames,  : 
invalid variable type

Where dataC looks like:

x   y   A1   A2  A3
1  514030 4793587  0.0  7.9 0.1
2  517995 4792516  5.8  5.1 0.0
3  514232 4792210  0.0  6.5 0.0
I though initially that it might need some escape character if quotes are added, and tried the following, but it looks ok.


names(dataC[3])
[1] "A1"

mode(names(dataC[3]))
[1] "character"

v<-variogram(as.character(names(dataC[3]))~1,loc=~x+y, dataC)
Error in model.frame(formula, rownames, variables, varnames, extras, extranames,  : 
invalid variable type

v<-variogram(as.formula((names(dataC[3]))~1),loc=~x+y, dataC)
Error in model.frame(formula, rownames, variables, varnames, extras, extranames,  : 
invalid variable type

I'd greatly appreciate any suggestions for fixing this.

Thanks again,

femke
[[alternative HTML version deleted]]
You're not building a valid formula. Try this:

v <- list()
for(i in 3:5) {
  gr <- names(dataC[i])
  f <- formula(paste(gr, "1", sep = " ~ "))
  v[[gr]] <- variogram(f, loc = ~ x + y, dataC)
}
BTW, since variogram is not in the base package it would also be helpful 
in the future if you add that you are using the spatial package.

HTH,
Sundar
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] Area between CDFs

2004-02-18 Thread Samuelson, Frank*

mf<-c(male,female)
ord<-order(mf);
v<-c(rep(1/length(male),length(male)),rep(-1/length(female),length(female)))
;
mf<-mf[ord];
v<-v[ord];
sum(diff(mf)*(cumsum(v)[1:(length(v)-1)]))

You may not want to integrate cdfs.  They're already probabilities.  :)
Nice analytic statistics exist for just the maximum distance between
the cdfs, for example.

-Frank


-Original Message-
From: Harold Doran [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, February 18, 2004 2:21 PM
To: R Help
Subject: [R] Area between CDFs


Dear List:
 
I am trying to find the area between two ECDFs. I am examining the gap in
performance between two groups, males and females on a student achievement
test in math, which is a continuous metric.
 
I start by creating a subset of the dataframe 
 
male<-subset(datafile, female="Male")
female<-subset(datafile, female="Female")
 
I then plot the two CDFs via
 
plot.ecdf(male$math)
plot.ecdf(female$math, add=TRUE)
 
This produces the visual display that reveals a gap in performance. What I
would like to do is learn to perform the integration between the two ECDFs
to examine the size of this gap. 
 
I would also like to try and examine the horizontal distance between the two
CDFs via another visual display. In other words, the distance between, say
the 50th percentile, from each CDF (or, the distance along the x-axis from
cdf1 to cdf2 at each percentile. Ideally, I would like to plot this
horizontal gap at each percentile.
 
Secondly, I would like to try and measure and plot the vertical gap, i.e.,
the distance along the y-axis from cdf 1 to cdf2 at each value along the
x-axis.
 
I am not sure if I first need to smooth the ECDFs before performing these
operations.
 
Any help would be appreciated. I hope this makes sense.
 
Harold 
 
 
 
 
 
--
Harold C. Doran
Director of Research and Evaluation
New American Schools
675 N. Washington Street, Suite 220
Alexandria, Virginia 22314
703.647.1628
   
 
 
 

[[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] using names() as a variable in a formula

2004-02-18 Thread femke
Greetings List,

I'm having some trouble with the use of the names function in a formula.  Below is an 
example of something that works (i.e first line), and the second line is the same 
formula which doesn't.  I want to be able to reference the column of the dataC table 
so I can run the variogram iteratively with a loop.

> v<-variogram(A1~1,loc=~x+y, dataC)
> v<-variogram(names(dataC[3])~1,loc=~x+y, dataC)
Error in model.frame(formula, rownames, variables, varnames, extras, extranames,  : 
invalid variable type

Where dataC looks like:

x   y   A1   A2  A3
1  514030 4793587  0.0  7.9 0.1
2  517995 4792516  5.8  5.1 0.0
3  514232 4792210  0.0  6.5 0.0

I though initially that it might need some escape character if quotes are added, and 
tried the following, but it looks ok.

> names(dataC[3])
[1] "A1"
> mode(names(dataC[3]))
[1] "character"
> v<-variogram(as.character(names(dataC[3]))~1,loc=~x+y, dataC)
Error in model.frame(formula, rownames, variables, varnames, extras, extranames,  : 
invalid variable type
> v<-variogram(as.formula((names(dataC[3]))~1),loc=~x+y, dataC)
Error in model.frame(formula, rownames, variables, varnames, extras, extranames,  : 
invalid variable type

I'd greatly appreciate any suggestions for fixing this.

Thanks again,

femke
[[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] How to repeat a procedure

2004-02-18 Thread Patrick Burns
I believe that Thomas got "mu" wrong.  If I understand
correctly, the line:
x3 <- rpois(50 * 100, rep(mu, each=100))

should read:

x3 <- rpois(50 * 100, rep(mu, 50))

or just

x3 <- rpois(50 * 100, mu)

Patrick Burns

Burns Statistics
[EMAIL PROTECTED]
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and "A Guide for the Unwilling S User")
Thomas Lumley wrote:

On Wed, 18 Feb 2004, Haiyan Chen wrote:

 

Hello,

1. After I generate a 100x50 matrix by x3<-matrix(0,100,50);for (i in
1:100) {x1<-rpois(50, mu[i]);x2<-x1; x2[runif(50)<.01]<-0; x3[i,]<-x2},
   

YOu can do this without the loop, eg

x3<-rpois(50*100, rep(mu,each=100))
x3<-ifelse(runif(50*100)<0.01, 0, x3)
x3<-matrix(x3, ncol=50)
 

2. I want to calculate means and sample variances of each row and create a
new matrix 100x2;
   

means<-apply(x3,2,mean)
vars<-apply(x3,2,var)
cbind(means,vars)
 

3. I then want to repeat above procedure 500 times so that eventually I
will have 500 100x2 matrices.
   

make.a.matrix<-function(...){
x3<-rpois(50*100, rep(mu,each=100))
x3<-ifelse(runif(50*100)<0.01, 0, x3)
x3<-matrix(x3, ncol=50)
cbind(apply(x3,2,mean), apply(x3,2, var))
}
many.matrices<-lapply(1:500, make.a.matrix)

gives a list of 500 matrices.  This isn't quite the most efficient
solution, but it's not bad.
	-thomas

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
 

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] interesting feature

2004-02-18 Thread Philipp Pagel
Hi!

On Wed, Feb 18, 2004 at 10:45:23AM -0600, Svetlana Eden wrote:
> > d <- rbind(d, add)
> > d
> x  y
> 1   1 99
> 2  10 55
> 11 14 99
> # it would be more natural to index the rows: 1,2,3 instead of
> #1,2,11  ?!

What you see in the first column are row-names not indexes. Since both
data frames had a row named '1' there was a conflict which R is trying
to resolve by appending '1'.

> # especially if index '11' is not functioning...
...
> # now I would think that the next index should be 21, BUT:
...
> # so what is the intuition of such indexing?

I think it all becomes clear if you try this:

> a <- data.frame(foo=1:5, bar=10:6, row.names=LETTERS[1:5])
> a
  foo bar
A   1  10
B   2   9
C   3   8
D   4   7
E   5   6
> b <- data.frame(foo=c(9,10), bar=c(99,98), row.names=c('A','B'))
> b
  foo bar
A   9  99
B  10  98
> rbind(a,b)
   foo bar
A1  10
B2   9
C3   8
D4   7
E5   6
A1   9  99
B1  10  98

cu
Philipp

-- 
Dr. Philipp PagelTel.  +49-89-3187-3675
Institute for Bioinformatics / MIPS  Fax.  +49-89-3187-3585
GSF - National Research Center for Environment and Health
Ingolstaedter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/~pagel

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Generalized Estimating Equations and log-likelihood calculation

2004-02-18 Thread treebc
Hi there,

I'm working with clustered data sets and trying to calculate log-likelihood 
(and/or AIC, AICc) for my models.  In using the gee and geese packages one 
gets Wald test output; but apparently there is no no applicable method 
for "logLik" (log-likelihood)calculation.

Is anyone aware of a way to calculate log-likelihood for GEE models?

Thanks for the help,
Bruce

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] interesting feature

2004-02-18 Thread Thomas Petzoldt
Svetlana Eden wrote:

Hi, everybody.
This was an interesting discussion last time and it helped me a lot.
Could you please have a look at some feature and tell me
why it was designed this way
What you see in the first column are the row names. The index is 1,2,3,4 
as usual.

Thomas P.

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] How to repeat a procedure

2004-02-18 Thread Haiyan Chen

Thanks, Patrick. I was aware of that and was able to fix it.

Thanks Tom, Wayne and Peter for all your help.

Heyen



   

  Patrick Burns

  <[EMAIL PROTECTED]To:   Thomas Lumley <[EMAIL 
PROTECTED]>  
  anet.com>cc:   Haiyan Chen <[EMAIL 
PROTECTED]>, [EMAIL PROTECTED]  
   Subject:  Re: [R] How to repeat a 
procedure 
  02/18/2004 01:09 

  PM   

   

   





I believe that Thomas got "mu" wrong.  If I understand
correctly, the line:

x3 <- rpois(50 * 100, rep(mu, each=100))

should read:

x3 <- rpois(50 * 100, rep(mu, 50))

or just

x3 <- rpois(50 * 100, mu)

Patrick Burns

Burns Statistics
[EMAIL PROTECTED]
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and "A Guide for the Unwilling S User")

Thomas Lumley wrote:

>On Wed, 18 Feb 2004, Haiyan Chen wrote:
>
>
>
>>Hello,
>>
>>1. After I generate a 100x50 matrix by x3<-matrix(0,100,50);for (i in
>>1:100) {x1<-rpois(50, mu[i]);x2<-x1; x2[runif(50)<.01]<-0; x3[i,]<-x2},
>>
>>
>
>YOu can do this without the loop, eg
>
>x3<-rpois(50*100, rep(mu,each=100))
>x3<-ifelse(runif(50*100)<0.01, 0, x3)
>x3<-matrix(x3, ncol=50)
>
>
>
>>2. I want to calculate means and sample variances of each row and create
a
>>new matrix 100x2;
>>
>>
>
>means<-apply(x3,2,mean)
>vars<-apply(x3,2,var)
>cbind(means,vars)
>
>
>
>>3. I then want to repeat above procedure 500 times so that eventually I
>>will have 500 100x2 matrices.
>>
>>
>
>make.a.matrix<-function(...){
> x3<-ifelse(runif(50*100)<0.01, 0, x3)
> x3<-matrix(x3, ncol=50)
> cbind(apply(x3,2,mean), apply(x3,2, var))
>}
>
>many.matrices<-lapply(1:500, make.a.matrix)
>
>gives a list of 500 matrices.  This isn't quite the most efficient
>solution, but it's not bad.
>
>
> -thomas
>
>__
>[EMAIL PROTECTED] mailing list
>https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
>
>
>
>

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Area between CDFs

2004-02-18 Thread Harold Doran
Dear List:
 
I am trying to find the area between two ECDFs. I am examining the gap in performance 
between two groups, males and females on a student achievement test in math, which is 
a continuous metric.
 
I start by creating a subset of the dataframe 
 
male<-subset(datafile, female="Male")
female<-subset(datafile, female="Female")
 
I then plot the two CDFs via
 
plot.ecdf(male$math)
plot.ecdf(female$math, add=TRUE)
 
This produces the visual display that reveals a gap in performance. What I would like 
to do is learn to perform the integration between the two ECDFs to examine the size of 
this gap. 
 
I would also like to try and examine the horizontal distance between the two CDFs via 
another visual display. In other words, the distance between, say the 50th percentile, 
from each CDF (or, the distance along the x-axis from cdf1 to cdf2 at each percentile. 
Ideally, I would like to plot this horizontal gap at each percentile.
 
Secondly, I would like to try and measure and plot the vertical gap, i.e., the 
distance along the y-axis from cdf 1 to cdf2 at each value along the x-axis.
 
I am not sure if I first need to smooth the ECDFs before performing these operations.
 
Any help would be appreciated. I hope this makes sense.
 
Harold 
 
 
 
 
 
--
Harold C. Doran
Director of Research and Evaluation
New American Schools
675 N. Washington Street, Suite 220
Alexandria, Virginia 22314
703.647.1628
   
 
 
 

[[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] parse error in GLMM function

2004-02-18 Thread Ray Brownrigg
"CENDOYA, Gabriela" <[EMAIL PROTECTED]> writes:
> I'm trying to use the function GLMM from lme4 package, (R-1.8.1, Windows
> 98),and I get the following error:
> > pd5 = GLMM(nplant~sitio+
> + fert+
> + remo+
> + sitio:fert+
> + remo:sitio+
> + remo:fert+
> + remo:fert:sitio
> + data=datos,
> + family=binomial,
> + random=~repe:sitio)
> Error in parse(file, n, text, prompt) : parse error

Isn't the problem that you really do have a syntax error?

Note there is no comma before the data=.

Ray

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] overlay points on plot

2004-02-18 Thread Prof Brian Ripley
Is v a data frame?  In that case you need v[[2]] and v[[3]], as v[2] is a 
data frame.

On Wed, 18 Feb 2004, femke wrote:

> 
> Dear R-help list,
> 
> I'm trying to overlay a number of data objects in a plot.  Following an earlier 
> example on the list I've created an empty plot as follows
> 
> > xlim <- range(as.numeric(c("0","1")))
> > ylim <- range(as.numeric(c("0","25")) )
> > plot(NA, xlim=xlim, ylim=ylim, xlab="distance", ylab="semivariance")
> 
> However when I try to plot something on it, I get the following error:
> 
> > points(v[2],v[3])
> Error in as.double.default(x) : (list) object cannot be coerced to double
> 
> A sample of my data looks like the following V[2]:
> 
>gamma
> 1   0.04
> 2   0.582500
> 3   1.574545
> 4   7.126500
> .
> 
> and V[3]:
> 
> dist
> 1   470.0426
> 2  1045.6365
> 3  1607.1936
> 
> 
> 
> Does anyone have any idea how to fix this?  
> 
> Thanks very much,
> 
> femke
>   [[alternative HTML version deleted]]
> 
> __
> [EMAIL PROTECTED] mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
> 
> 

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

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] building the development version

2004-02-18 Thread Peter Dalgaard
Prof Brian Ripley <[EMAIL PROTECTED]> writes:

> On 18 Feb 2004, Peter Dalgaard wrote:
> > > > There should be no such directory.  Did you do this in a clean build 
> > > > directory, as this is what would happen if you try to rebuild over 
> > > > sources from a couple of months ago?  Please try again starting in an 
> > > > empty build directory.
> > > 
> > > This directory exists on a clean anonCVS checkout, cvs co, followed
> > > with a cvs update -Pd.  Done AFTER Debbie's post, on a new machine.
> > 
> > There should actually be an eda directory. On my system, with a fresh
> 
> Yes, but no eda/src nor eda/man.

OK, that I can confirm. They do turn up on a checkout without the -P
option, but disappear after "cvs up -Pd". Tony, Debbie, did you
perhaps configure before attempting to prune the empty dirs? Could you
try 

cvs -d ...blabla... co -P R

-p

BTW: Make dist appears to be broken?

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

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] interesting feature

2004-02-18 Thread Liaw, Andy
> From: Svetlana Eden
> 
> Hi, everybody.
> This was an interesting discussion last time and it helped me a lot.
> 
> Could you please have a look at some feature and tell me
> why it was designed this way
> (my questions are under #)

I give it a shot...
 
> > x = c(1, 10)
> > y = c(99, 55)
> > d <- data.frame(x = x, y = y)
> > d
>x  y
> 1  1 99
> 2 10 55
> > add <- data.frame(x = 14, y = 99)
> > add
>x  y
> 1 14 99
> > d <- rbind(d, add)
> > d
> x  y
> 1   1 99
> 2  10 55
> 11 14 99
> # it would be more natural to index the rows: 1,2,3 instead of
> #1,2,11  ?!

rownames for data.frame need not be 1, 2, ..., and we need something that's
going to work regardless.

> > d[3,1]
> [1] 14
> > d[11,1]
> [1] NA
> # especially if index '11' is not functioning...

This one seems curious to me.  Trying to access non-existing column result
in error:

> d[1,11]
Error in "[.data.frame"(d, 1, 11) : undefined columns selected

OTOH, try:

> d[11,1] <- 1
> dim(d)
[1] 11  2
> d
Error in data.frame(x = c(" 1", "10", "14", "NA", "NA", "NA", "NA", "NA",  :

duplicate row.names: 11

so that destroys the integrity of the data frame!

> > add1 <- data.frame(x = 10, y = 87)
> > d <- rbind(d, add)
> # now I would think that the next index should be 21, BUT:
> > d
> x  y
> 1   1 99
> 2  10 55
> 11 14 99
> 12 10 87
> # so what is the intuition of such indexing?

I believe the rationale is explained in ?make.unique (which
rbind.data.frame() calls to create the rownames).
 
HTH,
Andy

 
> -- 
> Svetlana EdenBiostatistician IISchool of Medicine
>  Department of Biostatistics   Vanderbilt 
> University
> 
> __
> [EMAIL PROTECTED] mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 
> 


--
Notice:  This e-mail message, together with any attachments,...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] building the development version

2004-02-18 Thread Peter Dalgaard
[EMAIL PROTECTED] (A.J. Rossini) writes:

> Prof Brian Ripley <[EMAIL PROTECTED]> writes:
> 
> > On Wed, 18 Feb 2004, Deborah Swayne wrote:
> >
> >> I'm trying to build the current development version of R on an SGI
> >> running IRIX6.5.  Everything proceeds merrily until I reach the eda
> >> package.  This is the error message I get if I cd to the appropriate
> >> directory and type 'make' or 'make all.'  Does this make sense to
> >> anyone?  -- Thanks, Debby
> >
> > There should be no such directory.  Did you do this in a clean build 
> > directory, as this is what would happen if you try to rebuild over 
> > sources from a couple of months ago?  Please try again starting in an 
> > empty build directory.
> 
> This directory exists on a clean anonCVS checkout, cvs co, followed
> with a cvs update -Pd.  Done AFTER Debbie's post, on a new machine.

There should actually be an eda directory. On my system, with a fresh
checkout from the developer CVS, it ends up building a package
containing only

.noGenerics <- TRUE

.First.lib <- function(lib, pkg)
{
have.stats <- "package:stats" %in% search()
if(!have.stats) require("stats")
warning("package ", sQuote("eda"), " has been merged into ",
sQuote("stats"), call. = FALSE)
}

I can't reproduce Debbie's problem though...

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

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] interesting feature

2004-02-18 Thread Douglas Bates
Svetlana Eden <[EMAIL PROTECTED]> writes:

> Hi, everybody.
> This was an interesting discussion last time and it helped me a lot.
> 
> Could you please have a look at some feature and tell me
> why it was designed this way
> (my questions are under #)
> 
> > x = c(1, 10)
> > y = c(99, 55)
> > d <- data.frame(x = x, y = y)
> > d
>x  y
> 1  1 99
> 2 10 55
> > add <- data.frame(x = 14, y = 99)
> > add
>x  y
> 1 14 99
> > d <- rbind(d, add)
> > d
> x  y
> 1   1 99
> 2  10 55
> 11 14 99
> # it would be more natural to index the rows: 1,2,3 instead of
> #1,2,11  ?!

It's not the number 11, it is the string "11".

Row names are character strings.  In your original data frame the row
names were "1" and "2" for the first frame and "1" for the second.
The rbind function should not create a duplicate row name so it
prepended a "1" to all the names in the second frame.  That explains
the "11" and "12" in your last example.  They are simply the original
names "1" and "2" with a "1" prepended to them.

> >
> > d[3,1]
> [1] 14
> > d[11,1]

Try d["11", 1]

> [1] NA
> # especially if index '11' is not functioning...
> >
> > add1 <- data.frame(x = 10, y = 87)
> > d <- rbind(d, add)
> # now I would think that the next index should be 21, BUT:
> > d
> x  y
> 1   1 99
> 2  10 55
> 11 14 99
> 12 10 87
> # so what is the intuition of such indexing?

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] building the development version

2004-02-18 Thread Prof Brian D Ripley
On Wed, 18 Feb 2004, A.J. Rossini wrote:

> Prof Brian Ripley <[EMAIL PROTECTED]> writes:
>
> > On Wed, 18 Feb 2004, Deborah Swayne wrote:
> >
> >> I'm trying to build the current development version of R on an SGI
> >> running IRIX6.5.  Everything proceeds merrily until I reach the eda
> >> package.  This is the error message I get if I cd to the appropriate
> >> directory and type 'make' or 'make all.'  Does this make sense to
> >> anyone?  -- Thanks, Debby
> >
> > There should be no such directory.  Did you do this in a clean build
> > directory, as this is what would happen if you try to rebuild over
> > sources from a couple of months ago?  Please try again starting in an
> > empty build directory.
>
> This directory exists on a clean anonCVS checkout, cvs co, followed
> with a cvs update -Pd.  Done AFTER Debbie's post, on a new machine.

Looks like there is a problem with anonCVS.  That directory is empty
in the master CVS tree and hence does not appear in the daily snapshots.
I've just checked: it is not there in R-devel_2004-02-18.tar.bz2.

What is in it under anonCVS?

> I verified Debbie's results, and the solution I suggested (2
> incantations, with a weird incantation and the removal of the eda
> subdir) got me most of the way there.  The second incantation was
> needed to cope with a problem in the ctest directory.

Looks like we need to take some preventative measures in any case 

-- 
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 272860 (secr)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] overlay points on plot

2004-02-18 Thread femke

Dear R-help list,

I'm trying to overlay a number of data objects in a plot.  Following an earlier 
example on the list I've created an empty plot as follows

> xlim <- range(as.numeric(c("0","1")))
> ylim <- range(as.numeric(c("0","25")) )
> plot(NA, xlim=xlim, ylim=ylim, xlab="distance", ylab="semivariance")

However when I try to plot something on it, I get the following error:

> points(v[2],v[3])
Error in as.double.default(x) : (list) object cannot be coerced to double

A sample of my data looks like the following V[2]:

   gamma
1   0.04
2   0.582500
3   1.574545
4   7.126500
.

and V[3]:

dist
1   470.0426
2  1045.6365
3  1607.1936



Does anyone have any idea how to fix this?  

Thanks very much,

femke
[[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] interesting feature

2004-02-18 Thread Prof Brian Ripley
You are adding a row with name "1" each time.  R just adds a suffix to 
make it unique.  What you call indices are the *row names* of the data 
frame.

Suppose the row name had been "Eden".  Then "Eden1" and "Eden2" make more 
sense than your suggestions.

On Wed, 18 Feb 2004, Svetlana Eden wrote:

> Hi, everybody.
> This was an interesting discussion last time and it helped me a lot.
> 
> Could you please have a look at some feature and tell me
> why it was designed this way
> (my questions are under #)
> 
> > x = c(1, 10)
> > y = c(99, 55)
> > d <- data.frame(x = x, y = y)
> > d
>x  y
> 1  1 99
> 2 10 55
> > add <- data.frame(x = 14, y = 99)
> > add
>x  y
> 1 14 99
> > d <- rbind(d, add)
> > d
> x  y
> 1   1 99
> 2  10 55
> 11 14 99
> # it would be more natural to index the rows: 1,2,3 instead of
> #1,2,11  ?!
> >
> > d[3,1]
> [1] 14
> > d[11,1]
> [1] NA
> # especially if index '11' is not functioning...

You need "11": it is a row name and not a row index.

> > add1 <- data.frame(x = 10, y = 87)
> > d <- rbind(d, add)
> # now I would think that the next index should be 21, BUT:
> > d
> x  y
> 1   1 99
> 2  10 55
> 11 14 99
> 12 10 87
> # so what is the intuition of such indexing?

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

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] building the development version

2004-02-18 Thread A.J. Rossini
Prof Brian Ripley <[EMAIL PROTECTED]> writes:

> On Wed, 18 Feb 2004, Deborah Swayne wrote:
>
>> I'm trying to build the current development version of R on an SGI
>> running IRIX6.5.  Everything proceeds merrily until I reach the eda
>> package.  This is the error message I get if I cd to the appropriate
>> directory and type 'make' or 'make all.'  Does this make sense to
>> anyone?  -- Thanks, Debby
>
> There should be no such directory.  Did you do this in a clean build 
> directory, as this is what would happen if you try to rebuild over 
> sources from a couple of months ago?  Please try again starting in an 
> empty build directory.

This directory exists on a clean anonCVS checkout, cvs co, followed
with a cvs update -Pd.  Done AFTER Debbie's post, on a new machine.

I verified Debbie's results, and the solution I suggested (2
incantations, with a weird incantation and the removal of the eda
subdir) got me most of the way there.  The second incantation was
needed to cope with a problem in the ctest directory.

best,
-tony

-- 
[EMAIL PROTECTED]http://www.analytics.washington.edu/ 
Biomedical and Health Informatics   University of Washington
Biostatistics, SCHARP/HVTN  Fred Hutchinson Cancer Research Center
UW (Tu/Th/F): 206-616-7630 FAX=206-543-3461 | Voicemail is unreliable
FHCRC  (M/W): 206-667-7025 FAX=206-667-4812 | use Email

CONFIDENTIALITY NOTICE: This e-mail message and any attachme...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] parse error in GLMM function

2004-02-18 Thread Douglas Bates
"CENDOYA, Gabriela" <[EMAIL PROTECTED]> writes:

> Douglas Bates write:
> 
> >"CENDOYA, Gabriela" <[EMAIL PROTECTED]> writes:
> >I'm trying to use the function GLMM from lme4 package, (R-1.8.1, Windows
> >> 98),and I get the following error:
> > > pd5 = GLMM(nplant~sitio+
> >> + fert+
> >> + remo+
> >> + sitio:fert+
> >> + remo:sitio+
> >> + remo:fert+
> >> + remo:fert:sitio
> >> + data=datos,
> >> + family=binomial,
> >> + random=~repe:sitio)
> >> Error in parse(file, n, text, prompt) : parse error
> 
> >Could you tell us the version of the lme4 package please?
> 
> lme4  version: 0.4-7
> 
> 
>  About the optional data frame I didn't want to sound picky, I just
> mention it because I thought it could be related to the other problem.
>  In fact, I am really amazed about how good, complete and clear are the help
> pages in R.

My response about being picky was intended to be a joke.  Having the
code fail to agree with the documentation is definitely a bug in
either the code or the documentation, which is why I said "thanks for
pointing this out".  Sorry that my reply didn't sound the way that I
had intended it.

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] return a list of vectors from C?

2004-02-18 Thread Jeff D. Hamann
I've been working on a shared library that will be called from R. The
functions pass several vectors in and out (residuals, parameters, etc) and I
would like to be able to return a list of objects. I'm familiar with return
single objects (vectors, etc) from a C function, but need a little help for
returning a list of objects.

My code so far looks something like:

/* this function will perform the same tasks as the previous */
/* and return a list of the values rather than just the  */
/* optimal values. It should return the optimization info as */
/* well as the residual values from the flikam function  */
SEXP testfunc2(
   SEXP *pq,
   SEXP *obs )
{

   int  i;
   double *pq_vect;
   double *obs_vect;

   SEXP  ret_val;

   PROTECT( pq = coerceVector( pq, REALSXP ) );
   PROTECT( obs = coerceVector( obs, REALSXP ) );

   pq_vect = REAL( pq );
   obs_vect = REAL( obs );


   /* call my functions for the results */


   /* generate the output list */
   PROTECT( ret_val = allocVector( VECSXP, NPQ ) );
   for( i = 0; i < NPQ; i++ )
   {
  //REAL(ret_val)[i] = XMIN[i];
  //PROTECT( ret_val = allocVector( VECSXP, NPQ ) );
  //SET_VECTOR_ELT( ret_val, i, 3.14159 );

  //SET_VECTOR_ELT( ret_val, i, pq );


  /* generate the output vector */
/*   PROTECT( ret_val = allocVector( REALSXP, NPQ ) ); */
/*   for( i = 0; i < NPQ; i++ ) */
/*   { */
/*   REAL(ret_val)[i] = XMIN[i]; */
/*   } */

   }

   UNPROTECT( 3 );

   return ret_val;

}


What package would be a good example of how to do this?

Jeff.

---
Jeff D. Hamann
Forest Informatics, Inc.
PO Box 1421
Corvallis, Oregon USA 97339-1421
(office) 541-754-1428
(cell) 541-740-5988
[EMAIL PROTECTED]
www.forestinformatics.com

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] building the development version

2004-02-18 Thread Prof Brian Ripley
On Wed, 18 Feb 2004, Deborah Swayne wrote:

> I'm trying to build the current development version of R on an SGI
> running IRIX6.5.  Everything proceeds merrily until I reach the eda
> package.  This is the error message I get if I cd to the appropriate
> directory and type 'make' or 'make all.'  Does this make sense to
> anyone?  -- Thanks, Debby

There should be no such directory.  Did you do this in a clean build 
directory, as this is what would happen if you try to rebuild over 
sources from a couple of months ago?  Please try again starting in an 
empty build directory.

> 
> gmake[3]: Entering directory `/l/fsc/dfs/src/R/src/library/eda'
> building package 'eda'
> ../../../library/eda/R/eda is unchanged
> ../../../library/eda/man/eda.Rd is unchanged
> /home/dfs/src/R/src/library/eda/src
> gmake[4]: Entering directory `/l/fsc/dfs/src/R/src/library/eda/src'
> config.status: error: invalid argument: src/library/eda/src/Makefile

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

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Interesting feature

2004-02-18 Thread Roy, Supratik
 Interesting feature
The logic seems to be simple. The first digit in the label indicates the row

position within the new matrix/vector that is being added.  Thus the first
digit remains 1
if you go on adding single rows. The second digit is then filled up by the
lowest digit 
possible that makes the label distinct from all previous labels, and the
third so on 
Try adding not just single rows but matrices of more than 1 rows repeatedly,

and the pattern will be clear.
 
Supratik. 

[[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] How to repeat a procedure

2004-02-18 Thread Peter Wolf
Haiyan Chen wrote:

Hello,

1. After I generate a 100x50 matrix by x3<-matrix(0,100,50);for (i in
1:100) {x1<-rpois(50, mu[i]);x2<-x1; x2[runif(50)<.01]<-0; x3[i,]<-x2},
2. I want to calculate means and sample variances of each row and create a
new matrix 100x2;
Try:

mean.var<-function(n=10, m=5){
mu<-(1:n)^2
x<-matrix(rpois(n*m,mu),n,m)
stat<-t(apply(x,1,function(x)c(mean(x),var(x
}
to set some elements of x to zero you can add an additional line in mean.var

3. I then want to repeat above procedure 500 times so that eventually I
will have 500 100x2 matrices.
n<-100; m<-50
n.comp<-500
for(i in 1:n.comp) 
eval(parse(text=paste("result",i,"<-mean.var(n,m)",sep="")))

Peter

Would someone mind helping me to code 2 & 3?

Thanks ahead of time.

Heyen

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
 

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] How to repeat a procedure

2004-02-18 Thread Wayne Jones
The command ?apply will easily get row means/vars (or col means/vars)

e.g.  
my.mat<-matrix(rnorm(144),12)
my.mat
apply(my.mat,1,mean,na.rm=T)
apply(my.mat,1,var,na.rm=T)



The functions ?rbind and ?cbind will help you add rows or columns to
matrices or data frames

Enjoy 

Wayne


-Original Message-
From: Haiyan Chen [mailto:[EMAIL PROTECTED]
Sent: 18 February 2004 15:39
To: [EMAIL PROTECTED]
Subject: [R] How to repeat a procedure


Hello,

1. After I generate a 100x50 matrix by x3<-matrix(0,100,50);for (i in
1:100) {x1<-rpois(50, mu[i]);x2<-x1; x2[runif(50)<.01]<-0; x3[i,]<-x2},

2. I want to calculate means and sample variances of each row and create a
new matrix 100x2;

3. I then want to repeat above procedure 500 times so that eventually I
will have 500 100x2 matrices.

Would someone mind helping me to code 2 & 3?

Thanks ahead of time.

Heyen

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html


KSS Ltd
Seventh Floor  St James's Buildings  79 Oxford Street  Manchester  M1 6SS  England
Company Registration Number 2800886
Tel: +44 (0) 161 228 0040   Fax: +44 (0) 161 236 6305
mailto:[EMAIL PROTECTED]http://www.kssg.com


The information in this Internet email is confidential and m...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] How to repeat a procedure

2004-02-18 Thread Thomas Lumley
On Wed, 18 Feb 2004, Haiyan Chen wrote:

> Hello,
>
> 1. After I generate a 100x50 matrix by x3<-matrix(0,100,50);for (i in
> 1:100) {x1<-rpois(50, mu[i]);x2<-x1; x2[runif(50)<.01]<-0; x3[i,]<-x2},

YOu can do this without the loop, eg

x3<-rpois(50*100, rep(mu,each=100))
x3<-ifelse(runif(50*100)<0.01, 0, x3)
x3<-matrix(x3, ncol=50)

> 2. I want to calculate means and sample variances of each row and create a
> new matrix 100x2;

means<-apply(x3,2,mean)
vars<-apply(x3,2,var)
cbind(means,vars)

> 3. I then want to repeat above procedure 500 times so that eventually I
> will have 500 100x2 matrices.

make.a.matrix<-function(...){
x3<-rpois(50*100, rep(mu,each=100))
x3<-ifelse(runif(50*100)<0.01, 0, x3)
x3<-matrix(x3, ncol=50)
cbind(apply(x3,2,mean), apply(x3,2, var))
}

many.matrices<-lapply(1:500, make.a.matrix)

gives a list of 500 matrices.  This isn't quite the most efficient
solution, but it's not bad.


-thomas

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] building the development version

2004-02-18 Thread A.J. Rossini

Are you rebuilding?  

./config.status 

might need to be run to remake the Makefile, or:

  ./config.status --recheck ; ./config.status

(from top level directory in the R tree).  I've had the same problems
before. 

Deborah Swayne <[EMAIL PROTECTED]> writes:

> I'm trying to build the current development version of R on an SGI
> running IRIX6.5.  Everything proceeds merrily until I reach the eda
> package.  This is the error message I get if I cd to the appropriate
> directory and type 'make' or 'make all.'  Does this make sense to
> anyone?  -- Thanks, Debby
>
> gmake[3]: Entering directory `/l/fsc/dfs/src/R/src/library/eda'
> building package 'eda'
> ../../../library/eda/R/eda is unchanged
> ../../../library/eda/man/eda.Rd is unchanged
> /home/dfs/src/R/src/library/eda/src
> gmake[4]: Entering directory `/l/fsc/dfs/src/R/src/library/eda/src'
> config.status: error: invalid argument: src/library/eda/src/Makefile
>
> __
> [EMAIL PROTECTED] mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

-- 
[EMAIL PROTECTED]http://www.analytics.washington.edu/ 
Biomedical and Health Informatics   University of Washington
Biostatistics, SCHARP/HVTN  Fred Hutchinson Cancer Research Center
UW (Tu/Th/F): 206-616-7630 FAX=206-543-3461 | Voicemail is unreliable
FHCRC  (M/W): 206-667-7025 FAX=206-667-4812 | use Email

CONFIDENTIALITY NOTICE: This e-mail message and any attachme...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Help with multiple graphs on one set of axis

2004-02-18 Thread kjetil
On 17 Feb 2004 at 11:13, Phillip Good wrote:

> Can you suggest code to plot two cumulative distribution functions on
> the same set of axis?
> 

> library(stepfun)
> x <- rnorm(100)
> y <- rnorm(110, 0.5)
> plot(ecdf(x), col.p="red",col.h="red",col.v="red")
> plot(ecdf(y),add=TRUE, col.p="blue",col.h="blue",col.v="blue")

Kjetil Halvorsen


> Phillp Good
> 
> "Never trust anything that can think for itself if you can't see where
> it keeps its brain."  Mr. Weasley
>  [[alternative HTML version deleted]]
> 
> __
> [EMAIL PROTECTED] mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] interesting feature

2004-02-18 Thread Svetlana Eden
Hi, everybody.
This was an interesting discussion last time and it helped me a lot.

Could you please have a look at some feature and tell me
why it was designed this way
(my questions are under #)

> x = c(1, 10)
> y = c(99, 55)
> d <- data.frame(x = x, y = y)
> d
   x  y
1  1 99
2 10 55
> add <- data.frame(x = 14, y = 99)
> add
   x  y
1 14 99
> d <- rbind(d, add)
> d
x  y
1   1 99
2  10 55
11 14 99
# it would be more natural to index the rows: 1,2,3 instead of
#1,2,11  ?!
>
> d[3,1]
[1] 14
> d[11,1]
[1] NA
# especially if index '11' is not functioning...
>
> add1 <- data.frame(x = 10, y = 87)
> d <- rbind(d, add)
# now I would think that the next index should be 21, BUT:
> d
x  y
1   1 99
2  10 55
11 14 99
12 10 87
# so what is the intuition of such indexing?


-- 
Svetlana EdenBiostatistician IISchool of Medicine
 Department of Biostatistics   Vanderbilt University

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] building the development version

2004-02-18 Thread Deborah Swayne

I'm trying to build the current development version of R on an SGI
running IRIX6.5.  Everything proceeds merrily until I reach the eda
package.  This is the error message I get if I cd to the appropriate
directory and type 'make' or 'make all.'  Does this make sense to
anyone?  -- Thanks, Debby

gmake[3]: Entering directory `/l/fsc/dfs/src/R/src/library/eda'
building package 'eda'
../../../library/eda/R/eda is unchanged
../../../library/eda/man/eda.Rd is unchanged
/home/dfs/src/R/src/library/eda/src
gmake[4]: Entering directory `/l/fsc/dfs/src/R/src/library/eda/src'
config.status: error: invalid argument: src/library/eda/src/Makefile

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] How to repeat a procedure

2004-02-18 Thread Haiyan Chen
Hello,

1. After I generate a 100x50 matrix by x3<-matrix(0,100,50);for (i in
1:100) {x1<-rpois(50, mu[i]);x2<-x1; x2[runif(50)<.01]<-0; x3[i,]<-x2},

2. I want to calculate means and sample variances of each row and create a
new matrix 100x2;

3. I then want to repeat above procedure 500 times so that eventually I
will have 500 100x2 matrices.

Would someone mind helping me to code 2 & 3?

Thanks ahead of time.

Heyen

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] persp and lines()

2004-02-18 Thread Jeff Jorgensen
Tom,

Thanks for the nudge to reexamine the instructions.  I wasn't calling the 
right object with "pmat".  I first had to create a perspective plot object 
which creates the plot, and then call *that* object for "pmat", not the 
matrix I used to create the plot in the first place:

surface<-persp(x=..., y=..., z=perspmatrix, )

## function needed to add things to persp, found in the ?persp help menu ##
trans3d <- function(x,y,z, pmat) {
   tr <- cbind(x,y,z,1) %*% pmat
   list(x = tr[,1]/tr[,4], y= tr[,2]/tr[,4])
 }
lines(trans3d(x=..., y=..., z=..., pmat=surface), ...)



At 07:45 PM 2/17/2004 -0500, you wrote:
Jeff  -

See the section titled "Value:" and example (2) from  help("persp")
for instructions and an example of doing exactly what you ask.
-  tom blackwell  -  u michigan medical school  -  ann arbor  -

On Tue, 17 Feb 2004, Jeff Jorgensen wrote:

> R-sters:
>
> I'm interested in keeping data plotted in persp to preserve the wireframe
> look, I'd just like to change one of the lines drawn (in either the x or y
> direction) into a different color so that it stands out.
>
> Or is there some way to add a line (say, via lines(), or abline()) to a
> persp() plot at the designated x or y that would follow the z surface
> contour?  I could add a line using 2D representations of the data, but I'd
> like to use the perspective plot if possible.
>
> Any advice?
>
> Cheers,
>
> Jeff
>
> __
> [EMAIL PROTECTED] mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
http://www.R-project.org/posting-guide.html
>
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] PNG Problem on Windows 98

2004-02-18 Thread Duncan Murdoch
On Wed, 18 Feb 2004 14:34:40 +0100 (MET), "Johannes Schnitzler"
<[EMAIL PROTECTED]> wrote :

>The png graphics are only on one computer correct.
>On the other computers - the x-axis labels, the legend text and the "mtext"
>(on the bottom) is missing. 
>Attached are simple example files one in jpg (which is ok) and one in png
>format.

I don't have access to a Win98 machine to test any more.  However, I
notice that I've been doing builds with an out of date version of the
PNG library (version 1.2.0).  I've just downloaded 1.2.5, and am
building r-devel with it.

Could you download r-devel from CRAN tomorrow, and see if this bug is
fixed?  (I'll upload it today, but it won't be visible until
tomorrow.)

You should look in

 

to find the download.  Make sure it is dated Feb 18 or later.

Duncan Murdoch

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] PNG Problem on Windows 98

2004-02-18 Thread Johannes Schnitzler

For clarification to my first email (PNG Problem on Windows 98 ), i'm using
R 1.8.1

<.with the new version of R it is normally no problem to produce very
fast
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] parse error in GLMM function

2004-02-18 Thread CENDOYA, Gabriela

“Douglas Bates” write:

>"CENDOYA, Gabriela" <[EMAIL PROTECTED]> writes:
>I'm trying to use the function GLMM from lme4 package, (R-1.8.1, Windows
>> 98),and I get the following error:
> > pd5 = GLMM(nplant~sitio+
>> + fert+
>> + remo+
>> + sitio:fert+
>> + remo:sitio+
>> + remo:fert+
>> + remo:fert:sitio
>> + data=datos,
>> + family=binomial,
>> + random=~repe:sitio)
>> Error in parse(file, n, text, prompt) : parse error

>Could you tell us the version of the lme4 package please?

lme4  version: 0.4-7


 About the “optional data frame” I didn’t want to sound “picky”, I just
mention it because I thought it could be related to the other problem.
 In fact, I am really amazed about how good, complete and clear are the help
pages in R.
Thanks again
Gabriela

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] pass by reference -- how to do it

2004-02-18 Thread Liaw, Andy
One needs to be more careful with "<<-" in R than in S-PLUS, because of the
scoping rule difference.  ?"<<-" says:

 The operators '<<-' and '->>' cause a search to made through the
 environment for an existing definition of the variable being
 assigned.  If such a variable is found then its value is
 redefined, otherwise assignment takes place globally. Note that
 their semantics differ from that in the S language, but is useful
 in conjunction with the scoping rules of R.

Andy

> From: Gabor Grothendieck
> 
> If you don't mind NOT passing your arrays at all then you 
> can do this:
> 
> f <- function() a[1] <<- a[1] + 1
> a <- 1:5
> f()  # increments first element of a by 1
> a # c(2,2,3,4,5)
> 
> The <<- causes the expression to take place in the global 
> environment.
> 
> If you want to actually pass your arrays by reference then the
> following works although its a bit messy:
> 
> g <- function(z) eval(eval(substitute(expression(z[1] <<- z[1]+1
> a <- 1:5
> g(a)  # increments first element of a by 1
> a # c(2,2,3,4,5)
> 
> The <<- causes the expression to be evaluated in the global 
> environment. expression() turns its argument into an object
> of mode expression.  substitute() replaces z with the argument 
> passed to f in that expression and returns an object of mode 
> call.  The inner eval turns the object of mode call into an 
> object of mode expression and the outer eval evaluates that 
> expression.  
> 
> ---
> Date:   Tue, 17 Feb 2004 13:23:58 -0800 (PST) 
> From:   Robert Dodier <[EMAIL PROTECTED]>
> To:   <[EMAIL PROTECTED]> 
> Subject:   [R] pass by reference -- how to do it 
> 
>  
> Hello,
> 
> Pass by reference appears to be a topic which comes up
> from time to time, but I wasn't able to find something in
> the R-help archives which tells how to accomplish it.
> 
> I have a problem that you may have seen before -- R runs
> out of memory when processing large matrices. Part of the
> problem for me is that I am using some large matrices as
> function arguments, and these are modified, which leads 
> to allocating copies of the matrices. 
> 
> I would like to do the modification "in place" so that
> a copy is not required. Thanks for any light you can shed
> on this.
> 
> If you're tempted to tell me "you don't really want to do that" --
> let me save you the trouble. You are so very right! Indeed I
> don't want to have pass by reference variables. OTOH I don't
> want R to come to a dead halt at an inconvenient time either.
> 
> Thanks for your help,
> Robert Dodier
> 
> __
> [EMAIL PROTECTED] mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 
> 
> __
> [EMAIL PROTECTED] mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 
> 


--
Notice:  This e-mail message, together with any attachments,...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


re: [R] ANOVA procedure on the sufficient statistics

2004-02-18 Thread Michael Friendly


Hi, 
I have a two-way anova with unequal cell numbers that I want to analyze. 
The problem is I don't have individual observations of the data.
I only have the sufficient statistics (mean, variance, # of observations) for each cell. 
Is there any existing function in S-plus that would allow me to do aov() with the sufficient statistics?
 

See:
David Larsen, Analysis of Variance With Just Summary Statistics
  as Input,  The American Statistician, May 1992, Vol. 46(2), 151-152.
This is implemented in SAS,
 Doc: http://www.math.yorku.ca/SCS/sasmac/stat2dat.html
Shouldn't be hard to do in R.

--
Michael Friendly Email: [EMAIL PROTECTED] 
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele Streethttp://www.math.yorku.ca/SCS/friendly.html
Toronto, ONT  M3J 1P3 CANADA

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] ANOVA procedure on the sufficient statistics

2004-02-18 Thread Liaw, Andy
You can apply the trick that Prof. Dalgaard recently posted in response to a
similar question (for one-way ANOVA).  For each cell, generate data as:

y <- cell.mean + cell.sd * scale(rnorm(cell.count))

Then generate the data frame to feed to aov.

HTH,
Andy

> From: Yun-Fang Juan
> 
> Hi, 
> I have a two-way anova with unequal cell numbers that I want 
> to analyze. 
> The problem is I don't have individual observations of the data.
> I only have the sufficient statistics (mean, variance, # of 
> observations) for each cell. 
> Is there any existing function in S-plus that would allow me 
> to do aov() with the sufficient statistics?
>  
> The table is like 
> 
>  G1 G2 G3 G5 G6
>  T1 
>  T2
>  T3
> 
> 
> For cell (Ti, Gj) i have mean,  variance and # observations 
> and the factors are unordered.
> 
> Thanks a lot for helping me on this in advance.
> 
> 
> Yun-Fang
>   [[alternative HTML version deleted]]
> 
> __
> [EMAIL PROTECTED] mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 
> 


--
Notice:  This e-mail message, together with any attachments,...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] perhaps 'aggregate()' (was: How to write efficient R code)

2004-02-18 Thread Tom Blackwell
Sebastian and Andy  -

Yes, Andy has read the question correctly.  A similar task that
I do quite often is to subtract the mean of a class from all of
the members of the class, and do this within every column of a
(numeric) data frame.  Kurt Hornik's function  aggregate()  is
the one to use.  Here's an example using the same data set that
he uses in the example on the help page.  (Only the commands are
shown here.  You'll have to try them to see the output, because
I cannot cut and paste easily into my email.)

data(state)
ls()
#  This data set puts individual columns into your workspace,
#  rather than making a data frame of them.

example <- data.frame(state.abb, state.name, state.region, state.x77)
str(example)
means   <- aggregate(example[ ,3+seq(8)], list(example[ ,3]), mean)
str(means)
residuals <- example[ ,3+seq(8)] - means[as.numeric(example[ ,3]), -1]
result  <- cbind(example[ ,seq(3)], residuals)
str(result)

 -- Ah, I think this example would be easier to read if I had used
the columns from the workspace directly, rather than packaging them
into a data frame 'example' first, the using numeric subscripts on
the data frame.  But, at least this illustrates some common ways of
subscripting subsets of columns from a data frame.

Again, see  help("aggregate"), help("Subscript")  to see what I am
doing here.

-  best  -  tom blackwell  -  u michigan medical school  -  ann arbor  -

(Ah, I see that Andy has just replied this morning as well.  I'll see
what his reply was as soon as I send off this one.)

On Tue, 17 Feb 2004, Sebastian Luque wrote:

> Hi,
>
> This is exactly what I meant Andy, the stratifying variable can be
> thought of as a factor. However, I tried your code and I get the error:
> "Error in Ops.data.frame..- only defined for equally-sized data
> frames". What may be happening?
> The result of 'apply' functions, or 'split' or 'by' and the like give
> lists as results, with a names attribute that, in my case, would have
> the levels of the factor. How can one get the results back to a
> data.frame object, with the newly calculated variables? The indexing for
> lists is not as straight forward as for data frames.
>
> Thanks to both of you for showing me the power of indexing in R functions!
>
> Sebastian
>
>
> Liaw, Andy wrote:
>
> >I'm guessing what Sebatian want is to do the differencing by a stratifying
> >variable such as ID; e.g., the data may look like:
> >
> >df <- as.data.frame(cbind(ID=rep(1:5, each=3), x=matrix(rnorm(45), 15, 3))
> >
> >So using Tom's solution, one would do something like:
> >
> >mdiff <- function(x) x[-1,] - x[nrow(x),]
> >sapply(split(df[,-1], df[,1]), mdiff)
> >
> >There could well be more efficient ways!
> >
> >Andy
> >
> >
> >
> >>From: Tom Blackwell
> >>
> >>Sebastian  -
> >>
> >>For successive differences within a single column 'x'
> >>
> >>differences <- c(NA, diff(x)),
> >>
> >>same as
> >>
> >>differences <- c(NA, x[-1] - x[-length(x)]).
> >>
> >>See  help("diff"), help("Subscript").  The second version also
> >>works when  x  is a matrix or a data frame, except now the result
> >>is a matrix or data frame of the same size.
> >>
> >>x <- data.frame(matrix(rnorm(1e+5), 1e+4))
> >>dim(x)   # 110
> >>differences <- rbind(rep(NA, 10), x[-1, ] - x[-dim(x)[1], ])
> >>dim(differences) # 110
> >>
> >>However, you write "I need to do this for all the subsets of data
> >>created by the numbers in one of the columns of the data frame ..."
> >>and I'm not sure I understand how an 'id' column would create many
> >>subsets of the data.  So the simple examples above may not answer
> >>the question you are asking.
> >>
> >>-  tom blackwell  -  u michigan medical school  -  ann arbor  -
> >>
> >>On Tue, 17 Feb 2004, Sebastian Luque wrote:
> >>
> >>
> >>
> >>>Hi,
> >>>
> >>>In fact, I've been trying to get rid of loops in my code for more
> >>>than a week now, but nothing I try seems to work. It sounds as if
> >>>you have lots of experience with loops, so would appreciate any
> >>>pointers you may have on the following.
> >>>
> >>>I want to create a column showing the difference between the ith
> >>>row and i-1. Of course, the first row won't have any value in it,
> >>>because there is nothing above it to subtract to. This is fairly
> >>>easy to do with a simple loop, but I need to do this for all the
> >>>subsets of data created by the numbers in one of the columns of
> >>>the data frame (say, an id column). I would greatly appreciate
> >>>any idea you may have on this.
> >>>
> >>>Thanks in advance.
> >>>
> >>>Best regards,
> >>>Sebastian
> >>>--
> >>>  Sebastian Luque
> >>>
> >>>[EMAIL PROTECTED]
> >>>
> >>>
> >>>
> >>>
> >>__
> >>[EMAIL PROTECTED] mailing list
> >>https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> >>PLEASE do read the posting guide!
> >>http://www.R-project.org/posting-guide.html
> >>
> >>
> >>
> >>
> >
> >
> >-

[R] PNG Problem on Windows 98

2004-02-18 Thread Johannes Schnitzler
Dear all,


with the new version of R it is normally no problem to produce very fast
graphics in the png format.

In the office i want to work with R - Windows 98 is used.
There are french versions and english versions of Windows 98 second edition.

The png graphics are only on one computer correct.
On the other computers - the x-axis labels, the legend text and the "mtext"
(on the bottom) is missing. 
Attached are simple example files one in jpg (which is ok) and one in png
format.

produced with:

png("test3.png");
plot(1:100);
mtext(c("aaa","bbb"),c(1,2),c(4,1));
legend(50,50,"");
dev.off()

for jpeg with jpeg(..)


Any idea where the difference in the installation could be, like missing
files ore necesarry updates for the windows system? 

Thank you very much in advance for any help.  


Johannes__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

RE: [R] How to write efficient R code

2004-02-18 Thread Liaw, Andy
Sorry about the typo.  There should be a "-" in front of nrow(x); i.e.,

mdiff <- function(x) x[-1,] - x[-nrow(x),]

... and sapply() won't work, but lapply() will.  So the whole thing looks
like:

> do.call("rbind",lapply(split(df[,-1], df$ID), function(x) x[-1,] -
x[-nrow(x),]))
 V2 V3 V4
1.2  -0.1250197  0.6446575 -1.0504143
1.3  -0.4104924  0.5638618  2.4117082
2.5  -3.1917997 -1.8687987 -0.9026947
2.6   2.2405199  3.5321711  1.0417581
3.8   1.7029947  0.3666408  0.8117269
3.9  -1.6701011 -0.8246094 -0.9099002
4.11  0.5183960  1.1066630  1.0484818
4.12  0.3563826 -1.9202869 -3.5635572
5.14  2.2746317  2.9820733 -2.4086057
5.15 -2.5767889 -2.5492538 -0.3083154

However, looking at this, I can't imagine this being the most efficient way
to go about it.  If the IDs are contiguous (i.e., data for the same ID are
in consecutive rows), then you can operate on the entire data and then throw
out the unwanted row of each ID:

> df.diff <- df[-1, -1] - df[-nrow(df), -1]
> del <- which(diff(as.numeric(df$ID)) != 0)
> del
[1]  3  6  9 12
> df.diff[-del,]
   V2 V3 V4
2  -0.1250197  0.6446575 -1.0504143
3  -0.4104924  0.5638618  2.4117082
5  -3.1917997 -1.8687987 -0.9026947
6   2.2405199  3.5321711  1.0417581
8   1.7029947  0.3666408  0.8117269
9  -1.6701011 -0.8246094 -0.9099002
11  0.5183960  1.1066630  1.0484818
12  0.3563826 -1.9202869 -3.5635572
14  2.2746317  2.9820733 -2.4086057
15 -2.5767889 -2.5492538 -0.3083154

HTH,
Andy

> From: Sebastian Luque [mailto:[EMAIL PROTECTED] 
> 
> Hi,
> 
> This is exactly what I meant Andy, the stratifying variable can be 
> thought of as a factor. However, I tried your code and I get 
> the error: 
> "Error in Ops.data.frame..- only defined for equally-sized data 
> frames". What may be happening?
> The result of 'apply' functions, or 'split' or 'by' and the like give 
> lists as results, with a names attribute that, in my case, would have 
> the levels of the factor. How can one get the results back to a 
> data.frame object, with the newly calculated variables? The 
> indexing for 
> lists is not as straight forward as for data frames.
> 
> Thanks to both of you for showing me the power of indexing in 
> R functions!
> 
> Sebastian
> 
> 
> Liaw, Andy wrote:
> 
> >I'm guessing what Sebatian want is to do the differencing by 
> a stratifying
> >variable such as ID; e.g., the data may look like:
> >
> >df <- as.data.frame(cbind(ID=rep(1:5, each=3), 
> x=matrix(rnorm(45), 15, 3))
> >
> >So using Tom's solution, one would do something like:
> >
> >mdiff <- function(x) x[-1,] - x[nrow(x),]
> >sapply(split(df[,-1], df[,1]), mdiff)
> >
> >There could well be more efficient ways!
> >
> >Andy
> >
> >  
> >
> >>From: Tom Blackwell
> >>
> >>Sebastian  -
> >>
> >>For successive differences within a single column 'x'
> >>
> >>differences <- c(NA, diff(x)),
> >>
> >>same as
> >>
> >>differences <- c(NA, x[-1] - x[-length(x)]).
> >>
> >>See  help("diff"), help("Subscript").  The second version also
> >>works when  x  is a matrix or a data frame, except now the result
> >>is a matrix or data frame of the same size.
> >>
> >>x <- data.frame(matrix(rnorm(1e+5), 1e+4))
> >>dim(x)   # 110
> >>differences <- rbind(rep(NA, 10), x[-1, ] - x[-dim(x)[1], ])
> >>dim(differences) # 110
> >>
> >>However, you write "I need to do this for all the subsets of data
> >>created by the numbers in one of the columns of the data frame ..."
> >>and I'm not sure I understand how an 'id' column would create many
> >>subsets of the data.  So the simple examples above may not answer
> >>the question you are asking.
> >>
> >>-  tom blackwell  -  u michigan medical school  -  ann arbor  -
> >>
> >>On Tue, 17 Feb 2004, Sebastian Luque wrote:
> >>
> >>
> >>
> >>>Hi,
> >>>
> >>>In fact, I've been trying to get rid of loops in my code for more
> >>>than a week now, but nothing I try seems to work. It sounds as if
> >>>you have lots of experience with loops, so would appreciate any
> >>>pointers you may have on the following.
> >>>
> >>>I want to create a column showing the difference between the ith
> >>>row and i-1. Of course, the first row won't have any value in it,
> >>>because there is nothing above it to subtract to. This is fairly
> >>>easy to do with a simple loop, but I need to do this for all the
> >>>subsets of data created by the numbers in one of the columns of
> >>>the data frame (say, an id column). I would greatly appreciate
> >>>any idea you may have on this.
> >>>
> >>>Thanks in advance.
> >>>
> >>>Best regards,
> >>>Sebastian
> >>>--
> >>>  Sebastian Luque
> >>>
> >>>[EMAIL PROTECTED]
> >>>
> >>>
> >>>  
> >>>
> >>__
> >>[EMAIL PROTECTED] mailing list
> >>https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> >>PLEASE do read the posting guide! 
> >>http://www.R-project.org/posting-guide.html
> >>
> >>
> >>
> >>
> >
> >
> >-

[R] Plotting a three parameter gamma distribution

2004-02-18 Thread Mårten Bjellerup
using GammaDist you have to normalize so that the location parameter equals
zero. However, I want to plot a gamma distribution using the three parameter
distribution, i.e. I want to be able to specify the location parameter. Does
anybody now how I can do this or is there already a routine somewhere that I
haven't found?

Thanx in advance,

Mårten


Mårten Bjellerup
Doctoral Student in Economics
School of Management and Economics
Växjö University
SE-351 95  Växjö
Sweden

Tel: +46 470 708410
Fax: +46 470 82478
Mobile: +46 70 969 88 88
Mail: [EMAIL PROTECTED]
Web: http://www.ehv.vxu.se
-
"Forecasting is like trying to
drive a car blindfolded and
following directions given
by a person who is looking
out of the back window"

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] problem with fitdistr ?

2004-02-18 Thread Prof Brian Ripley
On 18 Feb 2004, Peter Dalgaard wrote:

> Prof Brian Ripley <[EMAIL PROTECTED]> writes:
> 
> > It works under the versions 7.2-0 dated Jan 22 or later: that on CRAN is 
> > dated Jan 14 and predates 7.1-14.
> > 
> > Since R-devel is `under development', the pieces are not at all times in 
> > sync.
> 
> OK. I'm still picking up the older version from CRAN on r-devel
> builds, though.

I have submitted an update to CRAN.

> I'd bump the build number rather than rely on the date to discern
> different versions of packages.

I do once they are released, but this one is not released (hence the -0).

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

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] problem with fitdistr ?

2004-02-18 Thread Peter Dalgaard
Prof Brian Ripley <[EMAIL PROTECTED]> writes:

> It works under the versions 7.2-0 dated Jan 22 or later: that on CRAN is 
> dated Jan 14 and predates 7.1-14.
> 
> Since R-devel is `under development', the pieces are not at all times in 
> sync.

OK. I'm still picking up the older version from CRAN on r-devel
builds, though.

I'd bump the build number rather than rely on the date to discern
different versions of packages.

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

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Generating 2x2 contingency tables

2004-02-18 Thread Mahmoud K. Okasha
Hi again,
Thank you. I solved my problem by sampling from the multinomial
distribution..
Best regards ...

- Original Message -
From: "Torsten Hothorn" <[EMAIL PROTECTED]>
To: "Mahmoud K. Okasha" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Wednesday, February 18, 2004 9:30 AM
Subject: Re: [R] Generating 2x2 contingency tables


>
> On Tue, 17 Feb 2004, Mahmoud K. Okasha wrote:
>
> > Hello R-users,
> >
> > I would like to generate two-way contingency tables with zero in one
cell. I tried to use the function r2dtable but I could not force one cell to
have zero value.
> >
>
> r2dtable samples from the conditional distribution of the table given the
> margins. And with margins fixed AND one cell fixed (to zero) the
> conditional distribution just puts mass one at the observed table.
>
> You may want to sample from a multinomial distribution with one
> of the parameters fixed to zero.
>
> Best,
>
> Torsten
>
> > Any Idea?
> >
> > Best regards..
> > Mahmoud
> > [[alternative HTML version deleted]]
> >
> > __
> > [EMAIL PROTECTED] mailing list
> > https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
> >
> >
>
>

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Ang: [R] How to write efficient R code

2004-02-18 Thread Sixten Borg
Hej Lennart,

I would like to add one thing:
Often, there already exists an R function that solves the problem at hand. Instead of 
writing your own function, search the help files [apropos(), help.search()]. What I 
some times find difficult though, is guessing what key words will produce relevant 
search hits...

Mvh
Sixten

>>> <[EMAIL PROTECTED]> 2004-02-17 15:36:12 >>>
I have been lurking in this list a while and searching in the archives to
find out how one learns to write fast R code. One solution seems to be to
write part of the code not in R but in C. However after finding a benchmark
article (http://www.sciviews.org/other/benchmark.htm) I have been more
interested in making the R code itself more efficient. I would like to find
more info about this. I have tried to mail the contact person for the
benchmark, but I have so recieved no reply.

I am not an R programmer (or statistican) so I do not know R well. I am
looking for some advice about writing fast R code. What about the different
data types for example? Is there some good place to start to look for more
info about this? 


Thanks for any pointers
Lennart

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help 
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] problem with fitdistr ?

2004-02-18 Thread Prof Brian Ripley
On Wed, 18 Feb 2004, Ernesto Jardim wrote:

> On Tue, 2004-02-17 at 18:59, Prof Brian Ripley wrote:
> > Which version of MASS (not that you gave me any credit)?  This works in 
> > the current 7.1-14.
> > 
> > On Tue, 17 Feb 2004, Ernesto Jardim wrote:
> > 
> > > I'm trying fitdistr but I'm getting some errors
> > > 
> > > > fitdistr(rnorm(100),"Normal")
> > > Error in fitdistr(rnorm(100), "Normal") : 'start' must be a named list
> > > > fitdistr(rnorm(100),"Normal",start=list(mean=0,sd=1))
> > > Error in fitdistr(rnorm(100), "Normal", start = list(mean = 0, sd = 1))
> > > :
> > > supplying pars for the Normal is not supported
> > > 
> > > 
> > > What is the problem here ? Am I doing something wrong ?
> 
> Hi,
> 
> I'm using R-1.8.1 with MASS 7.1-13. Sorry for not mentioning MASS.

It was a bug in that version (only, AFAICS -- 7.1-12 required start 
values).  Please update to 7.1-14.

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

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] problem with fitdistr ?

2004-02-18 Thread Ernesto Jardim
On Tue, 2004-02-17 at 18:59, Prof Brian Ripley wrote:
> Which version of MASS (not that you gave me any credit)?  This works in 
> the current 7.1-14.
> 
> On Tue, 17 Feb 2004, Ernesto Jardim wrote:
> 
> > I'm trying fitdistr but I'm getting some errors
> > 
> > > fitdistr(rnorm(100),"Normal")
> > Error in fitdistr(rnorm(100), "Normal") : 'start' must be a named list
> > > fitdistr(rnorm(100),"Normal",start=list(mean=0,sd=1))
> > Error in fitdistr(rnorm(100), "Normal", start = list(mean = 0, sd = 1))
> > :
> > supplying pars for the Normal is not supported
> > 
> > 
> > What is the problem here ? Am I doing something wrong ?

Hi,

I'm using R-1.8.1 with MASS 7.1-13. Sorry for not mentioning MASS.

Regards

EJ



Information on Package 'MASS'

Description:
 
Package: MASS
Description: The main library and the datasets
Title: Main Library of Venables and Ripley's MASS
Bundle: VR
Priority: recommended
Version: 7.1-13
Date: 2003-12-06
Depends: R (>= 1.8.0), lattice, nlme (>= 3.1-40), survival
Author: S original by Venables & Ripley. R port by Brian Ripley
<[EMAIL PROTECTED]>, following earlier work by Kurt Hornik
and Albrecht Gebhardt.
Maintainer: Brian Ripley <[EMAIL PROTECTED]>
BundleDescription: Functions and datasets to support Venables and
Ripley, 'Modern Applied Statistics with S' (4th edition).
License: GPL (version 2 or later)
URL: http://www.stats.ox.ac.uk/pub/MASS4/
Packaged: Sat Dec 6 20:47:49 2003; ripley
Built: R 1.8.1; i686-pc-linux-gnu; 2004-01-08 15:37:40; unix

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] problem with fitdistr ?

2004-02-18 Thread Prof Brian Ripley
It works under the versions 7.2-0 dated Jan 22 or later: that on CRAN is 
dated Jan 14 and predates 7.1-14.

Since R-devel is `under development', the pieces are not at all times in 
sync.

On 18 Feb 2004, Peter Dalgaard wrote:

> Prof Brian Ripley <[EMAIL PROTECTED]> writes:
> 
> > Which version of MASS (not that you gave me any credit)?  This works in 
> > the current 7.1-14.
> 
> Odd things are happening for me with r-devel, though:
> 
> > library(MASS)
> > fitdistr(rnorm(100),"Normal")
> Error in dn[[2]] : subscript out of bounds
> > fitdistr(rnorm(100),"Normal",start=list(mean=0,sd=1))
> Error in fitdistr(rnorm(100), "Normal", start = list(mean = 0, sd =
> > 1)) :
> supplying pars for the Normal is not supported
> > x <- fitdistr(rnorm(100),"normal")
> > x
> Error in dn[[2]] : subscript out of bounds
> > str(x)
> List of 2
>  $ estimate: num 0.217
>  $ sd  : num 0.99
>  - attr(*, "class")= chr "fitdistr"
> 
> And the rest of the story is that this bit of print.fitdistr computes
> "ans" without dimnames and thus refers to dn[[2]] before there's
> anything there:
> 
> ans <- format(rbind(x$estimate, x$sd), digits = digits)
> ans[1, ] <- sapply(ans[1, ], function(x) paste("", x))
> ans[2, ] <- sapply(ans[2, ], function(x) paste("(", x, ")",
> sep = ""))
> dn <- dimnames(ans)
> dn[[1]] <- rep("", 2)
> dn[[2]] <- paste(substring("  ", 1, (nchar(ans[2, ]) -
> nchar(dn[[2]]))%/%2), dn[[2]])
> 
> 
>  
> 
> 

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

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html