Re: [R] read.spss and umlaut

2006-08-04 Thread Thomas Kuster
Hello

Am Donnerstag, 3. August 2006 15.34 schrieb Thomas Lumley:
 On Thu, 3 Aug 2006, Thomas Kuster wrote:
  Hello
 
  Am Mittwoch, 2. August 2006 17.11 schrieb Thomas Lumley:
...
 You haven't shown anything that indicates that the C code stopped reading.
 More likely R just stops displaying when it gets to an illegal byte
 sequence.  You could use nchar() to count the bytes in the string to find
 out.

If I change the translatable characters (overwrite the 0 between :#@'= and 
~000 with ÄÖÜäöü). I can read in the file an every ÄÖÜäöü ist a withspace:
 daten - read.spss(projets_umlaut.por)
 levels(daten$PROJETX)
  [1] Bg Stammzellenforschung
  [2] Bb   ber eine neue Finanzordnung
  [3] Bb Neugestaltung des Finanzausgleichs
  [4]  nderrung Bg  EOG Mutterschafturlaub
  [5] EV Postdienste f r alle
  [6] Bb  ber B rgerrechtserwerb 3. Generation
  [7] Bb  ber erleichterte Einb rung 2. Generation
  [8] Bg Steuerpaket
   .
   .
   .
 levels(daten$PROJETX)[208]
[1] EV Gleiche Rechte f r Mann und Frau Gegenvorschlag
 charToRaw(levels(daten$PROJETX)[208])
 [1] 45 56 20 47 6c 65 69 63 68 65 20 52 65 63 68 74 65 20 66 20 72 20 4d 61 
6e
[26] 6e 20 75 6e 64 20 46 72 61 75 20 47 65 67 65 6e 76 6f 72 73 63 68 6c 61 
67

without change the table I get:
 daten - read.spss(projets.por)
 charToRaw(levels(daten$PROJETX)[208])
 [1] 45 56 20 47 6c 65 69 63 68 65 20 52 65 63 68 74 65 20 66

The SPSS file is from:
http://voxit.sidos.ch/update.asp?lang=d
- Download der kumulierten Dateien Version 2.0

You must accept this:
The Standardized Post-Vote Surveys:
http://voxit.sidos.ch/agreement.asp?lang=emenu=0

Thomas

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


Re: [R] gnlsControl

2006-08-04 Thread Dieter Menne
Daniel Coleman coleman.daniel at gene.com writes:

 
 When I run gnls I get the error:
 
 Error in nls(y ~ cbind(1, 1/(1 + exp((xmid - x)/exp(lscal, data = xy,  :
 
 step factor 0.000488281 reduced below 'minFactor' of 0.000976563
 
 My first thought was to decrease minFactor but gnlsControl does not contain
 minFactor nor nlsMinFactor (see below).  It does however contain nlsMaxIter
 and nlsTol which I assume are the analogs of maxiter and tol in nls.control.
 I would be happy to hear from anyone who has an idea on what parameters in
 gnlsControl to change to get convergence.  

Try nlsTol with a large value, e.g. 0.3. If I am really desparate, I put the
gnls in a try() structure, halving nlsTol until it fails, and take the last
successful. 

Dieter

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


Re: [R] Questions about sweave...

2006-08-04 Thread Dieter Menne
Brian Lunergan ff809 at ncf.ca writes:

 
 Evening all:
 
 I'm taking a little time to experiment with R, Sweave, and Miktex/LaTex but 
 I've run up against some problems and -well- I hope that there are some on 
 the list who might have some suggestions. This will be kind of wordy as I 
 will include the complete files involved as I'm just not sure what I'm 
 looking for. Apologies at the outset.

This is Windows special

See A.12: 
http://www.ci.tuwien.ac.at/~leisch/Sweave/FAQ.html

And put a commented (!sic) \usepackage into the header (don't remember where I
found this)

% \usepackage{Sweave} 


Dieter

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


[R] geodesic distance (solution)

2006-08-04 Thread stefano iacus
  Hi,
  has anyone ever seen implemented in R the following geodesic
  distance between positive definite pxp matrices A and B?
 
  d(A,B) = \sum_{i=1}^p (\log \lambda_i)^2
 
  were \lambda is the solution of det(A -\lambda B)  = 0
 
  thanks
  stefano

as I received few private email on the claimed solution, I'm posting  
it to r-help.

when matrix B is invertible (which is always my case), one approach  
is to notice that
solving

det(A -\lambda * B)  = 0

is equivalent to solve

det(B^-1*A -\lambda *I)  = 0

which is a standard eigen value problem for the matrix B^-1 * A, hence

eigen(solve(B) %*% A)$values

is the answer.

I'm pretty sure that the problem can also be solved using some svd  
decomposition when B is not invertible.

hope it helps
stefano

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


Re: [R] Building a random walk vector

2006-08-04 Thread Ben Bolker
Matthew Wilson matt at overlook.homelinux.net writes:

 
 I'm studying R in my free time.  I want to build a vector where each
 element is equal to the element before it in the sequence plus some
 random tweak.
 

  You will probably get many answers to this, but
I think

vec - 100+c(0,cumsum(runif(49,-2,2)))

works.

  Ben Bolker

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


[R] need sample parallelized R scripts

2006-08-04 Thread Deomano, Emily \(IRRI\)
Good day to everyone.

I'm working on computing correlation for several datasets (one dataset for each 
chromosome).  Computation is done several thousand times for each dataset which 
at present takes around 13 hours. We have a HPC machine with MPI.  snow package 
and R 2.3.1 running in Linux (Rocks) are installed in the machine.  I need to 
modify the script to run it on several nodes.  I do not have experience in 
writing parallel scripts.

Anybody knows where I can find sample R scripts that are designed to run on 
parallel machines?  

Thanks.
Ems



Emily Deomano
Crop Research Informatics Laboratory
The International Rice Research Institute DAPO Box  Metro Manila, 
Philippines
Email: [EMAIL PROTECTED];  Tel No: (63-2) 580-5600;  Fax No: (63-2) 580-5699

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


[R] Integration and Loop in R

2006-08-04 Thread Lorenzo Isella
Dear All,
I have seldom needed to use loops in R, but now I need to code a loop
with a stride different from one.
In the R manual I downloaded I have the example:
 xc - split(x, ind)
 yc - split(y, ind)
 for (i in 1:length(yc)) {
plot(xc[[i]], yc[[i]]);
abline(lsfit(xc[[i]], yc[[i]]))
  }
but in my case I'd like to add a condition so that i varies by 4 from
one go to the following one. I cannot figure out the right syntax, can
anyone help here?
Another thing (which could possibly solve my problem): I had a look at
integrate command in R.
It seems to require an object defined as a function to carry out the
integration.
What if I simply have a list of data values? How can I coerce them
into a function recognized by R? Furthermore, are there R routines to
carry out the integration on a non-equally spaced 1D grid?
Best Regards

Lorenzo

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


Re: [R] bullseye or polar display of circular data

2006-08-04 Thread Jim Lemon
Michael Jerosch-Herold wrote:
 I have data for several rings of a left heart chamber, and which I would like 
 to display in concentric rings, with color-encoding of the values. Each ring 
 corresponds to one slice through the heart, and the rings correspond to 
 positions from the base to the apex of the heart as you move from the 
 outermost ring to the innermost one. The data have a circular pattern. These 
 types of displays are referred to as bullseye displays in the nuclear 
 medicine literature. Does any reader of these messages know of a R 
 function/package that offers this functionality?
 
 Also I noticed that in some contexts you can define a circular attribute 
 for your data. Are there plot routines for such circular data?
 
I'm not quite sure that I understand the display you want, but 
radial.plot in the plotrix package might do what you want. Also you 
could check the circular and CircStats packages.

Jim

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


[R] prettyR arrives

2006-08-04 Thread Jim Lemon
Hi all,

I have finally gotten the prettyR package going (many thanks to Kurt 
Hornik for his patience).

prettyR is a set of functions that allows the user to produce HTML 
output from R scripts. Given an R script that runs properly, an HTML 
listing complete with embedded graphics can be produced simply by 
passing the script to the core function htmlize (Phillipe Grosjean has 
not only offered great suggestions, but provided a fancier function 
named R2html). It is even possible to have the output magically appear 
in your friendly local HTML browser when the script has been processed.

The package includes some basic descriptive functions that display the 
usual suspects in formats that should not agitate those accustomed to 
the vanilla listings that abound in the real world.

prettyR is intended to assist the R beginner in producing basic stats 
right from the word go. No knowledge beyond that of writing an R 
script is required, but there is quite a bit of room to learn and 
innovate. Have fun and please let me know if you break it.

Jim

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


Re: [R] Looking for transformation to overcome heterogeneity of variances

2006-08-04 Thread Paul Smith
Thanks to all contributors for the fruitfulness of this discussion. I
am speculating about a simpler solution: to use a non-parametric
approach. To avoid the requirement of having normal residuals, Frank
Harrell has suggested here the following non-parametric procedure:

library(Design)  # also requires library(Hmisc)
f - lrm(y ~ a*b*c*d)
f
anova(f)

Could someone please tell me whether that also works when there is no
homoscedasticity? What are the assumptions of that method?

Paul

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


[R] User input from keyboard

2006-08-04 Thread chiya sharma
Dear All,

 Can anybody tell me the syntax for User input from keyboard in R. I mean
to say that if I run the program it should ask Please enter the date at
the begining of the program. I am using R-2.2.1 for windows.

Any help will be greatly appreciated.
thanks in advance.

Regards,
Chiya

[[alternative HTML version deleted]]

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


[R] Data frame referencing?

2006-08-04 Thread Sander Oom
Dear R users,

When you do:
 x - rnorm(10)
 y - rnorm(10)
 z - rnorm(10)
 a - data.frame(x,y,z)
 a$x
 [1]  1.37821893  0.21152756 -0.55453182 -2.10426048 -0.08967880  0.03712110
 [7] -0.80592149  0.07413450  0.15557671  1.22165341

Why does this not work:
 a[a$y0.5,y] -1
Error in [-.data.frame(`*tmp*`, a$y  0.5, y, value = 1) :
only 0's may be mixed with negative subscripts

While this works:
 a[a$y0.5,2] -1

 a
 x  y  z
1   1.37821893 -1.0887363  1.7340522
2   0.21152756 -0.7256467 -1.3165373
3  -0.55453182  1.000 -2.1116072
4  -2.10426048 -0.4898596 -1.5863823
5  -0.08967880  1.000 -0.9139706
6   0.03712110  1.000 -1.3004970
7  -0.80592149 -0.7004193 -0.1958059
8   0.07413450  1.000 -1.3574303
9   0.15557671 -0.3335407 -2.1991236
10  1.22165341  1.000 -0.7576708

For a complex loop I would prefer to reference the right colomn by name,
not by number! Now, when the colomns change, I need to check my code to
make sure that the right colomns are referenced.

Suggestions much appreciated!

Thanks in advance,

Sander.

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


Re: [R] Data frame referencing?

2006-08-04 Thread Gabor Grothendieck
When specifying a column name with [ the name must be quoted (unlike
when using it with $):

   a[a$y  0.5, y] - 1

On 8/4/06, Sander Oom [EMAIL PROTECTED] wrote:
 Dear R users,

 When you do:
  x - rnorm(10)
  y - rnorm(10)
  z - rnorm(10)
  a - data.frame(x,y,z)
  a$x
  [1]  1.37821893  0.21152756 -0.55453182 -2.10426048 -0.08967880  0.03712110
  [7] -0.80592149  0.07413450  0.15557671  1.22165341

 Why does this not work:
  a[a$y0.5,y] -1
 Error in [-.data.frame(`*tmp*`, a$y  0.5, y, value = 1) :
only 0's may be mixed with negative subscripts

 While this works:
  a[a$y0.5,2] -1

  a
 x  y  z
 1   1.37821893 -1.0887363  1.7340522
 2   0.21152756 -0.7256467 -1.3165373
 3  -0.55453182  1.000 -2.1116072
 4  -2.10426048 -0.4898596 -1.5863823
 5  -0.08967880  1.000 -0.9139706
 6   0.03712110  1.000 -1.3004970
 7  -0.80592149 -0.7004193 -0.1958059
 8   0.07413450  1.000 -1.3574303
 9   0.15557671 -0.3335407 -2.1991236
 10  1.22165341  1.000 -0.7576708

 For a complex loop I would prefer to reference the right colomn by name,
 not by number! Now, when the colomns change, I need to check my code to
 make sure that the right colomns are referenced.

 Suggestions much appreciated!

 Thanks in advance,

 Sander.

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


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


[R] Problem with installing R under Windows

2006-08-04 Thread TAN Chong Hui
I have been trying to install R under Windows from the source by
following the instructions in R Installation and Adminstration.
Met with a list of problems along the way.

1) Recommended packages: 

I tried to do 

 make lnik-recommended

and 

 make rsync-recommended
 
In both cases, I got the message no rule to make target

Have I gotten the make directory wrongly?

2) Building core files:

After I did

 make all recommended 

in R_HOME/src/gnuwin32, the process ends with the following error
message:

 make --no-print-directory -C ../modules \
   OPTFLAGS='-O3 -Wall -pedantic -std=gnu99' FOPTFLAGS='-O3 -Wall' -f 
 Makefile.wi n gcc  -shared -s  -o lapack.dll lapack.def Lapack.o 
 dllversion.o -L../../../bin - lRlapack -lRblas -lR
 c:\minGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\mingw32\bin\ld.exe:
 cannot fin
 d -lRlapack
 collect2: ld returned 1 exit status
 make[5]: *** [lapack.dll] Error 1
 make[4]: *** [all] Error 2
 make[3]: *** [all] Error 1
 make[2]: *** [rmodules] Error 2
 make[1]: *** [rbuild] Error 2
 make: *** [all] Error 2

What should I be doing here?

3) Building manuals

After I did

 make manuals

in R_HOME/src/gnuwin32, the process ends with the error message

! LaTeX Error: File `datasets-pkg.tex' not found.

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

Enter file name:
! Emergency stop.
read *

l.77 \input{datasets-pkg.tex}

!  == Fatal error occurred, the output PDF file is not finished!
Transcript written on refman.log.
make[1]: *** [refman.pdf] Error 1
make: *** [manuals] Error 2

What should I be doing here?



Can anyone help?

Thanks.

Rgds
Chong Hui



[[alternative HTML version deleted]]

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


Re: [R] between-within anova: aov and lme

2006-08-04 Thread William Simpson
Well nobody answered :-(
Nobody on R-help is doing anovas I guess -- I don't blame them! (It's just for 
aggies.)

In the absence of any response and for no good reason I am doing:
fitn1 - aov(amplitude ~ stereo*site*stimulus + Error(subject), stereon1) This 
is
Bill Venables's way.
And when the data are unbalanced I am doing:
lme(amplitude ~ site+stimulus+stereo*stimulus, random=~1|subject, method=ML,
stereon1)

And I have no clue why.

Every discussion of between-within ANOVA I have read (practical or 
mathematical) is
either vacuous or opaque...

Cheers
Bill
 I have 2 questions on ANOVA with 1 between subjects factor and 2 within 
 factors.

 1. I am confused on how to do the analysis with aov because I have seen two
examples on the web with different solutions.

 a) Jon Baron (http://www.psych.upenn.edu/~baron/rpsych/rpsych.html) does 6.8.5
Example 5: Stevens pp. 468 - 474 (one between, two within)

 between: gp
 within: drug, dose
 aov(effect ~ gp * drug * dose + Error(subj/(dose*drug)), data=Ela.uni)

 b) Bill Venables answered a question on R help as follows.

 - factor A between subjects
 - factors B*C within subjects.

 aov(response ~ A*B*C + Error(subject), Kirk)
 An alternative formula would be response ~ A/(B*C) + Error(subject), which 
 would
only change things by grouping together some of the sums of squares.

 ---
 SO: which should I do
 aov(response ~ A*B*C + Error(subject), Kirk)
 aov(response ~ A/(B*C) + Error(subject), Kirk)
 aov(response ~ A*B*C + Error(subject/(B*C)), Kirk)
 

 2. How would I do the analysis in lme()?
 Something like
 lme(response~A*B*C,random=~1|subject/(B*C))???


 Thanks very much for any help!
 Bill Simpson

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


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


Re: [R] Data frame referencing?

2006-08-04 Thread Dimitris Rizopoulos
you need to use quotes, i.e.,

a[a$y  0.5, y] - 1

you can also use

a$y[a$y  0.5] - 1


I hope it helps.

Best,
Dimitris


Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
 http://www.student.kuleuven.be/~m0390867/dimitris.htm


- Original Message - 
From: Sander Oom [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Sent: Friday, August 04, 2006 1:48 PM
Subject: [R] Data frame referencing?


 Dear R users,

 When you do:
 x - rnorm(10)
 y - rnorm(10)
 z - rnorm(10)
 a - data.frame(x,y,z)
 a$x
 [1]  1.37821893  0.21152756 -0.55453182 -2.10426048 -0.08967880 
 0.03712110
 [7] -0.80592149  0.07413450  0.15557671  1.22165341

 Why does this not work:
 a[a$y0.5,y] -1
 Error in [-.data.frame(`*tmp*`, a$y  0.5, y, value = 1) :
only 0's may be mixed with negative subscripts

 While this works:
 a[a$y0.5,2] -1

 a
 x  y  z
 1   1.37821893 -1.0887363  1.7340522
 2   0.21152756 -0.7256467 -1.3165373
 3  -0.55453182  1.000 -2.1116072
 4  -2.10426048 -0.4898596 -1.5863823
 5  -0.08967880  1.000 -0.9139706
 6   0.03712110  1.000 -1.3004970
 7  -0.80592149 -0.7004193 -0.1958059
 8   0.07413450  1.000 -1.3574303
 9   0.15557671 -0.3335407 -2.1991236
 10  1.22165341  1.000 -0.7576708

 For a complex loop I would prefer to reference the right colomn by 
 name,
 not by number! Now, when the colomns change, I need to check my code 
 to
 make sure that the right colomns are referenced.

 Suggestions much appreciated!

 Thanks in advance,

 Sander.

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


Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm

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


Re: [R] User input from keyboard

2006-08-04 Thread Petr Pikal
Hi

cat(\n,Enter x,\n) # prompt
y-scan(n=1)

prompts for user imput and scans 1 line from console.

HTH
Petr



On 4 Aug 2006 at 17:06, chiya sharma wrote:

Date sent:  Fri, 4 Aug 2006 17:06:38 +0530
From:   chiya sharma [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Subject:[R] User input from keyboard

 Dear All,
 
  Can anybody tell me the syntax for User input from keyboard in R. I
  mean
 to say that if I run the program it should ask Please enter the date
 at the begining of the program. I am using R-2.2.1 for windows.
 
 Any help will be greatly appreciated.
 thanks in advance.
 
 Regards,
 Chiya
 
  [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html and provide commented,
 minimal, self-contained, reproducible code.

Petr Pikal
[EMAIL PROTECTED]

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


Re: [R] Data frame referencing?

2006-08-04 Thread Sander Oom
Dear Gabor and Dimitris,

Simple, once you know! It is these little exceptions on the R notation
that get me stuck. Now I am on the loose again!

Thanks,

Sander.

Dimitris Rizopoulos wrote:
 you need to use quotes, i.e.,
 
 a[a$y  0.5, y] - 1
 
 you can also use
 
 a$y[a$y  0.5] - 1
 
 
 I hope it helps.
 
 Best,
 Dimitris
 
 
 Dimitris Rizopoulos
 Ph.D. Student
 Biostatistical Centre
 School of Public Health
 Catholic University of Leuven
 
 Address: Kapucijnenvoer 35, Leuven, Belgium
 Tel: +32/(0)16/336899
 Fax: +32/(0)16/337015
 Web: http://med.kuleuven.be/biostat/
  http://www.student.kuleuven.be/~m0390867/dimitris.htm
 
 
 - Original Message - 
 From: Sander Oom [EMAIL PROTECTED]
 To: r-help@stat.math.ethz.ch
 Sent: Friday, August 04, 2006 1:48 PM
 Subject: [R] Data frame referencing?
 
 
 Dear R users,

 When you do:
 x - rnorm(10)
 y - rnorm(10)
 z - rnorm(10)
 a - data.frame(x,y,z)
 a$x
 [1]  1.37821893  0.21152756 -0.55453182 -2.10426048 -0.08967880 
 0.03712110
 [7] -0.80592149  0.07413450  0.15557671  1.22165341

 Why does this not work:
 a[a$y0.5,y] -1
 Error in [-.data.frame(`*tmp*`, a$y  0.5, y, value = 1) :
only 0's may be mixed with negative subscripts

 While this works:
 a[a$y0.5,2] -1
 a
 x  y  z
 1   1.37821893 -1.0887363  1.7340522
 2   0.21152756 -0.7256467 -1.3165373
 3  -0.55453182  1.000 -2.1116072
 4  -2.10426048 -0.4898596 -1.5863823
 5  -0.08967880  1.000 -0.9139706
 6   0.03712110  1.000 -1.3004970
 7  -0.80592149 -0.7004193 -0.1958059
 8   0.07413450  1.000 -1.3574303
 9   0.15557671 -0.3335407 -2.1991236
 10  1.22165341  1.000 -0.7576708

 For a complex loop I would prefer to reference the right colomn by 
 name,
 not by number! Now, when the colomns change, I need to check my code 
 to
 make sure that the right colomns are referenced.

 Suggestions much appreciated!

 Thanks in advance,

 Sander.

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

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

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


[R] Sweave special token \\ from R to latex

2006-08-04 Thread Jan Wijffels
Dear helpeRs,

I would like to specify a newline command in R and pass it to latex  
via Sweave such that it corresponds to latex' \\ command. But that  
doesn't seem to be possible. If I Sweave the \n character, it just  
makes a new line in latex but not the \\ command.

Is there a way such that the following code would result in latex in
blablabla \\ blablabla on different line


echo=FALSE=
   string - blablabla \\ blablabla on different line
@
\Sexpr{string}




Thanks for the help,
Jan

Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm

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


Re: [R] User input from keyboard

2006-08-04 Thread Prof Brian Ripley
On Fri, 4 Aug 2006, Petr Pikal wrote:

 Hi
 
 cat(\n,Enter x,\n) # prompt
 y-scan(n=1)
 
 prompts for user imput and scans 1 line from console.
(that scans one number: use readLines(n=1) to get a string).

But readline() is probably easier.

 
 HTH
 Petr
 
 
 
 On 4 Aug 2006 at 17:06, chiya sharma wrote:
 
 Date sent:Fri, 4 Aug 2006 17:06:38 +0530
 From: chiya sharma [EMAIL PROTECTED]
 To:   r-help@stat.math.ethz.ch
 Subject:  [R] User input from keyboard
 
  Dear All,
  
   Can anybody tell me the syntax for User input from keyboard in R. I
   mean
  to say that if I run the program it should ask Please enter the date
  at the begining of the program. I am using R-2.2.1 for windows.

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

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


Re: [R] Sweave special token \\ from R to latex

2006-08-04 Thread Markus J�ntti
Jan Wijffels wrote:
 Dear helpeRs,

 I would like to specify a newline command in R and pass it to latex
 via Sweave such that it corresponds to latex' \\ command. But that
 doesn't seem to be possible. If I Sweave the \n character, it just
 makes a new line in latex but not the \\ command.

 Is there a way such that the following code would result in latex in
 blablabla \\ blablabla on different line


 echo=FALSE=
string - blablabla \\ blablabla on different line
 @
 \Sexpr{string}


For reasons that I am unable to account for, you get the desired string
in your .tex file if you do

echo=FALSE=

string - blablabla  blablabla on different line

@

\Sexpr{print(string)}

resulting in the .tex file as

blablabla \\ blablabla on different line


It would seem that using echo=FALSE,results=tex
would be a good solution.

Markus




 Thanks for the help,
 Jan

 Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm

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



-- 
Markus Jantti
Abo Akademi University
[EMAIL PROTECTED]
http://www.iki.fi/~mjantti
###

This message has been scanned by F-Secure Anti-Virus for Mic...{{dropped}}

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


Re: [R] plotting picture data

2006-08-04 Thread Ritwik Sinha
Just a suggestion. It seems like each square can be denoted by x and y
coordinates. Then you essentially have a two dimensional histogram/density
that you need to plot. You can use the lattice functions
cloud/wireframe. You can also go for a heat map/contour plot, the
lattice functions for that will be levelplot/contourplot. In case the
number of squares are small, you might prefer a two-dimensional histogram,
cloud in lattice has an option to plot the point as histogram.

Ritwik.

On 8/4/06, Gichangi, Anthony [EMAIL PROTECTED] wrote:

 Hi R users

 I have a dataset which represents points that are market by patients as
 the
 source of pain.
 Basically the patients indicates by a cross on a chest pictures where
 he/she
 thinks is the
 source of pain. The data was then digitalized by divinding the chest into
 small squares and each
 square was give value 1 if it was the center 2 if it was touched by the
 markings and 3 if it was not
 touched.  I would like to plot this data on the chest like graph showing
 the
 intesities of different
 points and later stratify the grouping variables to see the difference.

 Has anybody got an idea how I can go around this ?

 Help is highly appreciated.

 Regards

 Anthony Gichangi, M. sc.
 Department of Statistics.
 JB. Winsløvej 9B,
 DK 5000 Odense C.
 Tel:   00 45 6550 3379
 Mobile:  00 45 61105805

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




-- 
Ritwik Sinha
Graduate Student
Epidemiology and Biostatistics
Case Western Reserve University

http://darwin.cwru.edu/~rsinha

[[alternative HTML version deleted]]

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


Re: [R] plotting picture data

2006-08-04 Thread Petr Pikal
Hi

seems to me that it can be done by image. See ?image.

Just as illustration.
mat-matrix(sample(c(1,rep(2,10), rep(3,50)), 1000, replace=T), 
100,100)
for(i in 1:6) mat[i,c(1:(50-5*i),(50+5*i):100)]-NA
for(i in 14:9) mat[i,c(1:(50-5*(15-i)),(50+5*(15-i)):100)]-NA
image(1:100,1:100,mat)

HTH
Petr


On 4 Aug 2006 at 15:12, Gichangi, Anthony wrote:

From:   Gichangi, Anthony [EMAIL PROTECTED]
To: R-help r-help@stat.math.ethz.ch
Date sent:  Fri, 4 Aug 2006 15:12:36 +0200
Subject:[R] plotting picture data

 Hi R users
 
 I have a dataset which represents points that are market by patients
 as the source of pain. Basically the patients indicates by a cross on
 a chest pictures where he/she thinks is the source of pain. The data
 was then digitalized by divinding the chest into small squares and
 each square was give value 1 if it was the center 2 if it was touched
 by the markings and 3 if it was not touched.  I would like to plot
 this data on the chest like graph showing the intesities of different
 points and later stratify the grouping variables to see the
 difference.
 
 Has anybody got an idea how I can go around this ?
 
 Help is highly appreciated.
 
 Regards
 
 Anthony Gichangi, M. sc.
 Department of Statistics.
 JB. Winslřvej 9B,
 DK 5000 Odense C.
 Tel:   00 45 6550 3379
 Mobile:  00 45 61105805
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html and provide commented,
 minimal, self-contained, reproducible code.

Petr Pikal
[EMAIL PROTECTED]

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


Re: [R] read.spss and umlaut

2006-08-04 Thread Thomas Lumley

On Fri, 4 Aug 2006, Thomas Kuster wrote:


If I change the translatable characters (overwrite the 0 between :#@'= and
~000 with ÄÖÜäöü). I can read in the file an every ÄÖÜäöü ist a withspace:


Ok, that's the problem then.  The file format says that the umlauts are 
unreadable and R is believing the file format.


I will look at adding an option to specify an encoding and ignore the 
translation table, but not very urgently.


-thomas

Thomas Lumley   Assoc. Professor, Biostatistics
[EMAIL PROTECTED]   University of Washington, Seattle__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] question

2006-08-04 Thread Jessica G.
Hi Mr Plate,

I have a little question

How to convert a rowname vector of numbers into a real column of the matrix,

My problem is that I applied a rowsum function on a matrix.
Then I get a matrix in which the names of the columns are the values of the 
group (numbers)
Now I need to make calculation on the groups row.
How to convert this vector of (rownames) into a real column in the matrix ?


thanks by advance

Jessica Gervais

_

www.windowslivemessenger.fr

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


[R] expression() - Superscript in y-axis, keeping line break in string

2006-08-04 Thread Andrew Kniss
I've tried several different ways to accomplish this, but as yet to no
avail.  My y-axis for a plot has a rather long label, and thus I have
been using /n to break it into two lines.  However, to make it
technically correct for publication, I also need to use superscript in
the label.  For example:

 par(oma=c(0,0,2,0),mar=c(5,6,0.25,2),lheight=1)
 plot(1:10,
  ylab=14C-glyphosate line1\n line2)

will provide the text in two lines as I would like it.  However, I am
trying to keep those same line breaks when using expression() to get my
superscript number.  This will not work, as it aligns the 14C section
with the bottom line of the expression making little sense to the
reader.

 par(oma=c(0,0,2,0),mar=c(5,6,0.25,2),lheight=1)
 plot(1:10,
  ylab=expression( ^14*C*-glyphosate line1\n line2))

Is there a way to align the 14C portion of the expression with the top
line of the string rather than the bottom line?  Any suggestions are
greatly appreciated.
Andrew


-- 
Andrew Kniss
Assistant Research Scientist
University of Wyoming 
Department of Plant Sciences

[EMAIL PROTECTED]
Office: (307) 766-3949
Fax:(307) 766-5549

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


Re: [R] expression() - Superscript in y-axis, keeping line break in string

2006-08-04 Thread Marc Schwartz (via MN)
On Fri, 2006-08-04 at 09:47 -0600, Andrew Kniss wrote:
 I've tried several different ways to accomplish this, but as yet to no
 avail.  My y-axis for a plot has a rather long label, and thus I have
 been using /n to break it into two lines.  However, to make it
 technically correct for publication, I also need to use superscript in
 the label.  For example:
 
  par(oma=c(0,0,2,0),mar=c(5,6,0.25,2),lheight=1)
  plot(1:10,
   ylab=14C-glyphosate line1\n line2)
 
 will provide the text in two lines as I would like it.  However, I am
 trying to keep those same line breaks when using expression() to get my
 superscript number.  This will not work, as it aligns the 14C section
 with the bottom line of the expression making little sense to the
 reader.
 
  par(oma=c(0,0,2,0),mar=c(5,6,0.25,2),lheight=1)
  plot(1:10,
   ylab=expression( ^14*C*-glyphosate line1\n line2))
 
 Is there a way to align the 14C portion of the expression with the top
 line of the string rather than the bottom line?  Any suggestions are
 greatly appreciated.
 Andrew

plotmath, as has been covered many times previously, does not support
multi-line expressions. A note should probably be added to ?plotmath on
this.

Thus, you need to create each line in the label separately:

  par(oma=c(0,0,2,0),mar=c(5,6,0.25,2),lheight=1)
  
  plot(1:10, ylab = )

  # Now use mtext() to place each line of the y axis label

  mtext(2, text = expression( ^14*C*-glyphosate line1), line = 3)

  mtext(2, text = line2, line = 2)

See ?mtext for more information.

HTH,

Marc Schwartz

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


Re: [R] expression() - Superscript in y-axis, keeping line break in string

2006-08-04 Thread Gabor Grothendieck
Use atop:

   plot(1, main = expression(atop( ^14*C*-glyphosate line, line2)))

On 8/4/06, Andrew Kniss [EMAIL PROTECTED] wrote:
 I've tried several different ways to accomplish this, but as yet to no
 avail.  My y-axis for a plot has a rather long label, and thus I have
 been using /n to break it into two lines.  However, to make it
 technically correct for publication, I also need to use superscript in
 the label.  For example:

 par(oma=c(0,0,2,0),mar=c(5,6,0.25,2),lheight=1)
 plot(1:10,
  ylab=14C-glyphosate line1\n line2)

 will provide the text in two lines as I would like it.  However, I am
 trying to keep those same line breaks when using expression() to get my
 superscript number.  This will not work, as it aligns the 14C section
 with the bottom line of the expression making little sense to the
 reader.

 par(oma=c(0,0,2,0),mar=c(5,6,0.25,2),lheight=1)
 plot(1:10,
  ylab=expression( ^14*C*-glyphosate line1\n line2))

 Is there a way to align the 14C portion of the expression with the top
 line of the string rather than the bottom line?  Any suggestions are
 greatly appreciated.
 Andrew


 --
 Andrew Kniss
 Assistant Research Scientist
 University of Wyoming
 Department of Plant Sciences

 [EMAIL PROTECTED]
 Office: (307) 766-3949
 Fax:(307) 766-5549

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


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


Re: [R] expression() - Superscript in y-axis, keeping line break in string

2006-08-04 Thread Gabor Grothendieck
Sorry, you wanted a ylab=, not a main=.  Try using xyplot in lattice:

library(lattice)
xyplot(1~1, ylab = expression(atop(phantom(0)^14*C*-glyphosate line,
line2)))


On 8/4/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
 Use atop:

   plot(1, main = expression(atop( ^14*C*-glyphosate line, line2)))

 On 8/4/06, Andrew Kniss [EMAIL PROTECTED] wrote:
  I've tried several different ways to accomplish this, but as yet to no
  avail.  My y-axis for a plot has a rather long label, and thus I have
  been using /n to break it into two lines.  However, to make it
  technically correct for publication, I also need to use superscript in
  the label.  For example:
 
  par(oma=c(0,0,2,0),mar=c(5,6,0.25,2),lheight=1)
  plot(1:10,
   ylab=14C-glyphosate line1\n line2)
 
  will provide the text in two lines as I would like it.  However, I am
  trying to keep those same line breaks when using expression() to get my
  superscript number.  This will not work, as it aligns the 14C section
  with the bottom line of the expression making little sense to the
  reader.
 
  par(oma=c(0,0,2,0),mar=c(5,6,0.25,2),lheight=1)
  plot(1:10,
   ylab=expression( ^14*C*-glyphosate line1\n line2))
 
  Is there a way to align the 14C portion of the expression with the top
  line of the string rather than the bottom line?  Any suggestions are
  greatly appreciated.
  Andrew
 
 
  --
  Andrew Kniss
  Assistant Research Scientist
  University of Wyoming
  Department of Plant Sciences
 
  [EMAIL PROTECTED]
  Office: (307) 766-3949
  Fax:(307) 766-5549
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 


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


Re: [R] meta characters in file path

2006-08-04 Thread Li,Qinghong,ST.LOUIS,Molecular Biology
Thanks. I tried them, it works for most of those characters except * and ?. 

Does regular expression work in file names in windows? e.g. I have a 
machine-generated file named 021706 matrix#1479 @50.csv, of which 1479 is 
kinda random. Will I be able to match 1479 with some sort of wild card 
chars?

Thanks
Johnny

-Original Message-
From: Tony Plate [mailto:[EMAIL PROTECTED]
Sent: Thursday, August 03, 2006 3:42 PM
To: Li,Qinghong,ST.LOUIS,Molecular Biology
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] meta characters in file path


What is the problem you are having?  Seems to work fine for me running 
under Windows2000:

  write.table(data.frame(a=1:3,b=4:6), file=@# x.csv, sep=,)
  read.csv(file=@# x.csv)
   a b
1 1 4
2 2 5
3 3 6
  sessionInfo()
Version 2.3.1 (2006-06-01)
i386-pc-mingw32

attached base packages:
[1] methods   stats graphics  grDevices utils datasets
[7] base

other attached packages:
  XML
0.99-8
 

Li,Qinghong,ST.LOUIS,Molecular Biology wrote:
 Hi,
 
 I need to read in some files. The file names contain come meta characters 
 such as @, #, and white spaces etc, In read.csv, file= option, is there any 
 way that one can make the function to recognize a file path with those 
 characters?
 
 Thanks
 Johnny
 
   [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


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


Re: [R] expression() - Superscript in y-axis, keeping line break in string

2006-08-04 Thread Marc Schwartz (via MN)
Actually Gabor, using your solution with 'atop', which I had not
considered, it will work with base graphics:

 par(oma = c(0, 0, 2, 0), mar = c(5, 6, 0.25, 2), lheight = 1)

 plot(1:10, ylab = expression(atop( ^14*C*-glyphosate line1,
   line2)))

HTH,

Marc

On Fri, 2006-08-04 at 12:09 -0400, Gabor Grothendieck wrote:
 Sorry, you wanted a ylab=, not a main=.  Try using xyplot in lattice:
 
 library(lattice)
 xyplot(1~1, ylab = expression(atop(phantom(0)^14*C*-glyphosate line,
 line2)))
 
 
 On 8/4/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
  Use atop:
 
plot(1, main = expression(atop( ^14*C*-glyphosate line, line2)))
 
  On 8/4/06, Andrew Kniss [EMAIL PROTECTED] wrote:
   I've tried several different ways to accomplish this, but as yet to no
   avail.  My y-axis for a plot has a rather long label, and thus I have
   been using /n to break it into two lines.  However, to make it
   technically correct for publication, I also need to use superscript in
   the label.  For example:
  
   par(oma=c(0,0,2,0),mar=c(5,6,0.25,2),lheight=1)
   plot(1:10,
ylab=14C-glyphosate line1\n line2)
  
   will provide the text in two lines as I would like it.  However, I am
   trying to keep those same line breaks when using expression() to get my
   superscript number.  This will not work, as it aligns the 14C section
   with the bottom line of the expression making little sense to the
   reader.
  
   par(oma=c(0,0,2,0),mar=c(5,6,0.25,2),lheight=1)
   plot(1:10,
ylab=expression( ^14*C*-glyphosate line1\n line2))
  
   Is there a way to align the 14C portion of the expression with the top
   line of the string rather than the bottom line?  Any suggestions are
   greatly appreciated.
   Andrew
  

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


[R] Simulate an Overdispersed(extra-variance poisson process)?

2006-08-04 Thread Spencer Jones
Is there a function in R comparable to rpois that can simulate random
variables from an overdispersed poisson distribution? If there is not a
function any ideas/references on how to program one?

thanks,

Spencer Jones
Graduate Student, NLM Fellow
Dept. Biomedical Informatics
University of Utah

[[alternative HTML version deleted]]

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


Re: [R] Simulate an Overdispersed(extra-variance poisson process)?

2006-08-04 Thread Marc Schwartz (via MN)
On Fri, 2006-08-04 at 10:33 -0600, Spencer Jones wrote:
 Is there a function in R comparable to rpois that can simulate random
 variables from an overdispersed poisson distribution? If there is not a
 function any ideas/references on how to program one?

Take a look at

  ?rnbinom

or

  library(MASS)
  ?rnegbin


HTH,

Marc Schwartz

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


[R] Error when loading odesolve

2006-08-04 Thread Wuming Gong
Dear list,

I installed odesolve package (0.5-15) in R 2.3.1 in a Solaris server
(Generic_118558-11 sun4u sparc SUNW,Sun-Blade-1000).  The installing
progress completed without errors, though several warnings like
Warning: Option -fPIC passed to ld, if ld is invoked, ignored
otherwise were outputed.

However, when loading the odesolve package by library(odesolve),
following error messages pop out:

 library(odesolve)
Error in dyn.load(x, as.logical(local), as.logical(now)) :
unable to load shared library
'/project/scratch/ligroup/R1/lib/R/library/odesolve/libs/odesolve.so':
  ld.so.1: R: fatal: relocation error: file
/project/scratch/ligroup/R1/lib/R/library/odesolve/libs/odesolve.so:
symbol __f90_ssfw: referenced symbol not found
Error: package/namespace load failed for 'odesolve'

Could any one tell me how to fix this problem?

Thanks very much.

Wuming

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


Re: [R] Sampling from a Matrix

2006-08-04 Thread Marc Schwartz (via MN)
On Fri, 2006-08-04 at 12:46 -0400, Daniel Gerlanc wrote:
 Hello all,
 
 Consider the following problem:
 
 There is a matrix of probabilities:
 
  set.seed(1)
  probs - array(abs(rnorm(25, sd = 0.33)), dim = c(5,5), dimnames = 
  list(1:5, letters[1:5]))
  probs
 a  b   c de
 1 0.21 0.27 0.50 0.0148 0.303
 2 0.06 0.16 0.13 0.0053 0.258
 3 0.28 0.24 0.21 0.3115 0.025
 4 0.53 0.19 0.73 0.2710 0.656
 5 0.11 0.10 0.37 0.1960 0.205
 
 I want to sample 3 values from each row.
 
 One way to do this follows:
 
 index - 1:ncol(probs)
 
 for(i in 1:nrow(probs)){
 
 ## gets the indexes of the values chosen
 
 sample(index, size = 3, replace = TRUE, prob = probs[i, ])
 
 }
 
 Is there a another way to do this?
 
 Thanks!

 t(apply(probs, 1, function(x) sample(x, 3)))
   [,1]   [,2]   [,3]
1 0.210 0.5000 0.0148
2 0.258 0.0053 0.1300
3 0.025 0.2800 0.3115
4 0.190 0.5300 0.2710
5 0.196 0.1000 0.1100

See ?apply and ?t

HTH,

Marc Schwartz

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


[R] GAM 2D-plotting

2006-08-04 Thread Nixon Bahamon
Hi,

When I fit a GAM model (using mgvc) with overlapping terms, such as

gam(y~s(x,z)+s(z,w))

and afterwards I pretend to plot the component smooth functions that make it up
using plot.gam, I achieve a couple of 2D plots.

My question is: What's the meaning of those 2D plots in terms of y?

Regards,

Nixon

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


[R] training svm's with probability flag

2006-08-04 Thread Jessie Tenenbaum
Hi-
I'm seeing some weirdness with svm and tune.svm that I can't figure out- was
wondering if anyone else has seen this? Perhaps I'm failing to make
something the expected class?
Below is my repro case, though it *sometimes* doesn't repro. I'm using
R2.3.1 on WindowsXP. I was also seeing it happen with R2.1.1 and have seen
it on 2 different machines.
 
data(iris)
attach(iris)
library(e1071)
train- iris[c(1:30,50:80,100:130),]
test- iris[-c(1:30,50:80,100:130),]
y.train- train$Species
y.test- test$Species
obj- tune.svm(train[,-5], y.train, gamma = 2^(-1:1), cost = 2^(2:4),
probability=T)
my.svm- obj$best.model
pred1- predict(my.svm, test[,-5])
pred2- predict(my.svm, test[,-5], probability=T)
table(pred1, y.test)
table(pred2, y.test)

When I do this, the two different tables often come out different, as below:
 table(pred1, y.test)
y.test
pred1setosa versicolor virginica
  setosa 19  0 0
  versicolor  0 18 1
  virginica   0  119
 table(pred2, y.test)
y.test
pred2setosa versicolor virginica
  setosa 18  0 0
  versicolor  1 18 1
  virginica   0  119
 

I'm not sure 1. why the results would differ based on whether I choose to
calculate the probabilities, and 2. which one to trust??
Anyone come across this before, or have any ideas?
 
thanks,
jessie

[[alternative HTML version deleted]]

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


[R] why does lm() not allow for negative weights?

2006-08-04 Thread Jens Hainmueller
Dear List,

Why do commonly used estimator functions (such as lm(), glm(), etc.) not
allow negative case weights? I suspect that there is a good reason for this.
Yet, I can see reasonable cases when one wants to use negative case weights.

Take lm() for example:

###

n - 20
Y - rnorm(n)
X - cbind(rep(1,n),runif(n),rnorm(n))
Weights - rnorm(n)
# Includes Pos and Neg Weights
Weights

# Now do Weighted LS and get beta coeffs:
b - solve(t(X)%*%diag(Weights)%*%X) %*% t(X) %*% diag(Weights)%*%Y
b

# This seems like a valid model, but when I try
lm(Y ~ X[,2:3],weights=Weights)

# I get: missing or negative weights not allowed

###

What is the rationale for not allowing negative weights? I ask this, because
I am currently trying to implement a (two stage) estimator into R that
involves negative case weights. Weights are generated in the first stage, so
it would be nice if I could use canned functions such as
lm(,weights=Weights) in the second stage.

Thank you for your help.

Best,
Jens

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


Re: [R] meta characters in file path

2006-08-04 Thread Prof Brian Ripley
On Fri, 4 Aug 2006, Li,Qinghong,ST.LOUIS,Molecular Biology wrote:

 Thanks. I tried them, it works for most of those characters except * 
 and ?.

Those are not valid characters in Windows file paths
(/   * :   ? \ | are invalid in file or dir names).

 Does regular expression work in file names in windows? 

No, and I think you may mean wildcards (which is what work on the command 
line).

 e.g. I have a machine-generated file named 021706 matrix#1479 @50.csv, 
 of which 1479 is kinda random. Will I be able to match 1479 with 
 some sort of wild card chars?

Yes, use dir(), with regexp pattern patching to find the name(s) you 
want.  glob2rx() might be useful here.

 Thanks
 Johnny
 
 -Original Message-
 From: Tony Plate [mailto:[EMAIL PROTECTED]
 Sent: Thursday, August 03, 2006 3:42 PM
 To: Li,Qinghong,ST.LOUIS,Molecular Biology
 Cc: r-help@stat.math.ethz.ch
 Subject: Re: [R] meta characters in file path
 
 
 What is the problem you are having?  Seems to work fine for me running 
 under Windows2000:
 
   write.table(data.frame(a=1:3,b=4:6), file=@# x.csv, sep=,)
   read.csv(file=@# x.csv)
a b
 1 1 4
 2 2 5
 3 3 6
   sessionInfo()
 Version 2.3.1 (2006-06-01)
 i386-pc-mingw32
 
 attached base packages:
 [1] methods   stats graphics  grDevices utils datasets
 [7] base
 
 other attached packages:
   XML
 0.99-8
  
 
 Li,Qinghong,ST.LOUIS,Molecular Biology wrote:
  Hi,
  
  I need to read in some files. The file names contain come meta characters 
  such as @, #, and white spaces etc, In read.csv, file= option, is there any 
  way that one can make the function to recognize a file path with those 
  characters?
  
  Thanks
  Johnny
  
  [[alternative HTML version deleted]]
  
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

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

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


Re: [R] Error when loading odesolve

2006-08-04 Thread Prof Brian Ripley
Looking at odesolve, src/Makevars is

PKG_LIBS=$(BLAS_LIBS)

Now, the documentation says that if you have $(BLAS_LIBS) you must also 
have $(FLIBS), so please change this to

PKG_LIBS=$(BLAS_LIBS) $(FLIBS)

and take this up with the package maintainer (which is what the posting 
guide asked you to do in the first place).


On Sat, 5 Aug 2006, Wuming Gong wrote:

 Dear list,
 
 I installed odesolve package (0.5-15) in R 2.3.1 in a Solaris server
 (Generic_118558-11 sun4u sparc SUNW,Sun-Blade-1000).  The installing
 progress completed without errors, though several warnings like
 Warning: Option -fPIC passed to ld, if ld is invoked, ignored
 otherwise were outputed.
 
 However, when loading the odesolve package by library(odesolve),
 following error messages pop out:
 
  library(odesolve)
 Error in dyn.load(x, as.logical(local), as.logical(now)) :
 unable to load shared library
 '/project/scratch/ligroup/R1/lib/R/library/odesolve/libs/odesolve.so':
   ld.so.1: R: fatal: relocation error: file
 /project/scratch/ligroup/R1/lib/R/library/odesolve/libs/odesolve.so:
 symbol __f90_ssfw: referenced symbol not found
 Error: package/namespace load failed for 'odesolve'
 
 Could any one tell me how to fix this problem?
 
 Thanks very much.
 
 Wuming
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

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

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


Re: [R] why does lm() not allow for negative weights?

2006-08-04 Thread Duncan Murdoch
On 8/4/2006 1:26 PM, Jens Hainmueller wrote:
 Dear List,
 
 Why do commonly used estimator functions (such as lm(), glm(), etc.) not
 allow negative case weights? 

Residual sums of squares (or deviances) could be negative with negative 
case weights.  This doesn't seem like a good thing:  would you really 
want the fit to be far from those points?

  I suspect that there is a good reason for this.
 Yet, I can see reasonable cases when one wants to use negative case weights.
 
 Take lm() for example:
 
 ###
 
 n - 20
 Y - rnorm(n)
 X - cbind(rep(1,n),runif(n),rnorm(n))
 Weights - rnorm(n)
 # Includes Pos and Neg Weights
 Weights
 
 # Now do Weighted LS and get beta coeffs:
 b - solve(t(X)%*%diag(Weights)%*%X) %*% t(X) %*% diag(Weights)%*%Y

That formula does not necessarily give least squares estimates in the 
case where weights might be negative.  For example, with a single 
observation y, a single parameter mu, design matrix X = 1, and weight 
-1, that formula becomes

b - y,

but that is the worst possible estimator in a least squares sense.  The 
residual sum of squares can be made arbitrarily large and negative by 
setting b to a large value.

Duncan Murdoch


 b
 
 # This seems like a valid model, but when I try
 lm(Y ~ X[,2:3],weights=Weights)
 
 # I get: missing or negative weights not allowed
 
 ###
 
 What is the rationale for not allowing negative weights? I ask this, because
 I am currently trying to implement a (two stage) estimator into R that
 involves negative case weights. Weights are generated in the first stage, so
 it would be nice if I could use canned functions such as
 lm(,weights=Weights) in the second stage.
 
 Thank you for your help.
 
 Best,
 Jens
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] why does lm() not allow for negative weights?

2006-08-04 Thread Jens Hainmueller
Thanks Duncan Murdoch,

  Why do commonly used estimator functions (such as lm(), 
  glm(), etc.) 
  not allow negative case weights?
 
 Residual sums of squares (or deviances) could be negative 
 with negative case weights.  This doesn't seem like a good 
 thing:  would you really want the fit to be far from those points?

Yes, this is actually what I want for this particular estimator. But I can
see now why this generally doesn't seem like a a good idea.

Best,
Jens



 -Ursprüngliche Nachricht-
 Von: Duncan Murdoch [mailto:[EMAIL PROTECTED] 
 Gesendet: Friday, August 04, 2006 7:36 PM
 An: Jens Hainmueller
 Cc: r-help@stat.math.ethz.ch
 Betreff: Re: [R] why does lm() not allow for negative weights?
 
 On 8/4/2006 1:26 PM, Jens Hainmueller wrote:
  Dear List,
  

 

 
   I suspect that there is a good reason for this.
  Yet, I can see reasonable cases when one wants to use 
 negative case weights.
  
  Take lm() for example:
  
  ###
  
  n - 20
  Y - rnorm(n)
  X - cbind(rep(1,n),runif(n),rnorm(n)) Weights - rnorm(n) 
 # Includes 
  Pos and Neg Weights Weights
  
  # Now do Weighted LS and get beta coeffs:
  b - solve(t(X)%*%diag(Weights)%*%X) %*% t(X) %*% diag(Weights)%*%Y
 
 That formula does not necessarily give least squares 
 estimates in the case where weights might be negative.  For 
 example, with a single observation y, a single parameter mu, 
 design matrix X = 1, and weight -1, that formula becomes
 
 b - y,
 
 but that is the worst possible estimator in a least squares 
 sense.  The residual sum of squares can be made arbitrarily 
 large and negative by setting b to a large value.
 
 Duncan Murdoch
 
 
  b
  
  # This seems like a valid model, but when I try lm(Y ~ 
  X[,2:3],weights=Weights)
  
  # I get: missing or negative weights not allowed
  
  ###
  
  What is the rationale for not allowing negative weights? I 
 ask this, 
  because I am currently trying to implement a (two stage) estimator 
  into R that involves negative case weights. Weights are 
 generated in 
  the first stage, so it would be nice if I could use canned 
 functions 
  such as
  lm(,weights=Weights) in the second stage.
  
  Thank you for your help.
  
  Best,
  Jens
  
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide 
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.


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


Re: [R] why does lm() not allow for negative weights?

2006-08-04 Thread Dirk Eddelbuettel

On 4 August 2006 at 19:26, Jens Hainmueller wrote:
| Why do commonly used estimator functions (such as lm(), glm(), etc.) not
| allow negative case weights? I suspect that there is a good reason for this.

That came up on r-sig-finance a little while ago. As usual, Gabor won the
contest for most precise and concise answer with:

   [..] At any rate, note that if the weights can be negative then the sum of
   squares to be optimized is no longer a convex function of the coefficients
   so we really don't have a conventional least squares model and uniqueness
   and existence have possibly different answers.

See the r-sig-finance archives for April 2006 and a thread entitled 'negative
weights'. 

Hth, Dirk

-- 
Hell, there are no rules here - we're trying to accomplish something. 
  -- Thomas A. Edison

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


Re: [R] prettyR arrives

2006-08-04 Thread Rick Bilonick
On Fri, 2006-08-04 at 19:37 -0400, Jim Lemon wrote:
 Hi all,
 
 I have finally gotten the prettyR package going (many thanks to Kurt 
 Hornik for his patience).
 
 prettyR is a set of functions that allows the user to produce HTML 
 output from R scripts. Given an R script that runs properly, an HTML 
 listing complete with embedded graphics can be produced simply by 
 passing the script to the core function htmlize (Phillipe Grosjean has 
 not only offered great suggestions, but provided a fancier function 
 named R2html). It is even possible to have the output magically appear 
 in your friendly local HTML browser when the script has been processed.
 
 The package includes some basic descriptive functions that display the 
 usual suspects in formats that should not agitate those accustomed to 
 the vanilla listings that abound in the real world.
 
 prettyR is intended to assist the R beginner in producing basic stats 
 right from the word go. No knowledge beyond that of writing an R 
 script is required, but there is quite a bit of room to learn and 
 innovate. Have fun and please let me know if you break it.
 
 Jim
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

Thanks but I could not get R2html in prettyR to work:

 R2html(Rfile=/ophth/cornea/R/lme_4.R,
+   HTMLfile=/ophth/cornea/Reports/lme_4.html)
Error in CreateIndexFile(HTMLfile, basenavfile, baselistfile, title) :
unused argument(s) ( ...)

lme_3.r has the R script and lme_3.html is the html file I'd like to
create. The help file for R2html does not give an example.

 args(R2html)
function (Rfile, HTMLfile, echo = TRUE, split = FALSE, browse = TRUE,
title = R listing, bgcolor = #dd, ...)

What am I doing wrong? I can source the script file.

 args(CreateIndexFile)
function (HTMLbase, HTMLdir, title = R listing)

Is there a problem in R2html's call to CreateIndexFile? The arguments
don't seem to match.

Rick B.

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


Re: [R] ggplot facet label font size

2006-08-04 Thread Gabor Grothendieck
With ggplot its possible to do this too but in that case it seems
necessary to recurse through the grobs.  Here we look for
grobs that have a label component which contains a colon
and grid.edit those changing the value of cex.  Note that
getNames() give a single grob named pretty and we start
from that:

# run code
library(ggplot)
library(grid)

p - ggplot(tips, sex ~ smoker, aesthetics=list(x=tip/total_bill))
gghistogram(p)

recurse - function(x) {
   if (!is.null(x$label)  regexpr(:, x$label)  0)
  grid.edit(x$name, gp = gpar(cex = 0.7))
   for (ch in x$children) recurse(ch)
}
recurse(grid.get(pretty))


On 8/3/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
 If you are willing to use grid then you could create only the sex
 factor in the left strips since its already in the desired position
 but when displaying it output a factor.level, i.e. label of A.
 (my.strip.left is modified from the prior post to do that.)

 Then after the plot is drawn, looping through all grobs looking for
 those with a label component of A producing a list of grob names,
 strip.left.names.  We then mapply the real factor levels with
 those grobs editing them in reset.levels(), defined below.
 (I have used the fact, empirically determined that the stripts
 are produced in order of the factor levels.)

 Everything is the same as the last post except my.strip.left
 which has been modified and everything which comes after the
 call to histogram.

 Although this seems to work, maybe Deepayan or Paul can think of
 something slicker.


 library(ggplot) # data resides here
 library(lattice)
 library(grid)

 my.strip - function(which.given, which.panel, ...)
   if (which.given == 1  which.panel[2] == 2)
  strip.default(which.given, which.panel, ...)

 my.strip.left - function(which.given, which.panel, ...,
   factor.levels, horizontal)
   if (which.given == 1  which.panel[1] == 1)
  strip.default(which.given, which.panel, factor.levels = LETTERS,
  horizontal = FALSE, ...)


 histogram(~ tip/total_bill | sex + smoker, tips, strip = my.strip,
 strip.left = my.strip.left, par.settings = list(add.text =
 list(cex = 0.7)))

 is.strip.left - function(name) identical(grid.get(name)$label, A)
 strip.left.names - getNames()[sapply(getNames(), is.strip.left)]

 reset.levels - function(nam, lev) grid.edit(nam, label = lev)
 mapply(reset.levels , strip.left.names, levels(tips$smoker))






 On 8/3/06, Walker, Sam [EMAIL PROTECTED] wrote:
 
  This works OK, but there is some extra spacing between the panels, the
  top axis and the strip on the top, and the left labels and panel.
 
  How can I remove these extra spaces?
 
  I've tried changing various layout.widths settings with no luck.  It
  seems the spaces are calculated based on the number of conditioning
  variables, in this case 2 (sex+smoker).
 
 
  Thanks in advance...
  -Sam
 
 
  -Original Message-
  From: Gabor Grothendieck [mailto:[EMAIL PROTECTED]
  Sent: Wednesday, August 02, 2006 6:04 PM
  To: Walker, Sam
  Cc: r-help@stat.math.ethz.ch
  Subject: Re: [R] ggplot facet label font size
 
  On 8/2/06, Walker, Sam [EMAIL PROTECTED] wrote:
   How do I change the font size in the facet labels along the edges of
  the
   plot?
  
   For example (from the ggplot help file):
   p-ggplot(tips, sex ~ smoker, aesthetics=list(x=tip/total_bill))
   gghistogram(p)
  
   In this plot, the facet labels are smoker: No, smoker: Yes, sex:
   Female, sex: Male.  What command can I use to reduce the font size
  of
   these labels?
  
   In lattice terminology, cex is used to scale these strip labels.  But
  I
   couldn't find the equivalent in ggplot.
  
   The reason I'm asking is I have a 9x7 array of plots which I've been
   plotting with lattice.  I wanted to use ggplot because I like having
  the
   labels on the edge of the plots
 
  Note that lattice can do that by using custom strip functions:
 
  library(ggplot) # data resides here
  library(lattice)
 
  my.strip - function(which.given, which.panel, ...)
if (which.given == 1  which.panel[2] == 2)
   strip.default(which.given, which.panel, ...)
 
  my.strip.left - function(which.given, which.panel, ..., horizontal)
if (which.given == 2  which.panel[1] == 1)
   strip.default(which.given, which.panel, horizontal = FALSE, ...)
 
  histogram(~ tip/total_bill | sex + smoker, tips, strip = my.strip,
  strip.left = my.strip.left, par.settings = list(add.text =
  list(cex = 0.7)))
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 


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

Re: [R] expression() - Superscript in y-axis, keeping line break in string

2006-08-04 Thread Prof Brian Ripley
On Fri, 4 Aug 2006, Marc Schwartz (via MN) wrote:

 On Fri, 2006-08-04 at 09:47 -0600, Andrew Kniss wrote:
  I've tried several different ways to accomplish this, but as yet to no
  avail.  My y-axis for a plot has a rather long label, and thus I have
  been using /n to break it into two lines.  However, to make it
  technically correct for publication, I also need to use superscript in
  the label.  For example:
  
   par(oma=c(0,0,2,0),mar=c(5,6,0.25,2),lheight=1)
   plot(1:10,
ylab=14C-glyphosate line1\n line2)
  
  will provide the text in two lines as I would like it.  However, I am
  trying to keep those same line breaks when using expression() to get my
  superscript number.  This will not work, as it aligns the 14C section
  with the bottom line of the expression making little sense to the
  reader.
  
   par(oma=c(0,0,2,0),mar=c(5,6,0.25,2),lheight=1)
   plot(1:10,
ylab=expression( ^14*C*-glyphosate line1\n line2))
  
  Is there a way to align the 14C portion of the expression with the top
  line of the string rather than the bottom line?  Any suggestions are
  greatly appreciated.
  Andrew
 
 plotmath, as has been covered many times previously, does not support
 multi-line expressions. A note should probably be added to ?plotmath on
 this.

I've added a note.  I think what is exact is that control chars are not 
interpreted ('expresssion' is an overloaded work in this context).

Thanks for the nudge (and please do continue to make such remarks).

Brian

 
 Thus, you need to create each line in the label separately:
 
   par(oma=c(0,0,2,0),mar=c(5,6,0.25,2),lheight=1)
   
   plot(1:10, ylab = )
 
   # Now use mtext() to place each line of the y axis label
 
   mtext(2, text = expression( ^14*C*-glyphosate line1), line = 3)
 
   mtext(2, text = line2, line = 2)
 
 See ?mtext for more information.
 
 HTH,
 
 Marc Schwartz
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

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

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


Re: [R] Questions about sweave... question answered and problem solved

2006-08-04 Thread Brian Lunergan
* Dieter Menne wrote, On 2006-08-04 02:57:
 Brian Lunergan ff809 at ncf.ca writes:
 
 Evening all:

 I'm taking a little time to experiment with R, Sweave, and Miktex/LaTex but 
 I've run up against some problems and -well- I hope that there are some on 
 the list who might have some suggestions. This will be kind of wordy as I 
 will include the complete files involved as I'm just not sure what I'm 
 looking for. Apologies at the outset.
 
 This is Windows special
 
 See A.12: 
 http://www.ci.tuwien.ac.at/~leisch/Sweave/FAQ.html
 
 And put a commented (!sic) \usepackage into the header (don't remember where I
 found this)
 
 % \usepackage{Sweave} 
 
 
 Dieter

Thanks for the lead. Reinstalled R outside of 'c:\program files'. Reran the 
source through Sweave to generate a new example.tex with the preamble:

\documentclass[letterpaper]{article}
\title{Sweave Example 1}
\author{Friedrich Leisch}
\usepackage{C:/R-2.3.1/share/texmf/Sweave}
\begin{document}

Ran it through Latex and everything is as it should be. Problem solved.

-- 
Brian Lunergan
Nepean, Ontario
Canada


---
avast! Antivirus: Outbound message clean.
Virus Database (VPS): 0631-3, 2006-08-04
Tested on: 2006-08-04 14:52:19
avast! is copyright (c) 2000-2006 ALWIL Software.
http://www.avast.com

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


Re: [R] expression() - Superscript in y-axis, keeping line break in string

2006-08-04 Thread Marc Schwartz (via MN)
On Fri, 2006-08-04 at 19:44 +0100, Prof Brian Ripley wrote:
 On Fri, 4 Aug 2006, Marc Schwartz (via MN) wrote:
 
  On Fri, 2006-08-04 at 09:47 -0600, Andrew Kniss wrote:
   I've tried several different ways to accomplish this, but as yet to no
   avail.  My y-axis for a plot has a rather long label, and thus I have
   been using /n to break it into two lines.  However, to make it
   technically correct for publication, I also need to use superscript in
   the label.  For example:
   
par(oma=c(0,0,2,0),mar=c(5,6,0.25,2),lheight=1)
plot(1:10,
 ylab=14C-glyphosate line1\n line2)
   
   will provide the text in two lines as I would like it.  However, I am
   trying to keep those same line breaks when using expression() to get my
   superscript number.  This will not work, as it aligns the 14C section
   with the bottom line of the expression making little sense to the
   reader.
   
par(oma=c(0,0,2,0),mar=c(5,6,0.25,2),lheight=1)
plot(1:10,
 ylab=expression( ^14*C*-glyphosate line1\n line2))
   
   Is there a way to align the 14C portion of the expression with the top
   line of the string rather than the bottom line?  Any suggestions are
   greatly appreciated.
   Andrew
  
  plotmath, as has been covered many times previously, does not support
  multi-line expressions. A note should probably be added to ?plotmath on
  this.
 
 I've added a note.  I think what is exact is that control chars are not 
 interpreted ('expresssion' is an overloaded work in this context).
 
 Thanks for the nudge (and please do continue to make such remarks).
 
 Brian

snip

Happy to help and thanks for both noticing and taking the time to
incorporate the update.

Best regards,

Marc

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


[R] training svm's with probability flag (re-send in plain text)

2006-08-04 Thread Jessie Tenenbaum
Hi-

I'm seeing some weirdness with svm and tune.svm that I can't figure out- was
wondering if anyone else has seen this? Perhaps I'm failing to make
something the expected class?
Below is my repro case, though it *sometimes* doesn't repro. I'm using
R2.3.1 on WindowsXP. I was also seeing it happen with R2.1.1 and have seen
it on 2 different machines.
 
data(iris)
attach(iris)
library(e1071)
train- iris[c(1:30,50:80,100:130),]
test- iris[-c(1:30,50:80,100:130),]
y.train- train$Species
y.test- test$Species
obj- tune.svm(train[,-5], y.train, gamma = 2^(-1:1), cost = 2^(2:4),
probability=T)
my.svm- obj$best.model
pred1- predict(my.svm, test[,-5])
pred2- predict(my.svm, test[,-5], probability=T)
table(pred1, y.test)
table(pred2, y.test)

When I do this, the two different tables often come out different, as below:
 table(pred1, y.test)
y.test
pred1setosa versicolor virginica
  setosa 19  0 0
  versicolor  0 18 1
  virginica   0  119
 table(pred2, y.test)
y.test
pred2setosa versicolor virginica
  setosa 18  0 0
  versicolor  1 18 1
  virginica   0  119
 

I'm not sure 1. why the results would differ based on whether I choose to
calculate the probabilities, and 2. which one to trust??
Anyone come across this before, or have any ideas?
 
thanks,
jessie

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


[R] Doubt about Student t distribution simulation

2006-08-04 Thread Jose Claudio Faria
Dear R list,

I would like to illustrate the origin of the Student t distribution using R.

So, if (sample.mean - pop.mean) / standard.error(sample.mean) has t 
distribution with (sample.size - 1) degree free, what is wrong with the 
simulation below? I think that the theoretical curve should agree with 
the relative frequencies of the t values calculated:

#== begin options=
# parameters
   mu= 10
   sigma =  5

# size of sample
   n = 3

# repetitions
   nsim = 1

# histogram parameter
   nchist = 150
#== end options===

t   = numeric()
pop = rnorm(1, mean = mu, sd = sigma)

for (i in 1:nsim) {
   amo.i = sample(pop, n, replace = TRUE)
   t[i]  = (mean(amo.i) - mu) / (sigma / sqrt(n))
}

win.graph(w = 5, h = 7)
split.screen(c(2,1))
screen(1)
hist(t,
  main = histogram,
  breaks   = nchist,
  col  = lightgray,
  xlab = '', ylab = Fi,
  font.lab = 2, font = 2)

screen(2)
hist(t,
  probability = T,
  main= 'f.d.p and histogram',
  breaks  = nchist,
  col = 'lightgray',
  xlab= 't', ylab = 'f(t)',
  font.lab= 2, font = 2)

x = t
curve(dt(x, df = n-1), add = T, col = red, lwd = 2)

Many thanks for any help,
___
Jose Claudio Faria
Brasil/Bahia/Ilheus/UESC/DCET
Estatística Experimental/Prof. Adjunto
mails: [EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]

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


Re: [R] meta characters in file path

2006-08-04 Thread Li,Qinghong,ST.LOUIS,Molecular Biology
thanks Prof Ripley. dir() returns the path with full names (wildcards replaced) 
that are exactly what I need.



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Prof Brian Ripley
Sent: Friday, August 04, 2006 12:27 PM
To: Li,Qinghong,ST.LOUIS,Molecular Biology
Cc: r-help@stat.math.ethz.ch; Tony Plate
Subject: Re: [R] meta characters in file path


On Fri, 4 Aug 2006, Li,Qinghong,ST.LOUIS,Molecular Biology wrote:

 Thanks. I tried them, it works for most of those characters except * 
 and ?.

Those are not valid characters in Windows file paths
(/   * :   ? \ | are invalid in file or dir names).

 Does regular expression work in file names in windows? 

No, and I think you may mean wildcards (which is what work on the command 
line).

 e.g. I have a machine-generated file named 021706 matrix#1479 @50.csv, 
 of which 1479 is kinda random. Will I be able to match 1479 with 
 some sort of wild card chars?

Yes, use dir(), with regexp pattern patching to find the name(s) you 
want.  glob2rx() might be useful here.

 Thanks
 Johnny
 
 -Original Message-
 From: Tony Plate [mailto:[EMAIL PROTECTED]
 Sent: Thursday, August 03, 2006 3:42 PM
 To: Li,Qinghong,ST.LOUIS,Molecular Biology
 Cc: r-help@stat.math.ethz.ch
 Subject: Re: [R] meta characters in file path
 
 
 What is the problem you are having?  Seems to work fine for me running 
 under Windows2000:
 
   write.table(data.frame(a=1:3,b=4:6), file=@# x.csv, sep=,)
   read.csv(file=@# x.csv)
a b
 1 1 4
 2 2 5
 3 3 6
   sessionInfo()
 Version 2.3.1 (2006-06-01)
 i386-pc-mingw32
 
 attached base packages:
 [1] methods   stats graphics  grDevices utils datasets
 [7] base
 
 other attached packages:
   XML
 0.99-8
  
 
 Li,Qinghong,ST.LOUIS,Molecular Biology wrote:
  Hi,
  
  I need to read in some files. The file names contain come meta characters 
  such as @, #, and white spaces etc, In read.csv, file= option, is there any 
  way that one can make the function to recognize a file path with those 
  characters?
  
  Thanks
  Johnny
  
  [[alternative HTML version deleted]]
  
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

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

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

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


Re: [R] Doubt about Student t distribution simulation

2006-08-04 Thread John Fox
Dear Jose,

The problem is that you're using the population standard deviation (sigma)
rather than the sample SD of each sample [i.e., t[i]  = (mean(amo.i) - mu) /
(sd(amo.i) / sqrt(n)) ], so your values should be normally distributed, as
they appear to be.

A couple of smaller points: (1) Even after this correction, you're sampling
from a discrete population (albeit with replacement) and so the values won't
be exactly t-distributed. You could draw the samples directly from N(mu,
sigma) instead. (2) It would be preferable to make a quantile-comparison
plot against the t-distribution, since you'd get a better picture of what's
going on in the tails.

I hope this helps,
 John 


John Fox
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox 
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Jose 
 Claudio Faria
 Sent: Friday, August 04, 2006 3:09 PM
 To: R-help@stat.math.ethz.ch
 Subject: [R] Doubt about Student t distribution simulation
 
 Dear R list,
 
 I would like to illustrate the origin of the Student t 
 distribution using R.
 
 So, if (sample.mean - pop.mean) / standard.error(sample.mean) 
 has t distribution with (sample.size - 1) degree free, what 
 is wrong with the simulation below? I think that the 
 theoretical curve should agree with the relative frequencies 
 of the t values calculated:
 
 #== begin options=
 # parameters
mu= 10
sigma =  5
 
 # size of sample
n = 3
 
 # repetitions
nsim = 1
 
 # histogram parameter
nchist = 150
 #== end options===
 
 t   = numeric()
 pop = rnorm(1, mean = mu, sd = sigma)
 
 for (i in 1:nsim) {
amo.i = sample(pop, n, replace = TRUE)
t[i]  = (mean(amo.i) - mu) / (sigma / sqrt(n)) }
 
 win.graph(w = 5, h = 7)
 split.screen(c(2,1))
 screen(1)
 hist(t,
   main = histogram,
   breaks   = nchist,
   col  = lightgray,
   xlab = '', ylab = Fi,
   font.lab = 2, font = 2)
 
 screen(2)
 hist(t,
   probability = T,
   main= 'f.d.p and histogram',
   breaks  = nchist,
   col = 'lightgray',
   xlab= 't', ylab = 'f(t)',
   font.lab= 2, font = 2)
 
 x = t
 curve(dt(x, df = n-1), add = T, col = red, lwd = 2)
 
 Many thanks for any help,
 ___
 Jose Claudio Faria
 Brasil/Bahia/Ilheus/UESC/DCET
 Estatística Experimental/Prof. Adjunto
 mails: [EMAIL PROTECTED]
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Doubt about Student t distribution simulation

2006-08-04 Thread Peter Dalgaard
Jose Claudio Faria [EMAIL PROTECTED] writes:

 Dear R list,
 
 I would like to illustrate the origin of the Student t distribution using R.
 
 So, if (sample.mean - pop.mean) / standard.error(sample.mean) has t 
 distribution with (sample.size - 1) degree free, what is wrong with the 
 simulation below? I think that the theoretical curve should agree with 
 the relative frequencies of the t values calculated:
 
 #== begin options=
 # parameters
mu= 10
sigma =  5
 
 # size of sample
n = 3
 
 # repetitions
nsim = 1
 
 # histogram parameter
nchist = 150
 #== end options===
 
 t   = numeric()
 pop = rnorm(1, mean = mu, sd = sigma)
 
 for (i in 1:nsim) {
amo.i = sample(pop, n, replace = TRUE)
t[i]  = (mean(amo.i) - mu) / (sigma / sqrt(n))

At the very least, you need a sample-based standard error: sd(amo.i),
not sigma. Also, resampling from pop is not really what the
t-distribution is based on, but I don't think that matters much.


 }
 
 win.graph(w = 5, h = 7)
 split.screen(c(2,1))
 screen(1)
 hist(t,
   main = histogram,
   breaks   = nchist,
   col  = lightgray,
   xlab = '', ylab = Fi,
   font.lab = 2, font = 2)
 
 screen(2)
 hist(t,
   probability = T,
   main= 'f.d.p and histogram',
   breaks  = nchist,
   col = 'lightgray',
   xlab= 't', ylab = 'f(t)',
   font.lab= 2, font = 2)
 
 x = t
 curve(dt(x, df = n-1), add = T, col = red, lwd = 2)
 
 Many thanks for any help,
 ___
 Jose Claudio Faria
 Brasil/Bahia/Ilheus/UESC/DCET
 Estatística Experimental/Prof. Adjunto
 mails: [EMAIL PROTECTED]
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

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


Re: [R] Error when loading odesolve

2006-08-04 Thread Setzer . Woodrow
Prof. Ripley:
Thanks for diagnosing Wuming Gong's problem.
 I'm not sure I would have recognized the solution so quickly.  I have
uploaded to CRAN a new version of odesolve with Makevars fixed.

R. Woodrow Setzer, Ph. D.
National Center for Computational Toxicology
US Environmental Protection Agency
Mail Drop B205-01/US EPA/RTP, NC 27711
Ph: (919) 541-0128Fax: (919) 541-1194



 Prof Brian 
 Ripley 
 [EMAIL PROTECTED]To 
 .ac.uk  Wuming Gong   
 Sent by: [EMAIL PROTECTED]   
 [EMAIL PROTECTED]cc 
 tat.math.ethz.ch r-help@stat.math.ethz.ch  
Subject 
  Re: [R] Error when loading
 08/04/2006 01:33 odesolve  
 PM 









Looking at odesolve, src/Makevars is

PKG_LIBS=$(BLAS_LIBS)

Now, the documentation says that if you have $(BLAS_LIBS) you must also
have $(FLIBS), so please change this to

PKG_LIBS=$(BLAS_LIBS) $(FLIBS)

and take this up with the package maintainer (which is what the posting
guide asked you to do in the first place).


On Sat, 5 Aug 2006, Wuming Gong wrote:

 Dear list,

 I installed odesolve package (0.5-15) in R 2.3.1 in a Solaris server
 (Generic_118558-11 sun4u sparc SUNW,Sun-Blade-1000).  The installing
 progress completed without errors, though several warnings like
 Warning: Option -fPIC passed to ld, if ld is invoked, ignored
 otherwise were outputed.

 However, when loading the odesolve package by library(odesolve),
 following error messages pop out:

  library(odesolve)
 Error in dyn.load(x, as.logical(local), as.logical(now)) :
 unable to load shared library
 '/project/scratch/ligroup/R1/lib/R/library/odesolve/libs/odesolve.so':
   ld.so.1: R: fatal: relocation error: file
 /project/scratch/ligroup/R1/lib/R/library/odesolve/libs/odesolve.so:
 symbol __f90_ssfw: referenced symbol not found
 Error: package/namespace load failed for 'odesolve'

 Could any one tell me how to fix this problem?

 Thanks very much.

 Wuming

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


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

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

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


Re: [R] Doubt about Student t distribution simulation

2006-08-04 Thread Sundar Dorai-Raj
Hi, Jose/John,

Here's an example to help Jose and highlights John's advice. Also 
includes set.seed which should be included in all simulations posted to 
R-help.

set.seed(42)
mu - 10
sigma -  5
n - 3
nsim - 1
m - matrix(rnorm(n * nsim, mu, sigma), nsim, n)
t - apply(m, 1, function(x) (mean(x) - mu)/(sd(x)/sqrt(n)))

library(lattice)
qqmath(t, distribution = function(x) qt(x, n - 1),
panel = function(x, ...) {
  panel.qqmath(x, col = darkblue, ...)
  panel.qqmathline(x, col = darkred, ...)
})


With n = 3, expect a few outliers.

--sundar


John Fox wrote:
 Dear Jose,
 
 The problem is that you're using the population standard deviation (sigma)
 rather than the sample SD of each sample [i.e., t[i]  = (mean(amo.i) - mu) /
 (sd(amo.i) / sqrt(n)) ], so your values should be normally distributed, as
 they appear to be.
 
 A couple of smaller points: (1) Even after this correction, you're sampling
 from a discrete population (albeit with replacement) and so the values won't
 be exactly t-distributed. You could draw the samples directly from N(mu,
 sigma) instead. (2) It would be preferable to make a quantile-comparison
 plot against the t-distribution, since you'd get a better picture of what's
 going on in the tails.
 
 I hope this helps,
  John 
 
 
 John Fox
 Department of Sociology
 McMaster University
 Hamilton, Ontario
 Canada L8S 4M4
 905-525-9140x23604
 http://socserv.mcmaster.ca/jfox 
  
 
 
-Original Message-
From: [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] On Behalf Of Jose 
Claudio Faria
Sent: Friday, August 04, 2006 3:09 PM
To: R-help@stat.math.ethz.ch
Subject: [R] Doubt about Student t distribution simulation

Dear R list,

I would like to illustrate the origin of the Student t 
distribution using R.

So, if (sample.mean - pop.mean) / standard.error(sample.mean) 
has t distribution with (sample.size - 1) degree free, what 
is wrong with the simulation below? I think that the 
theoretical curve should agree with the relative frequencies 
of the t values calculated:

#== begin options=
# parameters
   mu= 10
   sigma =  5

# size of sample
   n = 3

# repetitions
   nsim = 1

# histogram parameter
   nchist = 150
#== end options===

t   = numeric()
pop = rnorm(1, mean = mu, sd = sigma)

for (i in 1:nsim) {
   amo.i = sample(pop, n, replace = TRUE)
   t[i]  = (mean(amo.i) - mu) / (sigma / sqrt(n)) }

win.graph(w = 5, h = 7)
split.screen(c(2,1))
screen(1)
hist(t,
  main = histogram,
  breaks   = nchist,
  col  = lightgray,
  xlab = '', ylab = Fi,
  font.lab = 2, font = 2)

screen(2)
hist(t,
  probability = T,
  main= 'f.d.p and histogram',
  breaks  = nchist,
  col = 'lightgray',
  xlab= 't', ylab = 'f(t)',
  font.lab= 2, font = 2)

x = t
curve(dt(x, df = n-1), add = T, col = red, lwd = 2)

Many thanks for any help,
___
Jose Claudio Faria
Brasil/Bahia/Ilheus/UESC/DCET
Estatística Experimental/Prof. Adjunto
mails: [EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]

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

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


Re: [R] Doubt about Student t distribution simulation

2006-08-04 Thread Jose Claudio Faria
Dears John, Peter and Sundar,

Many thanks for the quick answers!!!

.. and sorry for all..

[]s
___
Jose Claudio Faria
Brasil/Bahia/Ilheus/UESC/DCET
Estatística Experimental/Prof. Adjunto
mails: [EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]

John Fox escreveu:
 Dear Jose,
 
 The problem is that you're using the population standard deviation (sigma)
 rather than the sample SD of each sample [i.e., t[i]  = (mean(amo.i) - mu) /
 (sd(amo.i) / sqrt(n)) ], so your values should be normally distributed, as
 they appear to be.
 
 A couple of smaller points: (1) Even after this correction, you're sampling
 from a discrete population (albeit with replacement) and so the values won't
 be exactly t-distributed. You could draw the samples directly from N(mu,
 sigma) instead. (2) It would be preferable to make a quantile-comparison
 plot against the t-distribution, since you'd get a better picture of what's
 going on in the tails.
 
 I hope this helps,
  John 
 
 
 John Fox
 Department of Sociology
 McMaster University
 Hamilton, Ontario
 Canada L8S 4M4
 905-525-9140x23604
 http://socserv.mcmaster.ca/jfox 
  
 
 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Jose 
 Claudio Faria
 Sent: Friday, August 04, 2006 3:09 PM
 To: R-help@stat.math.ethz.ch
 Subject: [R] Doubt about Student t distribution simulation

 Dear R list,

 I would like to illustrate the origin of the Student t 
 distribution using R.

 So, if (sample.mean - pop.mean) / standard.error(sample.mean) 
 has t distribution with (sample.size - 1) degree free, what 
 is wrong with the simulation below? I think that the 
 theoretical curve should agree with the relative frequencies 
 of the t values calculated:

 #== begin options=
 # parameters
mu= 10
sigma =  5

 # size of sample
n = 3

 # repetitions
nsim = 1

 # histogram parameter
nchist = 150
 #== end options===

 t   = numeric()
 pop = rnorm(1, mean = mu, sd = sigma)

 for (i in 1:nsim) {
amo.i = sample(pop, n, replace = TRUE)
t[i]  = (mean(amo.i) - mu) / (sigma / sqrt(n)) }

 win.graph(w = 5, h = 7)
 split.screen(c(2,1))
 screen(1)
 hist(t,
   main = histogram,
   breaks   = nchist,
   col  = lightgray,
   xlab = '', ylab = Fi,
   font.lab = 2, font = 2)

 screen(2)
 hist(t,
   probability = T,
   main= 'f.d.p and histogram',
   breaks  = nchist,
   col = 'lightgray',
   xlab= 't', ylab = 'f(t)',
   font.lab= 2, font = 2)

 x = t
 curve(dt(x, df = n-1), add = T, col = red, lwd = 2)

 Many thanks for any help,
 ___
 Jose Claudio Faria
 Brasil/Bahia/Ilheus/UESC/DCET
 Estatística Experimental/Prof. Adjunto
 mails: [EMAIL PROTECTED]
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 
 Esta mensagem foi verificada pelo E-mail Protegido Terra.
 Scan engine: McAfee VirusScan / Atualizado em 04/08/2006 / Versão: 4.4.00/4822
 Proteja o seu e-mail Terra: http://mail.terra.com.br/
 
 


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


Re: [R] Doubt about Student t distribution simulation

2006-08-04 Thread John Fox
Dear Sundar,

Try qq.plot(t, dist=t, df=n-1) from the car package, which include a
95-percent point-wise confidence envelope that helps you judge how extreme
the outliers are relative to expectations.

Regards,
 John


John Fox
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox 
 

 -Original Message-
 From: Sundar Dorai-Raj [mailto:[EMAIL PROTECTED] 
 Sent: Friday, August 04, 2006 3:27 PM
 To: John Fox
 Cc: [EMAIL PROTECTED]; R-help@stat.math.ethz.ch
 Subject: Re: [R] Doubt about Student t distribution simulation
 
 Hi, Jose/John,
 
 Here's an example to help Jose and highlights John's advice. 
 Also includes set.seed which should be included in all 
 simulations posted to R-help.
 
 set.seed(42)
 mu - 10
 sigma -  5
 n - 3
 nsim - 1
 m - matrix(rnorm(n * nsim, mu, sigma), nsim, n) t - 
 apply(m, 1, function(x) (mean(x) - mu)/(sd(x)/sqrt(n)))
 
 library(lattice)
 qqmath(t, distribution = function(x) qt(x, n - 1),
 panel = function(x, ...) {
   panel.qqmath(x, col = darkblue, ...)
   panel.qqmathline(x, col = darkred, ...)
 })
 
 
 With n = 3, expect a few outliers.
 
 --sundar
 
 
 John Fox wrote:
  Dear Jose,
  
  The problem is that you're using the population standard deviation 
  (sigma) rather than the sample SD of each sample [i.e., t[i]  = 
  (mean(amo.i) - mu) /
  (sd(amo.i) / sqrt(n)) ], so your values should be normally 
  distributed, as they appear to be.
  
  A couple of smaller points: (1) Even after this correction, you're 
  sampling from a discrete population (albeit with 
 replacement) and so 
  the values won't be exactly t-distributed. You could draw 
 the samples 
  directly from N(mu,
  sigma) instead. (2) It would be preferable to make a 
  quantile-comparison plot against the t-distribution, since 
 you'd get a 
  better picture of what's going on in the tails.
  
  I hope this helps,
   John
  
  
  John Fox
  Department of Sociology
  McMaster University
  Hamilton, Ontario
  Canada L8S 4M4
  905-525-9140x23604
  http://socserv.mcmaster.ca/jfox
  
  
  
 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Jose Claudio 
 Faria
 Sent: Friday, August 04, 2006 3:09 PM
 To: R-help@stat.math.ethz.ch
 Subject: [R] Doubt about Student t distribution simulation
 
 Dear R list,
 
 I would like to illustrate the origin of the Student t distribution 
 using R.
 
 So, if (sample.mean - pop.mean) / standard.error(sample.mean) has t 
 distribution with (sample.size - 1) degree free, what is wrong with 
 the simulation below? I think that the theoretical curve 
 should agree 
 with the relative frequencies of the t values calculated:
 
 #== begin options=
 # parameters
mu= 10
sigma =  5
 
 # size of sample
n = 3
 
 # repetitions
nsim = 1
 
 # histogram parameter
nchist = 150
 #== end options===
 
 t   = numeric()
 pop = rnorm(1, mean = mu, sd = sigma)
 
 for (i in 1:nsim) {
amo.i = sample(pop, n, replace = TRUE)
t[i]  = (mean(amo.i) - mu) / (sigma / sqrt(n)) }
 
 win.graph(w = 5, h = 7)
 split.screen(c(2,1))
 screen(1)
 hist(t,
   main = histogram,
   breaks   = nchist,
   col  = lightgray,
   xlab = '', ylab = Fi,
   font.lab = 2, font = 2)
 
 screen(2)
 hist(t,
   probability = T,
   main= 'f.d.p and histogram',
   breaks  = nchist,
   col = 'lightgray',
   xlab= 't', ylab = 'f(t)',
   font.lab= 2, font = 2)
 
 x = t
 curve(dt(x, df = n-1), add = T, col = red, lwd = 2)
 
 Many thanks for any help,
 ___
 Jose Claudio Faria
 Brasil/Bahia/Ilheus/UESC/DCET
 Estatística Experimental/Prof. Adjunto
 mails: [EMAIL PROTECTED]
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
  
  
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide 
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.

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


[R] Help with short time series

2006-08-04 Thread Simone Vincenzi
Dear R-list, 
I have a statistical problem with the comparison of two short time-series of 
density data in an ecological framework. I have to compare two short time 
series (5 years, one value for each year) of species density data (it is the 
density of fish in two different streams) to test if the two means of the 
five densities are significantly different, so basically if the two mean 
stream-specific fish densities are significantly different. 
I don't think I can use a straight t-test due to the problem of 
autocorrelation and I don't think I can use a repeated measure ANOVA as I 
don't have any replicates. 
Any help would be greatly appreciated. 

Thanks 

Simone Vincenzi  


--
Universita' degli Studi di Parma (http://www.unipr.it)

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


[R] Postscript fonts

2006-08-04 Thread Erich Neuwirth
How can I find out what fonts are available for
par(family=
for the postscript device?



-- 
Erich Neuwirth, Didactic Center for Computer Science
University of Vienna
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-39464 Fax: +43-1-4277-9394

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


[R] Variance-Covariance matrix from glm()

2006-08-04 Thread Daniel Jeske
We are trying to find out how to get the variance-covariance matrix of the
MLEs out of the glm function.  Can anyone help?

 

Thanks,

Daniel Jeske

Department of Statistics

University of California

Riverside, CA

 

 

 


[[alternative HTML version deleted]]

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


[R] polychoric correlation error

2006-08-04 Thread Rosenbaum, Janet

Dear all,

I get a strange error when I find polychoric correlations with the ML method, 
which I have been able to reproduce using randomly-generated data.

What is wrong?  
I realize that the data that I generated randomly is a bit strange, but it is 
the only way that I duplicate the error message.


 n-100
 test.x-rnorm(n, mean=0, sd=1)
 test.c-test.x + rnorm(n, mean=0, sd=.5)
 thresh.x-c(-2.5, -1, -.5, .5, 1000)
 thresh.c-c(-1, 1, 2, 3, 1000)
 
 discrete.x-discrete.c-vector(length=n)
 
 for (i in 1:n) {
+   discrete.x[i]-which.min(thresh.x  test.x[i] )
+   discrete.c[i]-which.min(thresh.c  test.c[i] )
+ }
 pc-polychor(discrete.x, discrete.c, std.err=T, ML=T)
Error in optim(c(optimise(f, interval = c(-1, 1))$minimum, rc, cc), f,  : 
non-finite finite-difference value [1]
In addition: There were 50 or more warnings (use warnings() to see the first 50)
 print(pc)
Error in print(pc) : object pc not found
 warnings()
Warning messages:
1: NaNs produced in: log(x) 
2: NA/Inf replaced by maximum positive value
3: NaNs produced in: log(x) 


---

Thanks,

Janet



This email message is for the sole use of the intended recip...{{dropped}}

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


Re: [R] Variance-Covariance matrix from glm()

2006-08-04 Thread Achim Zeileis
On Fri, 4 Aug 2006, Daniel Jeske wrote:

 We are trying to find out how to get the variance-covariance matrix of the
 MLEs out of the glm function.  Can anyone help?

It can be extracted with the corresponding vcov() method.

Best,
Z

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


[R] (... not defined because of singularities) in lm()

2006-08-04 Thread Jia Pu
I got the message,  Coefficients: (1 not defined because of  
singularities), in the returned result of lm(). What does it mean?  
And where should I start investigating why it happens?

thanks.


/// Complete result of lm()
Call:
lm(formula = durationRatio ~ isHStar + isWordFinal + oneSyllToEOW +
 isInterNuclear + isIntonNuclear + isInterLP + isIntonLF +
 zeroSyllToNA + oneSyllToNA + zeroSyllToEOP + oneSyllToEOP +
 isInterNuclear:zeroSyllToEOP)

Residuals:
   Min1QMedian3Q   Max
-3.031538 -0.126943 -0.002909  0.121606  4.322135

Coefficients: (1 not defined because of singularities)
   Estimate Std. Error t value Pr(|t|)
(Intercept)   1.044481   0.010694  97.669   2e-16 ***
isHStar  -0.055227   0.005748  -9.607   2e-16 ***
isWordFinal  -0.262071   0.009982 -26.254   2e-16 ***
oneSyllToEOW -0.031313   0.009917  -3.158  0.00160 **
isInterNuclear0.063470   0.015699   4.043 5.32e-05 ***
isIntonNuclear0.054570   0.011711   4.660 3.21e-06 ***
isInterLP-0.262302   0.011868 -22.102   2e-16 ***
isIntonLF-0.160018   0.012537 -12.764   2e-16 ***
zeroSyllToNA -0.160767   0.011105 -14.477   2e-16 ***
oneSyllToNA  -0.012633   0.010779  -1.172  0.24123
zeroSyllToEOP-0.212474   0.011987 -17.726   2e-16 ***
oneSyllToEOP -0.123324   0.010998 -11.214   2e-16 ***
isInterNuclear:zeroSyllToEOPNA NA  NA   NA
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.2662 on 9650 degrees of freedom
Multiple R-Squared: 0.3957, Adjusted R-squared: 0.395
F-statistic: 574.5 on 11 and 9650 DF,  p-value:  2.2e-16

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


[R] cor of two matrices whose columns got shuffled

2006-08-04 Thread Betty Gilbert
Hello,
I'm trying to take the correlation of two distance matrices and get 
the r2 value
ex)


 Ndisc PS1Ntet   Nsito NcB NcA PS3 NcC 
NiB NiA
PS1 
0.08945   
Ntet  0.08601 
0.02020   
Nsito 0.09361 0.02780 
0.02260   
NcB   0.09479 0.03258 0.02914 
0.03674   
NcA   0.09363 0.03142 0.02798 0.03558 
0.02190   
PS3   0.09145 0.02924 0.02580 0.03340 0.02446 
0.02330   
NcC   0.08919 0.02698 0.02354 0.03114 0.02220 0.02104 
0.01670   
NiB   0.09749 0.03802 0.03458 0.04218 0.04336 0.04220 0.04002 
0.03776   
NiA   0.09571 0.03624 0.03280 0.04040 0.04158 0.04042 0.03824 0.03598 
0.02170   
PS2   0.09234 0.03287 0.02943 0.03703 0.03821 0.03705 0.03487 0.03261 
0.03289 0.03111


and
  Ndisc  PS1 Ntet  NcB  NcA  NcC  PS3 
Nsito  PS2  NiB
PS1 
2.981494

Ntet  2.949046 
1.003718   
NcB   3.212256 1.266928 
1.178326  
NcA   3.531725 1.586397 1.497795 
1.217055 
NcC   3.111421 1.166093 1.077491 0.944637 
1.264106
PS3   3.115273 1.169945 1.081343 1.000991 1.320460 
0.900156   
Nsito 2.994152 1.131330 1.098882 1.362092 1.681561 1.261257 
1.265109  
PS2   2.843805 1.228361 1.195913 1.459123 1.778592 1.358288 1.362140 
1.241019 
NiB   2.805537 1.375615 1.343167 1.606377 1.925846 1.505542 1.509394 
1.388273 1.237926
NiA   2.752269 1.322347 1.289899 1.553109 1.872578 1.452274 1.456126 
1.335005 1.184658 1.018210


The problem is that these matrices are the endpoint of an extensive 
simulation involving phylogenetic trees and the order of the columns 
and rows shifts around according to how they were ordered in the 
tree. I used cophenetic.phylo to get the distance matrix and now I 
need to find a way to reorder or sort the columns and rows such that 
the two matrices match and cor is taking the correlation of the 
corresponding column and row and not just the  one in the same 
position. I don't want to sort the values in the columns and rows but 
the entire column and their associated rows. I've looked at order , 
sort, and match and can't figure out a way to do it based on the 
alphanumeric name of the columns.  Does anyone have any suggestions?
Sincerely,
Betty




-- 
Betty Gilbert
[EMAIL PROTECTED]
Taylor Lab
Plant and Microbial Biology
321 Koshland Hall
U.C. Berkeley
Berkeley, Ca 94720
[[alternative HTML version deleted]]

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


Re: [R] polychoric correlation error

2006-08-04 Thread John Fox
Dear Janet,

Because you didn't set the value of the random-number generator seed, your
example isn't precisely reproducible, but the problem is apparent anyway:

 set.seed(12345)
 n-100
 test.x-rnorm(n, mean=0, sd=1)
 test.c-test.x + rnorm(n, mean=0, sd=.5) 
 thresh.x-c(-2.5, -1, -.5, .5, 1000) 
 thresh.c-c(-1, 1, 2, 3, 1000)
 
 discrete.x-discrete.c-vector(length=n)
 
 for (i in 1:n) {
+ discrete.x[i]-which.min(thresh.x  test.x[i] )
+ discrete.c[i]-which.min(thresh.c  test.c[i] ) }
 
 table(discrete.x, discrete.c)
  discrete.c
discrete.x  1  2  3  4  5
 2 12  1  0  0  0
 3  3 12  0  0  0
 4  2 19  2  0  0
 5  0 18 21  9  1
 
 cor(test.x, test.c)
[1] 0.9184189
 
 pc - polychor(discrete.x, discrete.c, std.err=T, ML=T)
Warning messages:
1: NaNs produced in: log(x) 
2: NaNs produced in: log(x) 
3: NaNs produced in: log(x) 
 pc

Polychoric Correlation, ML est. = 0.9077 (0.03314)
Test of bivariate normality: Chisquare = 3.103, df = 11, p = 0.9893

  Row Thresholds
  Threshold Std.Err.
1  -1.12200   0.1609
2  -0.56350   0.1309
3   0.03318   0.1235


  Column Thresholds
  Threshold Std.Err.
1   -0.9389   0.1489
20.4397   0.1292
31.2790   0.1707
42.3200   0.3715
 

The variables that you've created are indeed bivariate normal, but they are
highly correlated, and your choice of cut points makes it hard to estimate
the correlation from the contingency tables, apparently producing some
difficulty in the maximization of the likelihood. Nevertheless, the ML
estimates of the correlation and thresholds for the set of data above are
pretty good. (In your case, the optimization failed.)

BTW, a more straightforward way to create the categorical variables would be

discrete.x - cut(test.x, c(-Inf, -2.5, -1, -.5, .5, Inf))
discrete.c - cut(test.c, c(-Inf, -1, 1, 2, 3, Inf))

I hope this helps,
 John


John Fox
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox 
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of 
 Rosenbaum, Janet
 Sent: Friday, August 04, 2006 5:49 PM
 To: r-help@stat.math.ethz.ch
 Subject: [R] polychoric correlation error
 
 
 Dear all,
 
 I get a strange error when I find polychoric correlations 
 with the ML method, which I have been able to reproduce using 
 randomly-generated data.
 
 What is wrong?  
 I realize that the data that I generated randomly is a bit 
 strange, but it is the only way that I duplicate the error message.
 
 
  n-100
  test.x-rnorm(n, mean=0, sd=1)
  test.c-test.x + rnorm(n, mean=0, sd=.5) thresh.x-c(-2.5, -1, -.5, 
  .5, 1000) thresh.c-c(-1, 1, 2, 3, 1000)
  
  discrete.x-discrete.c-vector(length=n)
  
  for (i in 1:n) {
 + discrete.x[i]-which.min(thresh.x  test.x[i] )
 + discrete.c[i]-which.min(thresh.c  test.c[i] ) }
  pc-polychor(discrete.x, discrete.c, std.err=T, ML=T)
 Error in optim(c(optimise(f, interval = c(-1, 1))$minimum, 
 rc, cc), f,  : 
   non-finite finite-difference value [1]
 In addition: There were 50 or more warnings (use warnings() 
 to see the first 50)
  print(pc)
 Error in print(pc) : object pc not found
  warnings()
 Warning messages:
 1: NaNs produced in: log(x)
 2: NA/Inf replaced by maximum positive value
 3: NaNs produced in: log(x) 
 
 
 ---
 
 Thanks,
 
 Janet
 
 
 
 This email message is for the sole use of the intended\  ...{{dropped}}

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