Re: [R] Bug in formals-

2006-09-27 Thread Peter Dalgaard
Frank E Harrell Jr [EMAIL PROTECTED] writes:

 Deepayan Sarkar wrote:
  On 9/26/06, Frank E Harrell Jr [EMAIL PROTECTED] wrote:
  I think this is new since a previous version of R:
 
h - function(x, trantab) trantab[x]
w - 6:4
names(w) - c('cat','dog','giraffe')
w
   cat dog giraffe
 6   5   4
   
formals(h) - list(x=numeric(0), trantab=w)
h
  function (x = numeric(0), trantab = c(6, 5, 4))
  trantab[x]
 
  You can see that the names have been dropped from trantab's default
  values.
  
  Are you sure? I get
  
  formals(h)
  $x
  numeric(0)
  
  $trantab
 cat dog giraffe
   6   5   4
  
  h(1)
  cat
   6
  
  R version 2.4.0 beta (2006-09-21 r39463)
  x86_64-unknown-linux-gnu
  
  -Deepayan
 
 Deepayan -
 
 You are correct.  h('cat') is 6 as intended.  I just looked at the 
 function definition - the names attribute doesn't show for some reason. 
   I was expecting function(..., trantab=c(cat=6, ..).

It's a generic deparsing issue. Also:

 substitute(f(w),list(w=w))
f(c(6, 5, 4))

We should probably fix it at some point. Notice though that you can't
parse your way into such situations, only get there by computing on
the language.

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


[R] multiple imputation

2006-09-27 Thread ozric
Hi,

is it correct that multiple-Imputation like  mice 
http://www.imputation.com can't understand as a standard data-mining 
task, beacuse i haven't a generalization mechanism perform the model on 
complete new and bigger dataset with a predict method!?

many thanks  regards,
christian

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


Re: [R] New project: littler for GNU R

2006-09-27 Thread Seth Falcon
Jeffrey Horner [EMAIL PROTECTED] writes:

 Seth Falcon wrote:
 Wow, looks neat.

 OS X users will be unhappy with your naming choice as the default
 filesystem there is not case-sensitive :-(

 IOW, r and R do the same thing.  I would expect it to otherwise work
 on OS X so a change of some sort might be worthwhile.

 (I'm always amazed at how I can miss the simplest details. I probably
 knew at some point that OS X shipped with a case-sensitive file
 system, which you can turn off somehow, but forgot. Thank goodness for
 peer review.)

 littler will install into /usr/local/bin by default, so I don't think
 there's a clash with the Mac binary provided by CRAN, right?

It depends what you mean by clash :-)

If both are on the PATH, then you get the first one, I suspect, when
running either 'R' or 'r'.  I haven't tested this bit yet, but on my
OS X laptop I can invoke a new R session using either 'R' or 'r'
(using an R built from source, not the R GUI app thingie).

So IMO, a different name or an integration into the R script in some
way would be a big improvement.  

'r' is cute, but going down the road of tools with the same name
except for caps leads to confusion (for me).  For example, R CMD
build/INSTALL still catches me up after a number of years.

+ seth

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


[R] exact 95% confidence intervals

2006-09-27 Thread XinMeng
Hello sir:
As to the 2*2 table format for reporting results comparing a new test to true 
diagnosis,when I got the sensitivity and specificity,how can I calculate the 
exact 95% confidence intervals (based on the binomial distribution) for 
sensitivity and specificity via R?

Thanks a  lot!

My best!



--
***
Xin Meng 
Capitalbio Corporation
National Engineering Research Center 
for Beijing Biochip Technology 
BioPharma-informatics  Software Dept. 
Research Engineer
Tel: +86-10-80715888/80726868-6438
Fax: +86-10-80726790
[EMAIL PROTECTED] 
Address:18 Life Science Parkway, 
Changping District, Beijing 102206, China

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


[R] How to pass expression as an argument

2006-09-27 Thread Tong Wang
Hi,
 I am writing a function and need to pass a function expression as an 
argument,   for instance, 
myfun -  function( express) {
   x- c(1,2,3)
  y-express
 }

if I call the above function by myfun( x*2 ), I get  2  as the result,  
instead of  2,4,6 ,  could someone help me to 
fix this problem ? 
Furthermore,  is that possible to operate this expression on different 
variables?  for example, in myfun(), I 
might want to get  u*2,  z*2,  etc. without having to say x-u, x-z to match 
the expression.

Thanks a lot for your help.

best

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


Re: [R] How to pass expression as an argument

2006-09-27 Thread Peter Dalgaard
Tong Wang [EMAIL PROTECTED] writes:

 Hi,
  I am writing a function and need to pass a function expression as an 
 argument,   for instance, 
 myfun -  function( express) {
x- c(1,2,3)
   y-express
  }
 
 if I call the above function by myfun( x*2 ), I get  2  as the result,  
 instead of  2,4,6 ,  could someone help me to 
 fix this problem ? 
 Furthermore,  is that possible to operate this expression on different 
 variables?  for example, in myfun(), I 
 might want to get  u*2,  z*2,  etc. without having to say x-u, x-z to match 
 the expression.
 
 Thanks a lot for your help.

Either pass the expression explicitly using myfun(quote(x*2)) or
myfun(expression(x*2)) or use substitute(express) inside the function. 

-- 
   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] Accessing C- source code of R

2006-09-27 Thread Gunther Höning
That's exactly what I was looking for...

Thanks!
Gunther

-Ursprüngliche Nachricht-
Von: Uwe Ligges [mailto:[EMAIL PROTECTED] 
Gesendet: Dienstag, 26. September 2006 10:13
An: Gunther Höning
Cc: r-help@stat.math.ethz.ch
Betreff: Re: [R] Accessing C- source code of R



Gunther Höning wrote:
 Dear list,
 
 I'm looking for the sources code of parts of R, (e.g. spline).
 Does anyone know where I can access it ?

I plan to write a corresponding R Help Desk article on Accessing the
source. A draft is available from:
http://www.statistik.uni-dortmund.de/~ligges/R_Help_Desk_preview.pdf

Can you please tell me if this description is sufficient?

Thanks,
Uwe Ligges


 Gunther
 
 __
 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] exact 95% confidence intervals

2006-09-27 Thread Peter Dalgaard
XinMeng [EMAIL PROTECTED] writes:

 Hello sir:

 As to the 2*2 table format for reporting results comparing a new
 test to true diagnosis,when I got the sensitivity and
 specificity,how can I calculate the exact 95% confidence intervals
 (based on the binomial distribution) for sensitivity and specificity
 via R?

Just run binom.test on the data from each column (or row, depending on
which way you turn the tables).

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


[R] Impossible to merge with a zero rows data frame?

2006-09-27 Thread Bonfigli Sandro
I'm trying to merge two data frames. One of them is a zero rows data 
frame.
I'm using the merge parameter 'all.x = TRUE' so I'd expect to obtain all
the rows of x. In fact the merge help says:

all.x: logical; if 'TRUE', then extra rows will be added to the
  output, one for each row in 'x' that has no matching row in
  'y'.  These rows will have 'NA's in those columns that are
  usually filled with values from 'y'.

To let you test the problem here is some code:

 L3 - LETTERS[1:3]
 (d - data.frame(cbind(x=1, y=1), fac=sample(L3, 1, repl=TRUE)))
 e - d[-1,]

so now we have that:
 e
[1] x   y   fac
0 rows (or 0-length row.names)

here is the merge:
 merge(d, e, by.x = c(x), by.y = c(x), all.x = TRUE)

I'd expect something like:
  x y.x fac.x y.y fac.y
1 1   1 B  NANA
instead of:
Error in merge.data.frame(d, e, by.x = c(x), by.y = c(x), all.x = TRUE) : 
no row to correspond
(I'm traslating the error message, so it could be a little different)

My questions are:
Is there a way to obtain my desired result? In the context in which I'd 
like to use the code the second data frame is the result of a query
and a lot of overwork would be added if I have to check if the dataframe
is a zero rows one BEFORE the merge (in fact I do a sequence of several
merge)
Is this behaviour of the merge command correct? Why did the developers
choose it?

P.S.: I tested this code both in R 2.3.0 and in 2.3.1

Thank you in advance.
   Sandro Bonfigli

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


[R] Any hot-deck imputation packages?

2006-09-27 Thread Eleni Rapsomaniki
Hi

I found on google that there is an implementation of hot-deck imputation in
SAS:
http://ideas.repec.org/c/boc/bocode/s366901.html

Is there anything similar in R?

Many Thanks
Eleni Rapsomaniki

__
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] Any hot-deck imputation packages?

2006-09-27 Thread David Barron
I'm not sure if this is exactly what you're after, but it might be worth
looking at aregImpute in the Hmisc package.

On 27/09/06, Eleni Rapsomaniki [EMAIL PROTECTED] wrote:

 Hi

 I found on google that there is an implementation of hot-deck imputation
 in
 SAS:
 http://ideas.repec.org/c/boc/bocode/s366901.html

 Is there anything similar in R?

 Many Thanks
 Eleni Rapsomaniki

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




-- 
=
David Barron
Said Business School
University of Oxford
Park End Street
Oxford OX1 1HP

[[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] Constrained OLS regression

2006-09-27 Thread Mesomeris, Spyros [CIR]
Hello R helpers,

I am trying to do a linear OLS regression of y on two variables x1 and
x2. I want to constrain the coefficients of x1 and x2 to sum up to 1.
and therefore run a constrained OLS. Can anybody help with this? (I have
seen some answers to similar questions but it was not clear to me what I
need to do) - I have tried the lm function with offset but I must not
have used it properly.

Thanks,
Spyros

__
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] Constrained OLS regression

2006-09-27 Thread David Barron
Have a look at the linear.hypothesis function in the car package.  For example:

 mod.duncan - lm(prestige ~ income + education, data=Duncan)

 linear.hypothesis(mod.duncan, income + education = 1)
Linear hypothesis test

Hypothesis:
income + education = 1

Model 1: prestige ~ income + education
Model 2: restricted model

  Res.DfRSS Df Sum of Sq  F  Pr(F)
1 42 7506.7
2 43 8045.2 -1-538.5 3.0129 0.08994 .
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1


On 27/09/06, Mesomeris, Spyros [CIR] [EMAIL PROTECTED] wrote:
 Hello R helpers,

 I am trying to do a linear OLS regression of y on two variables x1 and
 x2. I want to constrain the coefficients of x1 and x2 to sum up to 1.
 and therefore run a constrained OLS. Can anybody help with this? (I have
 seen some answers to similar questions but it was not clear to me what I
 need to do) - I have tried the lm function with offset but I must not
 have used it properly.

 Thanks,
 Spyros

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




-- 
=
David Barron
Said Business School
University of Oxford
Park End Street
Oxford OX1 1HP

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


Re: [R] New project: littler for GNU R

2006-09-27 Thread Duncan Murdoch
Gabor Grothendieck wrote:
 I think this is quoted out of context. I was referring to Duncan's post
 which shows an example of piping R code.
   

No, that was Jeffrey's post that showed the pipe.  All that was in my 
post was a question about why this isn't a patch to the standard R 
script.  I don't think anyone has answered that, so I assume the reason 
is that it just seemed easier to write a separate script than to change 
the standard one.

If someone else designs, documents and commits the necessary changes to 
the standard script, I'd be happy to follow suit with the Windows R.exe.

Duncan Murdoch
 On 9/26/06, Dirk Eddelbuettel [EMAIL PROTECTED] wrote:
   
 On 26 September 2006 at 22:17, Gabor Grothendieck wrote:
 | The real problem is that one wants to pipe the data in, not the
 | R source.  The idea is that one successively transforms the
 | data in successive elements of the pipeline.

 But that is what our filesize example does::

 | On 9/26/06, Duncan Murdoch [EMAIL PROTECTED] wrote:
 |  On 9/26/2006 1:04 PM, Jeffrey Horner wrote:
 [...]
 |  But unlike bc(1), GNU R has a vast number of statistical
 |  functions. For example, we can quickly compute a summary() and show
 |  a stem-and-leaf plot for file sizes in a given directory via
 |  
 |$ ls -l /boot | awk '!/^total/ {print $5}' | \
 | r -e 'fsizes - as.integer(readLines());
 |print(summary(fsizes)); stem(fsizes)'
 |   Min. 1st Qu.  MedianMean 3rd Qu.Max.
 | 13 512  110100  486900  768400 4735000
 |Loading required package: grDevices
 |  
 |  The decimal point is 6 digit(s) to the right of the |
 |  
 |  0 | 002223
 |  0 | 5557778899
 |  1 | 112233
 |  1 | 5
 |  2 |
 |  2 |
 |  3 |
 |  3 |
 |  4 |
 |  4 | 7

 Data to be processed on stdin, command via -e 'some long expression'.

 To make it simpler, here is a somewhat useless example of r piping into r
 (which I've indented for readability):

  $  r -e 'set.seed(42); sapply(rnorm(5),function(x) cat(x,\n))' |  \
 r -e 'cat(sum(abs(as.numeric(readLines(, \n)'
  3.335916

 Isn't that something where, to quote you, one wants to pipe the data in, not
 the R source ?

 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.


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


Re: [R] New project: littler for GNU R

2006-09-27 Thread Duncan Murdoch
Jeffrey Horner wrote:
 Seth Falcon wrote:
   
 Jeffrey Horner [EMAIL PROTECTED] writes:
 

 [...]

   
 littler will install into /usr/local/bin by default, so I don't think
 there's a clash with the Mac binary provided by CRAN, right?
   
 It depends what you mean by clash :-)

 If both are on the PATH, then you get the first one, I suspect, when
 running either 'R' or 'r'.  I haven't tested this bit yet, but on my
 OS X laptop I can invoke a new R session using either 'R' or 'r'
 (using an R built from source, not the R GUI app thingie).
 

 Good point, but the executable path can be named absolutely in hash-bang 
 scripts. Relative paths work as well with the use of '/usr/bin/env 
 program' as is described in the littler announcement, but then you don't
 get to pass arguments to 'program', just to the hash-bang script.

   
 So IMO, a different name or an integration into the R script in some
 way would be a big improvement.
 

 But I'd like to know why there's an R script in the first place. Why not 
 just an executable as on windows?
   

There need to be (at least) two separate executables:  on Windows they 
are R.exe which invokes Rterm.exe. The reason for this is that R CMD 
foo invokes the script foo, it doesn't run Rterm at all.  On 
Unix-alikes the first is a script rather than an exe.

The reason the first is a script on Unix is that whoever wrote it 
preferred the sh script language to C for handling the things it needs 
to do, but that's not generally available in Windows, so we were stuck 
with C.

Duncan Murdoch
   
 'r' is cute, but going down the road of tools with the same name
 except for caps leads to confusion (for me).  For example, R CMD
 build/INSTALL still catches me up after a number of years.
 

 That's a different problem than case-sensitivity. The word 'build' must 
 have had a different semantic than INSTALL, and I'm not sure why one was 
 all caps and the other isn't.

 Jeff


__
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] Constrained OLS regression

2006-09-27 Thread Dimitris Rizopoulos
you could reparameterize, e.g.,

x1 - runif(100, -4, 4)
x2 - runif(100, -4, 4)
X - cbind(1, x1 , x2)
y -  rnorm(100, as.vector(X %*% c(5, -3, 4)), 2)
##

fn - function(betas){
betas - c(betas, 1 - betas[2])
crossprod(y - X %*% betas)[1, ]
}

opt - optim(c(5, -3), fn, method = BFGS)
c(opt$par, 1 - opt$par[2])


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: Mesomeris, Spyros [CIR] [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Sent: Wednesday, September 27, 2006 12:51 PM
Subject: [R] Constrained OLS regression


 Hello R helpers,

 I am trying to do a linear OLS regression of y on two variables x1 
 and
 x2. I want to constrain the coefficients of x1 and x2 to sum up to 
 1.
 and therefore run a constrained OLS. Can anybody help with this? (I 
 have
 seen some answers to similar questions but it was not clear to me 
 what I
 need to do) - I have tried the lm function with offset but I must 
 not
 have used it properly.

 Thanks,
 Spyros

 __
 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] How to pass expression as an argument

2006-09-27 Thread Gabor Grothendieck
On 27 Sep 2006 10:57:15 +0200, Peter Dalgaard [EMAIL PROTECTED] wrote:
 Tong Wang [EMAIL PROTECTED] writes:

  Hi,
   I am writing a function and need to pass a function expression as an 
  argument,   for instance,
  myfun -  function( express) {
 x- c(1,2,3)
y-express
   }
 
  if I call the above function by myfun( x*2 ), I get  2  as the result,  
  instead of  2,4,6 ,  could someone help me to
  fix this problem ?
  Furthermore,  is that possible to operate this expression on different 
  variables?  for example, in myfun(), I
  might want to get  u*2,  z*2,  etc. without having to say x-u, x-z to 
  match the expression.
 
  Thanks a lot for your help.

 Either pass the expression explicitly using myfun(quote(x*2)) or
 myfun(expression(x*2)) or use substitute(express) inside the function.


Regarding the second option see the source of curve by entering:

curve

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


Re: [R] New project: littler for GNU R

2006-09-27 Thread Duncan Murdoch
On 9/27/2006 7:06 AM, Duncan Murdoch wrote:
 Gabor Grothendieck wrote:
 I think this is quoted out of context. I was referring to Duncan's post
 which shows an example of piping R code.
   
 
 No, that was Jeffrey's post that showed the pipe.  All that was in my 
 post was a question about why this isn't a patch to the standard R 
 script.  I don't think anyone has answered that, so I assume the reason 
 is that it just seemed easier to write a separate script than to change 
 the standard one.

I've been reminded offline that this was discussed a few months ago by R 
Core, and some tricky questions were raised.  Nobody had the time to 
address them before 2.4.0, but I think the hope is that we'll have time 
after it is released to nail down the decisions on this so that 
something makes it into 2.5.0.

Expect some more comments on the tricky questions, but not for a 
couple of weeks:  2.4.0 is due out in 6 days, and that's the priority 
right now.

Duncan Murdoch


 
 If someone else designs, documents and commits the necessary changes to 
 the standard script, I'd be happy to follow suit with the Windows R.exe.
 
 Duncan Murdoch
 On 9/26/06, Dirk Eddelbuettel [EMAIL PROTECTED] wrote:
   
 On 26 September 2006 at 22:17, Gabor Grothendieck wrote:
 | The real problem is that one wants to pipe the data in, not the
 | R source.  The idea is that one successively transforms the
 | data in successive elements of the pipeline.

 But that is what our filesize example does::

 | On 9/26/06, Duncan Murdoch [EMAIL PROTECTED] wrote:
 |  On 9/26/2006 1:04 PM, Jeffrey Horner wrote:
 [...]
 |  But unlike bc(1), GNU R has a vast number of statistical
 |  functions. For example, we can quickly compute a summary() and show
 |  a stem-and-leaf plot for file sizes in a given directory via
 |  
 |$ ls -l /boot | awk '!/^total/ {print $5}' | \
 | r -e 'fsizes - as.integer(readLines());
 |print(summary(fsizes)); stem(fsizes)'
 |   Min. 1st Qu.  MedianMean 3rd Qu.Max.
 | 13 512  110100  486900  768400 4735000
 |Loading required package: grDevices
 |  
 |  The decimal point is 6 digit(s) to the right of the |
 |  
 |  0 | 002223
 |  0 | 5557778899
 |  1 | 112233
 |  1 | 5
 |  2 |
 |  2 |
 |  3 |
 |  3 |
 |  4 |
 |  4 | 7

 Data to be processed on stdin, command via -e 'some long expression'.

 To make it simpler, here is a somewhat useless example of r piping into r
 (which I've indented for readability):

  $  r -e 'set.seed(42); sapply(rnorm(5),function(x) cat(x,\n))' |  \
 r -e 'cat(sum(abs(as.numeric(readLines(, \n)'
  3.335916

 Isn't that something where, to quote you, one wants to pipe the data in, 
 not
 the R source ?

 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.

 
 __
 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] multiple imputation

2006-09-27 Thread Frank E Harrell Jr
[EMAIL PROTECTED] wrote:
 Hi,
 
 is it correct that multiple-Imputation like  mice 
 http://www.imputation.com can't understand as a standard data-mining 
 task, beacuse i haven't a generalization mechanism perform the model on 
 complete new and bigger dataset with a predict method!?
 
 many thanks  regards,
 christian

This is something we need.  I have not written a predict method for 
aregImpute in the Hmisc package yet (and soon a completely re-written 
version of aregImpute will be posted) but the framework in aregImpute 
may allow such a method to be written.  Volunteers welcome.

Frank

-- 
Frank E Harrell Jr   Professor and Chair   School of Medicine
  Department of Biostatistics   Vanderbilt University

__
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] exact 95% confidence intervals

2006-09-27 Thread Frank E Harrell Jr
Peter Dalgaard wrote:
 XinMeng [EMAIL PROTECTED] writes:
 
 Hello sir:
 
 As to the 2*2 table format for reporting results comparing a new
 test to true diagnosis,when I got the sensitivity and
 specificity,how can I calculate the exact 95% confidence intervals
 (based on the binomial distribution) for sensitivity and specificity
 via R?
 
 Just run binom.test on the data from each column (or row, depending on
 which way you turn the tables).
 

But beware of exact binomial intervals - they are often not very 
accurate.  Wilson and other intervals are generally better.  For example 
see the binconf function in the Hmisc package.

-- 
Frank E Harrell Jr   Professor and Chair   School of Medicine
  Department of Biostatistics   Vanderbilt University

__
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] equivalent of model.tables for an lm.object?

2006-09-27 Thread Henrik Parn
Dear all,

I run a linear model with three significant explanatory variabels
x1: a factor with 4 levels
x2 and x3: factors with two levels each
x4: continuous

model - lm(y ~ x1 + x2 * x3 + x4)

The data is not perfectly balanced between the different 
factor-combinations and I use treatment contrasts.

With an aov.object, I assume I could have used model.tables(aov.object, 
type = means, se = TRUE), to get the means and se for all factor 
combinations.

In an lm.object like mine, I calculate the means 'manually' from the 
Estimates (for sure it could be done with a script, but fair enough). 
For the standard error of the means, I started out using formulas of a 
variance of a sum of two variables, but I messed things up with the 
interaction. Is there a way to calculate the standard error of the means 
from Estimates and Std.Error (or other information) from the lm.object?


Thanks in advance for any advice!

Best regards,

Henrik


-- 

Henrik Pärn
Department of Biology
NTNU
7491 Trondheim
Norway

+47 735 96282 (office)
+47 909 89 255 (mobile)
+47 735 96100 (fax)

__
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] pdf and postscript sizes - change on each page?

2006-09-27 Thread Alex Brown
Hi All

The device commands pdf and postscript allow you to specify the width  
and height of a page.  However, each subsequent plot is drawn on a  
separate page.  Is there a way to change the page size part way through?

For instance, is there an equivalent to the function pdfresize below?

pdf(/tmp/1.pdf, width=6, height=6)

plot(1:10)

pdf.resize(width=8, height=5)

plot(sin, -pi, pi)

dev.off()

---

So far, the only way I can find to do this is:

pdf(/tmp/1.pdf, width=6, height=6)

plot(1:10)

dev.off()

pdf(/tmp/1.pdf, width=8, height=5)

plot(sin, -pi, pi)

dev.off()

---

however, this creates a new file - it does not append to the existing  
file.

I would note that the quartz device has some resize capability, when  
you drag the window frame.

-Alex

__
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] exact 95% confidence intervals

2006-09-27 Thread Dimitris Rizopoulos
check package binom.


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: XinMeng [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Sent: Wednesday, September 27, 2006 10:12 AM
Subject: [R] exact 95% confidence intervals


 Hello sir:
 As to the 2*2 table format for reporting results comparing a new 
 test to true diagnosis,when I got the sensitivity and 
 specificity,how can I calculate the exact 95% confidence intervals 
 (based on the binomial distribution) for sensitivity and specificity 
 via R?

 Thanks a  lot!

 My best!



 --
 ***
 Xin Meng
 Capitalbio Corporation
 National Engineering Research Center
 for Beijing Biochip Technology
 BioPharma-informatics  Software Dept.
 Research Engineer
 Tel: +86-10-80715888/80726868-6438
 Fax: +86-10-80726790
 [EMAIL PROTECTED]
 Address:18 Life Science Parkway,
 Changping District, Beijing 102206, China







 __
 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] equivalent of model.tables for an lm.object?

2006-09-27 Thread Chuck Cleland
Henrik Parn wrote:
 Dear all,
 
 I run a linear model with three significant explanatory variabels
 x1: a factor with 4 levels
 x2 and x3: factors with two levels each
 x4: continuous
 
 model - lm(y ~ x1 + x2 * x3 + x4)
 
 The data is not perfectly balanced between the different 
 factor-combinations and I use treatment contrasts.
 
 With an aov.object, I assume I could have used model.tables(aov.object, 
 type = means, se = TRUE), to get the means and se for all factor 
 combinations.
 
 In an lm.object like mine, I calculate the means 'manually' from the 
 Estimates (for sure it could be done with a script, but fair enough). 
 For the standard error of the means, I started out using formulas of a 
 variance of a sum of two variables, but I messed things up with the 
 interaction. Is there a way to calculate the standard error of the means 
 from Estimates and Std.Error (or other information) from the lm.object?

You might have a look at the effects package by John Fox.

http://socserv.mcmaster.ca/jfox/Misc/effects/index.html

 
 
 Thanks in advance for any advice!
 
 Best regards,
 
 Henrik
 

-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

__
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] Searching for keyword values in a text (configuration) file

2006-09-27 Thread Andre Jung

Hi,

I would like to read values from an ASCII text file that contains 
information in the following format:


DEVICE = 'PC'
CPU_SPEED = '1999', '233'
...

It's like a config file.

How can I e.g. get R to read the 2nd value of CPU_SPEED?
How do I go through text files and search for keywords and their values?

Thanks a lot,
Andre
__
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] Searching for keyword values in a text (configuration) file

2006-09-27 Thread Andre Jung
Hi,

I would like to read values from an ASCII text file that contains
information in the following format:

DEVICE = 'PC'
CPU_SPEED = '1999', '233'
...

It's like a config file.

How can I e.g. get R to read the 2nd value of CPU_SPEED?
How do I go through text files and search for keywords and their values?

Thanks a lot,
Andre

__
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] exponential fitting

2006-09-27 Thread Gabor Grothendieck
 # using this test data
 set.seed(1)
 x - 1:20/20
 y - exp(2 + 3 * x) + rnorm(20)

 # if its ok to fit logs so that its linear
 exp(fitted(lm(log(y) ~ x)))
1 2 3 4 5 6 7 8
  8.55615   9.94692  11.56376  13.44340  15.62857  18.16894  21.12223  24.7
910111213141516
 28.54699  33.18720  38.58165  44.85295  52.14363  60.61938  70.47284  81.92793
   17181920
 95.24501 110.72673 128.72494 149.64869

 # or to do it on original scale use linear coefs as starting values
 cc - coef(lm(log(y) ~ x))
 fitted(nls(y ~ exp(a + b*x), start = list(a = cc[1], b = cc[2])))
 [1]   8.592270   9.984536  11.602401  13.482421  15.667073  18.205720
 [7]  21.155722  24.583734  28.567211  33.196159  38.575168  44.825776
[13]  52.089214  60.529599  70.337640  81.734946  94.979039 110.369167
[19] 128.253066 149.034820
attr(,label)
[1] Fitted values

On 9/27/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 Hi,

 I would like to fit some experimental points by a exponential function.
 I ignore the parameters of this exponential and what I would like is to
 ask R to calculate the best fitting curve an the associated parameters (as
 the linear model function (lm) does for linear models).
 Is it possible ?
 Do anyone have an idea about how to do that ?

 Thanks by advance

 Jessica Gervais


[[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] exact 95% confidence intervals

2006-09-27 Thread Peter Dalgaard
Frank E Harrell Jr [EMAIL PROTECTED] writes:

 Peter Dalgaard wrote:
  XinMeng [EMAIL PROTECTED] writes:
 
  Hello sir:
 
  As to the 2*2 table format for reporting results comparing a new
  test to true diagnosis,when I got the sensitivity and
  specificity,how can I calculate the exact 95% confidence intervals
  (based on the binomial distribution) for sensitivity and specificity
  via R?
  Just run binom.test on the data from each column (or row, depending
  on
  which way you turn the tables).
 
 
 But beware of exact binomial intervals - they are often not very
 accurate.  Wilson and other intervals are generally better.  For
 example see the binconf function in the Hmisc package.

I suppose that by accurate you mean that they are generally better
at getting the coverage rate right? 

The exact intervals are strictly conservative, but at least
predictably so. The whole thing is largely a matter of taste to my
mind, but I know that other people (notably Alan Agresti) have
stronger opinions.

(People taking an interest in this may want to have a look at
http://en.wikipedia.org/wiki/Binomial_proportion_confidence_interval )

-- 
   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] Impossible to merge with a zero rows data frame?

2006-09-27 Thread Petr Pikal
Hi

you have two options:

change the source code for merge 
or use some modified function like

my.merge - function(x,y, ...) if(all(dim(x)[1]0, dim(y)[1]0)) 
merge(x,y) else print (No merge or whatever action which is 
suitable)

HTH
Petr

On 27 Sep 2006 at 11:55, Bonfigli Sandro wrote:

Date sent:  Wed, 27 Sep 2006 11:55:44 +0200
From:   Bonfigli Sandro [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Subject:[R] Impossible to merge with a zero rows data frame?

 I'm trying to merge two data frames. One of them is a zero rows data
 frame. I'm using the merge parameter 'all.x = TRUE' so I'd expect to
 obtain all the rows of x. In fact the merge help says:
 
 all.x: logical; if 'TRUE', then extra rows will be added to the
   output, one for each row in 'x' that has no matching row in
   'y'.  These rows will have 'NA's in those columns that are
   usually filled with values from 'y'.
 
 To let you test the problem here is some code:
 
  L3 - LETTERS[1:3]
  (d - data.frame(cbind(x=1, y=1), fac=sample(L3, 1, repl=TRUE))) e
  - d[-1,]
 
 so now we have that:
  e
 [1] x   y   fac
 0 rows (or 0-length row.names)
 
 here is the merge:
  merge(d, e, by.x = c(x), by.y = c(x), all.x = TRUE)
 
 I'd expect something like:
   x y.x fac.x y.y fac.y
 1 1   1 B  NANA
 instead of:
 Error in merge.data.frame(d, e, by.x = c(x), by.y = c(x), all.x =
 TRUE) : 
 no row to correspond
 (I'm traslating the error message, so it could be a little different)
 
 My questions are:
 Is there a way to obtain my desired result? In the context in which
 I'd like to use the code the second data frame is the result of a
 query and a lot of overwork would be added if I have to check if the
 dataframe is a zero rows one BEFORE the merge (in fact I do a sequence
 of several merge) Is this behaviour of the merge command correct? Why
 did the developers choose it?
 
 P.S.: I tested this code both in R 2.3.0 and in 2.3.1
 
 Thank you in advance.
Sandro Bonfigli
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html and provide commented,
 minimal, self-contained, reproducible code.

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] Searching for keyword values in a text (configuration) file

2006-09-27 Thread Gabor Grothendieck
Read in data using readLines and replace
= with comma and delete all spaces.
Then reread using read.table and set the
rownames to column 1 removing column 1.

# test data
Lines0 - DEVICE = 'PC'
CPU_SPEED = '1999', '233'


# if reading from a file then
# replace next line with something like Lines - readLines(myfile.dat)
Lines - readLines(textConnection(Lines0))
Lines - gsub(=, ,, Lines)
Lines - gsub( , , Lines)
DF - read.table(textConnection(Lines), sep = ,, fill = TRUE,
colClasses = character, header = FALSE)
rownames(DF) - DF[,1]
DF - DF[,-1]

DF[CPU_SPEED, 2]





On 9/27/06, Andre Jung [EMAIL PROTECTED] wrote:
 Hi,

 I would like to read values from an ASCII text file that contains
 information in the following format:

 DEVICE = 'PC'
 CPU_SPEED = '1999', '233'
 ...

 It's like a config file.

 How can I e.g. get R to read the 2nd value of CPU_SPEED?
 How do I go through text files and search for keywords and their values?

 Thanks a lot,
 Andre

 __
 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] Testing the equality of correlations

2006-09-27 Thread Marc Bernard
Dear All, 
   
  I wonder if there is any  implemented statistical test in R to test the  
equality between many correlations. As an example, let X1, X2, X3 X4 be four 
random  variables.  let 
  Phi(X1,X2) , Phi(X1,X3) and Phi(X1,X4) be the corresponding correlations.  
  How to test Phi(X1,X2) = Phi(X1,X3) = P(X1,X4)?
   
  Many thanks in advance,
   
  Bernard
   
   
   
   


-

[[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] Searching for keyword values in a text (configuration) file

2006-09-27 Thread David Barron
Something like this?

 library(Hmisc)
 t - readLines(clipboard)
 t
[1] DEVICE = 'PC' CPU_SPEED = '1999', '233'

 ix - grep(CPU_SPEED,t)
 loc - substring.location(t[ix],,)
 cpu - substring(t[ix],loc$first+2)
 cpu
[1] '233'


On 27/09/06, Andre Jung [EMAIL PROTECTED] wrote:
 Hi,

 I would like to read values from an ASCII text file that contains
 information in the following format:

 DEVICE = 'PC'
 CPU_SPEED = '1999', '233'
 ...

 It's like a config file.

 How can I e.g. get R to read the 2nd value of CPU_SPEED?
 How do I go through text files and search for keywords and their values?

 Thanks a lot,
 Andre

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



-- 
=
David Barron
Said Business School
University of Oxford
Park End Street
Oxford OX1 1HP

__
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] Searching for keyword values in a text (configuration) file

2006-09-27 Thread Gabor Grothendieck
Here is one more solution using the same Lines0 from last time.
This one uses strapply from gsubfn to pick out all the fields in
each line creating a list named by the keywords (rather than
a data frame as in the previous solution).  The names of the
components are the keywords so we remove them from
the contents of the list itself since we don't need them twice:

library(gsubfn)

# replace next line with something like Lines - readLines(myfile.dat)
Lines - readLines(textConnection(Lines0))

parms - strapply(Lines, [^ ',=]+, c, USE.NAMES = TRUE)
parms - lapply(parms, [, -1)

parms[[CPU_SPEED]][2]



On 9/27/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
 Read in data using readLines and replace
 = with comma and delete all spaces.
 Then reread using read.table and set the
 rownames to column 1 removing column 1.

 # test data
 Lines0 - DEVICE = 'PC'
 CPU_SPEED = '1999', '233'
 

 # if reading from a file then
 # replace next line with something like Lines - readLines(myfile.dat)
 Lines - readLines(textConnection(Lines0))
 Lines - gsub(=, ,, Lines)
 Lines - gsub( , , Lines)
 DF - read.table(textConnection(Lines), sep = ,, fill = TRUE,
colClasses = character, header = FALSE)
 rownames(DF) - DF[,1]
 DF - DF[,-1]

 DF[CPU_SPEED, 2]





 On 9/27/06, Andre Jung [EMAIL PROTECTED] wrote:
  Hi,
 
  I would like to read values from an ASCII text file that contains
  information in the following format:
 
  DEVICE = 'PC'
  CPU_SPEED = '1999', '233'
  ...
 
  It's like a config file.
 
  How can I e.g. get R to read the 2nd value of CPU_SPEED?
  How do I go through text files and search for keywords and their values?
 
  Thanks a lot,
  Andre
 
  __
  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] PDE

2006-09-27 Thread Christophe Nguyen
Dear all,
Does any know how to solve PDE with R? The archive list refers to the 
use of ODE if PDE are parabolic. I am not a mathematician and this does 
not mean anything for me!
help would be very appreciated.
Many thanks

-- 
___

Christophe NGUYEN

UMR 1220 INRA-ENITAB
Transfert sol-plante et cycle des éléments minéraux
dans les écosystèmes cultivés

Centre INRA de Bordeaux-Aquitaine
71, avenue Edouard Bourlaux, BP 81
33883 Villenave d'Ornon, FRANCE

Tel : 00 33 (0)5 57 12 25 07
Fax : 00 33 (0)5 57 12 25 15

email : [EMAIL PROTECTED]
page infoservice: http://www.bordeaux.inra.fr/tcem

__m°O°m

__
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] Searching for keyword values in a text (configuration) file

2006-09-27 Thread Gabor Grothendieck
Here is a slight simplification of this one using row.names= in
the read.table to avoid the subsequent manipulations.  We
use Lines0 defined in the earlier post:


# replace next line with something like Lines - readLines(myfile.dat)
Lines - readLines(textConnection(Lines0))

Lines - gsub(=, ,, Lines)
Lines - gsub( , , Lines)

DF - read.table(textConnection(Lines), row.names = 1, sep = ,, fill = TRUE,
   colClasses = character, header = FALSE)

DF[CPU_SPEED, 2]


On 9/27/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
 Read in data using readLines and replace
 = with comma and delete all spaces.
 Then reread using read.table and set the
 rownames to column 1 removing column 1.

 # test data
 Lines0 - DEVICE = 'PC'
 CPU_SPEED = '1999', '233'
 

 # if reading from a file then
 # replace next line with something like Lines - readLines(myfile.dat)
 Lines - readLines(textConnection(Lines0))
 Lines - gsub(=, ,, Lines)
 Lines - gsub( , , Lines)
 DF - read.table(textConnection(Lines), sep = ,, fill = TRUE,
colClasses = character, header = FALSE)
 rownames(DF) - DF[,1]
 DF - DF[,-1]

 DF[CPU_SPEED, 2]





 On 9/27/06, Andre Jung [EMAIL PROTECTED] wrote:
  Hi,
 
  I would like to read values from an ASCII text file that contains
  information in the following format:
 
  DEVICE = 'PC'
  CPU_SPEED = '1999', '233'
  ...
 
  It's like a config file.
 
  How can I e.g. get R to read the 2nd value of CPU_SPEED?
  How do I go through text files and search for keywords and their values?
 
  Thanks a lot,
  Andre
 
  __
  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] t-stat Curve

2006-09-27 Thread Isaac Barjis
Number of subjects = 25
Mean of Sample = 77
Standard Deviation (s) = 12
sem = 2.4
df = 24

The claim is that population mean is less than 80
*  80
So our H0 (null hupotheis) is *  80


 qt(.95,24)
[1] 1.710882
 qt(0.05, 24)
[1] -1.710882

tstat = -1.25 on t24 falls between 1.711 (.95,24) and *1.711 (.005,24)


How Could I sketch t curve for the above data where my * would be at the center?

Best Regards
Isaac

Dr. I. Barjis
Assistant Professor
Summer and Evening Coordinator
Department of  Biological Sciences
Room P313
300 Jay Street
Brooklyn, NY 11201

Phone: (718)2605285
Fax: (718)2548680
Fax: (718) 254-8595 Department Office
http://websupport1.citytech.cuny.edu/Faculty/ibarjis



BEGIN:VCARD
VERSION:2.1
X-GWTYPE:USER
FN:Isaac Barjis
ORG:;Physical  Biological Sciences
EMAIL;WORK;PREF;NGW:[EMAIL PROTECTED]
N:Barjis;Isaac
TITLE:Assistant Professor
END:VCARD

BEGIN:VCARD
VERSION:2.1
X-GWTYPE:USER
FN:Isaac Barjis
ORG:;Physical  Biological Sciences
EMAIL;WORK;PREF;NGW:[EMAIL PROTECTED]
N:Barjis;Isaac
TITLE:Assistant Professor
END:VCARD

__
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] Testing the equality of correlations

2006-09-27 Thread Paul Hewson
Marc,

Off the top my head (i.e. this could all be horribly wrong), I think
Anderson gave an asymptotic version for such a test, whereby under the
null hypothesis, the difference between Fisher's z for each sample, z1 -
z2, is normal with zero mean.   If I recall correctly, the 1984 edition
gave a test statistic something like:
 
 $\frac{\vert z_{1} - z_{2} \rvert}{ \sqrt{\frac{1}{N_{1} - 3} +
\frac{1}{N_{2} - 3}}}$, 

as the test.   I ***think*** N = n+1.   Assuming that part is correct,
it can be coded up quite simply (and crudely and hopefully correctly)
as:

## estimate Fisher's z for the sample
fishz - function(x1,x2){
r - cor(x1,x2)
z - 0.5 * log( (1+r)/(1-r) )
 }

## apply the correlation test
cortest - function(x1,x2,x3,x4){
   numer - abs(fishz(x1,x2) - fishz(x3,x4) )
   denom - sqrt( 1/( length(x1) - 2) + 1/( length(x2) - 2) )
   test.stat - numer / denom
return(test.stat)
}


A quick demo with some simulated data:

require(MASS)
X1 - mvrnorm(1000, c(0,0), matrix(c(1,0.7,0.7,1),2,2))
X2 - mvrnorm(1000, c(0,0), matrix(c(1,0.9,0.9,1),2,2))

cortest(X1[,1], X1[,2], X2[,1], X2[,2])

Is above 1.96 indicating they are different

X2 - mvrnorm(1000, c(0,0), matrix(c(1,0.7,0.7,1),2,2))
cortest(X1[,1], X1[,2], X2[,1], X2[,2])

Is below 1.96 indicating they are not different.   All that needs to be
done for these pair is to get the pooled estimate of the populations
Fisher's z $ \frac{ (N_{1} - 3)z_{1} + (N_{2} - 3)z_{2}}{N_{1} + N_{2} -
6}$ and solve fisher's z to get an estimate of rho.

Just dabbling around with this suggests either I've missed something, or
that we need quite a large sample size before the asymptotics are any
use.   If this is of any use I'll double check on N.

Paul


-=-=-=-=-=-=-=-=-=-=-=-=
Paul Hewson 
Lecturer in Statistics 
School of Mathematics and Statistics 
University of Plymouth 
Drake Circus 
Plymouth PL4 8AA 

tel (01752) 232778 (Campus) 
tel (01752) 764437 (Tamar Science Park) 
fax (01752) 232780 

email: [EMAIL PROTECTED]
web: http://www.plymouth.ac.uk/staff/phewson
-=-=-=-=-=-=-=-=-=-=-=-=




-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Marc Bernard
Sent: 27 September 2006 14:42
To: r-help@stat.math.ethz.ch
Subject: [R] Testing the equality of correlations


Dear All, 
   
  I wonder if there is any  implemented statistical test in R to test
the  equality between many correlations. As an example, let X1, X2, X3
X4 be four random  variables.  let 
  Phi(X1,X2) , Phi(X1,X3) and Phi(X1,X4) be the corresponding
correlations.  
  How to test Phi(X1,X2) = Phi(X1,X3) = P(X1,X4)?
   
  Many thanks in advance,
   
  Bernard
   
   
   
   


-

[[alternative HTML version deleted]]

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

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


[R] multidimensional lists

2006-09-27 Thread Evan Cooch
In the process of moving a number of my scripts from MATLAB - R, I've 
discovered that there is no 'pure' equivalent of MATLAB's cell arrays, 
which I use quite often. Basically, I create matrices (as a cell array) 
where each element of the matrix is itself a matrix (e.g., 2x2 cell 
array where each element of the array is another matrix). I pass these 
cell arrays to various functions which then do clever things with the 
various matrices (of course) - basically, I need to be able to pass 
collections of matrices to functions to do various things, and I need to 
be able to control the dimensionality of the cell array to preserve some 
structural relationships among the matrices in the array. The cell array 
in MATLAB handles this with aplomb.

So far, in R, I've used lists. Given (say) 4 matrices (A,B,C,D), in 
MATLAB I can use

test={A,B,C,D} for a row vector cell array, or

test={A;B;C;D} for a column vector cell array.

In R, I get more or less the same thing using

test=list(A,B,C,D)

but this only gives me a row list. For a bunch of technical reasons, I 
need to be able to control the orientation (as noted)- this is 
especially true for n-dimensional cell arrays. In MATLAB, for example, I 
could generate a (say) 2x2 cell array using

test={A B;C D}

The only way I can figure out how to do this in R is using something like

test=list(A,B,C,D);
dim(test)  c(2,2);

This seems to work, but defaults to bycolumn (in other words, instead of   

A  B
C  D

I get

A  C
B  D

)

So, I follow with

test=t(test) as needed to flip the thing around to byrow.

OK, so the question is - is there a better way? This *seems* to work, 
but I'm discovering that R is a lot like working with LaTeX (something I 
know much more about) - you can do most things, but there is often a 
more elegant way if you can figure out how to find out about it.

Thanks in advance...

__
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] t-stat Curve

2006-09-27 Thread Nordlund, Dan (DSHS)
 -Original Message-
 From: [EMAIL PROTECTED] [mailto:r-help-
 [EMAIL PROTECTED] On Behalf Of Isaac Barjis
 Sent: Wednesday, September 27, 2006 8:08 AM
 To: R-help@stat.math.ethz.ch
 Subject: [R] t-stat Curve
 
 Number of subjects = 25
 Mean of Sample = 77
 Standard Deviation (s) = 12
 sem = 2.4
 df = 24
 
 The claim is that population mean is less than 80
 *  80
 So our H0 (null hupotheis) is *  80
 
 
  qt(.95,24)
 [1] 1.710882
  qt(0.05, 24)
 [1] -1.710882
 
 tstat = -1.25 on t24 falls between 1.711 (.95,24) and *1.711 (.005,24)
 
 
 How Could I sketch t curve for the above data where my * would be at the
 center?
 
 Best Regards
 Isaac
 
 Dr. I. Barjis
 Assistant Professor
 Summer and Evening Coordinator
 Department of  Biological Sciences


Isaac,

I'm not sure that what you are asking for is reasonable (or possible).  It
is the sampling distribution of your t-statistic that is distributed as t
under the null hypothesis, not your observed data.  Could you clarify what
it is you wish to do?

Dan

Daniel J. Nordlund
Research and Data Analysis
Washington State Department of Social and Health Services
Olympia, WA  98504-5204

__
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] package e1071 - class probabilities

2006-09-27 Thread Vincent Negre
Hello,
I use the package e1071 for svm classification. I would like to get 
probabilities associated with predictions.
But when I change the argument 'probability' (TRUE or FALSE) in functions 
svm.model() and predict() , I don't have the same prediction. 
Do you know why there are these differences?

Thank you in advance for your help.
Best regards.
Vincent.




-

[[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] multidimensional lists

2006-09-27 Thread Prof Brian Ripley
matrix(some_list, nr, nc, byrow=TRUE)  may be what you are looking for.

R arrays can be of any vector type, including list.  I'd get used to R's 
Fortran ordering rather than force transposes all the time.

On Wed, 27 Sep 2006, Evan Cooch wrote:

 In the process of moving a number of my scripts from MATLAB - R, I've
 discovered that there is no 'pure' equivalent of MATLAB's cell arrays,
 which I use quite often. Basically, I create matrices (as a cell array)
 where each element of the matrix is itself a matrix (e.g., 2x2 cell
 array where each element of the array is another matrix). I pass these
 cell arrays to various functions which then do clever things with the
 various matrices (of course) - basically, I need to be able to pass
 collections of matrices to functions to do various things, and I need to
 be able to control the dimensionality of the cell array to preserve some
 structural relationships among the matrices in the array. The cell array
 in MATLAB handles this with aplomb.

 So far, in R, I've used lists. Given (say) 4 matrices (A,B,C,D), in
 MATLAB I can use

 test={A,B,C,D} for a row vector cell array, or

 test={A;B;C;D} for a column vector cell array.

 In R, I get more or less the same thing using

 test=list(A,B,C,D)

 but this only gives me a row list. For a bunch of technical reasons, I
 need to be able to control the orientation (as noted)- this is
 especially true for n-dimensional cell arrays. In MATLAB, for example, I
 could generate a (say) 2x2 cell array using

 test={A B;C D}

 The only way I can figure out how to do this in R is using something like

 test=list(A,B,C,D);
 dim(test)  c(2,2);

 This seems to work, but defaults to bycolumn (in other words, instead of

 A  B
 C  D

 I get

 A  C
 B  D

 )

 So, I follow with

 test=t(test) as needed to flip the thing around to byrow.

 OK, so the question is - is there a better way? This *seems* to work,
 but I'm discovering that R is a lot like working with LaTeX (something I
 know much more about) - you can do most things, but there is often a
 more elegant way if you can figure out how to find out about it.

 Thanks in advance...

 __
 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] multidimensional lists

2006-09-27 Thread Gabor Grothendieck
Try this:

AA - matrix(list(A, 10*A, 100*A, 1000*A), 2, byrow = TRUE)
AA[1,2]


On 9/27/06, Evan Cooch [EMAIL PROTECTED] wrote:
 In the process of moving a number of my scripts from MATLAB - R, I've
 discovered that there is no 'pure' equivalent of MATLAB's cell arrays,
 which I use quite often. Basically, I create matrices (as a cell array)
 where each element of the matrix is itself a matrix (e.g., 2x2 cell
 array where each element of the array is another matrix). I pass these
 cell arrays to various functions which then do clever things with the
 various matrices (of course) - basically, I need to be able to pass
 collections of matrices to functions to do various things, and I need to
 be able to control the dimensionality of the cell array to preserve some
 structural relationships among the matrices in the array. The cell array
 in MATLAB handles this with aplomb.

 So far, in R, I've used lists. Given (say) 4 matrices (A,B,C,D), in
 MATLAB I can use

 test={A,B,C,D} for a row vector cell array, or

 test={A;B;C;D} for a column vector cell array.

 In R, I get more or less the same thing using

 test=list(A,B,C,D)

 but this only gives me a row list. For a bunch of technical reasons, I
 need to be able to control the orientation (as noted)- this is
 especially true for n-dimensional cell arrays. In MATLAB, for example, I
 could generate a (say) 2x2 cell array using

 test={A B;C D}

 The only way I can figure out how to do this in R is using something like

 test=list(A,B,C,D);
 dim(test)  c(2,2);

 This seems to work, but defaults to bycolumn (in other words, instead of

 A  B
 C  D

 I get

 A  C
 B  D

 )

 So, I follow with

 test=t(test) as needed to flip the thing around to byrow.

 OK, so the question is - is there a better way? This *seems* to work,
 but I'm discovering that R is a lot like working with LaTeX (something I
 know much more about) - you can do most things, but there is often a
 more elegant way if you can figure out how to find out about it.

 Thanks in advance...

 __
 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] panel.curve

2006-09-27 Thread jessica . gervais
Hi,

I am trying to fit experimental points by exponemtial curve

my data are stored into a matrix data

the first column is the geographical point (a number = data[,1] ) ( I 
would like to plot several graphes at  the same time)
the second column is the time of measurement (x in the plot)
the third column is a speed (y in the plot)

if we assume the point are folowing this exponential behaviour y=exp(a+bx)
then log y = a+ bx
we then can determine the coefficient a and b by a linear regression with 
the lm function and get them as following : coef ( lm (log(y)~x)) 
then I can use those coefficient


if I plot ln y = ax+b , everything goes fine 

 
xyplot(log(data[,3])~data[,2]|data[,1],panel=function(x,y){panel.xyplot(x,y)+panel.abline(coef(lm(y~x)))})
and I get perfect linear regression of my points

...But I would prefer to plot the exponential curves (y=exp ( a*x + b ))..
I tried the following formula :

 
xyplot(data[,3]~data[,2]|data[,1],panel=function(x,y){panel.xyplot(x,y)+panel.curve(coef(lm(log(y)~x))[1])})

and I get : 
Error in model.frame(formula, rownames, variables, varnames, extras, 
extranames,  :
variable lengths differ (found for 'x')

... I don't really now what goes wrong and how to correct that
Maybe I am wrong in the use of the pannel.curve function  

Do anyone know something about that ? 


Thanks by advance

Jessica Gervais
 




[[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] t-stat Curve

2006-09-27 Thread Charles Annis, P.E.
Isaac:

You will likely find something helpful here:
http://addictedtor.free.fr/graphiques/thumbs.php

I also recently came across this code (I thought it was at the URL above,
but I can't find it now) that may be useful with modification.

I apologize to the code-writer for having lost the correct reference. (If
anyone finds it, please send the reference to me. Thanks.)
#

# neighboring (not overlapping) normal densities
dev.off() 
x-seq(-10,10,length=400)
y1-dnorm(x)
y2-dnorm(x,m=3)
par(mar=c(5,4,2,1))
plot(x, y2, xlim=c(-3,8), type=n, xlab=quote(Z==frac(mu[1]-mu[2],
 sigma/sqrt(n))), ylab=Density)
polygon(c(1.96,1.96,x[240:400],10), c(0,dnorm(1.96,m=3),y2[240:400],0),
 col=grey80, lty=0)
lines(x, y2)
lines(x, y1)
polygon(c(-1.96,-1.96,x[161:1],-10), c(0,dnorm(-1.96,m=0), y1[161:1],0),
 col=grey30, lty=0)
polygon(c(1.96, 1.96, x[240:400], 10), c(0,dnorm(1.96,m=0),
 y1[240:400],0), col=grey30)
legend(4.2, .4, fill=c(grey80,grey30),
  legend=expression(P(abs(phantom(i)*Z*phantom(i))1.96,
H[1])==0.85,
  P(abs(phantom(i)*Z*phantom(i))1.96,H[0])==0.05), bty=n)
text(0, .2, quote(H[0]:~~mu[1]==mu[2]))
text(3, .2, quote(H[1]:~~mu[1]==mu[2]+delta))

#


Charles Annis, P.E.

[EMAIL PROTECTED]
phone: 561-352-9699
eFax:  614-455-3265
http://www.StatisticalEngineering.com
 
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Isaac Barjis
Sent: Wednesday, September 27, 2006 11:08 AM
To: R-help@stat.math.ethz.ch
Subject: [R] t-stat Curve

Number of subjects = 25
Mean of Sample = 77
Standard Deviation (s) = 12
sem = 2.4
df = 24

The claim is that population mean is less than 80
*  80
So our H0 (null hupotheis) is *  80


 qt(.95,24)
[1] 1.710882
 qt(0.05, 24)
[1] -1.710882

tstat = -1.25 on t24 falls between 1.711 (.95,24) and *1.711 (.005,24)


How Could I sketch t curve for the above data where my * would be at the
center?

Best Regards
Isaac

Dr. I. Barjis
Assistant Professor
Summer and Evening Coordinator
Department of  Biological Sciences
Room P313
300 Jay Street
Brooklyn, NY 11201

Phone: (718)2605285
Fax: (718)2548680
Fax: (718) 254-8595 Department Office
http://websupport1.citytech.cuny.edu/Faculty/ibarjis

__
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] panel.curve

2006-09-27 Thread Gabor Grothendieck
Look at the arguments to panel.curve

   ?panel.curve

and try RSiteSearch(panel.curve) for some examples.


On 9/27/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 Hi,

 I am trying to fit experimental points by exponemtial curve

 my data are stored into a matrix data

 the first column is the geographical point (a number = data[,1] ) ( I
 would like to plot several graphes at  the same time)
 the second column is the time of measurement (x in the plot)
 the third column is a speed (y in the plot)

 if we assume the point are folowing this exponential behaviour y=exp(a+bx)
 then log y = a+ bx
 we then can determine the coefficient a and b by a linear regression with
 the lm function and get them as following : coef ( lm (log(y)~x))
 then I can use those coefficient


 if I plot ln y = ax+b , everything goes fine


 xyplot(log(data[,3])~data[,2]|data[,1],panel=function(x,y){panel.xyplot(x,y)+panel.abline(coef(lm(y~x)))})
 and I get perfect linear regression of my points

 ...But I would prefer to plot the exponential curves (y=exp ( a*x + b ))..
 I tried the following formula :

 
 xyplot(data[,3]~data[,2]|data[,1],panel=function(x,y){panel.xyplot(x,y)+panel.curve(coef(lm(log(y)~x))[1])})

 and I get :
 Error in model.frame(formula, rownames, variables, varnames, extras,
 extranames,  :
variable lengths differ (found for 'x')

 ... I don't really now what goes wrong and how to correct that
 Maybe I am wrong in the use of the pannel.curve function 

 Do anyone know something about that ?


 Thanks by advance

 Jessica Gervais





[[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] multidimensional lists

2006-09-27 Thread Evan Cooch
Prof Brian Ripley wrote:
 matrix(some_list, nr, nc, byrow=TRUE)  may be what you are looking for.

 R arrays can be of any vector type, including list.  I'd get used to 
 R's Fortran ordering rather than force transposes all the time.

Thanks very much. And I thought I'd left some aspects of my FORTRAN 
coding experience in the past. Would seem not.

__
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] multidimensional lists

2006-09-27 Thread Evan Cooch
Gabor Grothendieck wrote:
 Try this:

 AA - matrix(list(A, 10*A, 100*A, 1000*A), 2, byrow = TRUE)
 AA[1,2]


Seems to do the trick. Thanks!

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


Re: [R] exact 95% confidence intervals

2006-09-27 Thread Frank E Harrell Jr
Peter Dalgaard wrote:
 Frank E Harrell Jr [EMAIL PROTECTED] writes:
 
 Peter Dalgaard wrote:
 XinMeng [EMAIL PROTECTED] writes:

 Hello sir:
 As to the 2*2 table format for reporting results comparing a new
 test to true diagnosis,when I got the sensitivity and
 specificity,how can I calculate the exact 95% confidence intervals
 (based on the binomial distribution) for sensitivity and specificity
 via R?
 Just run binom.test on the data from each column (or row, depending
 on
 which way you turn the tables).

 But beware of exact binomial intervals - they are often not very
 accurate.  Wilson and other intervals are generally better.  For
 example see the binconf function in the Hmisc package.
 
 I suppose that by accurate you mean that they are generally better
 at getting the coverage rate right? 

Yes

 
 The exact intervals are strictly conservative, but at least
 predictably so. The whole thing is largely a matter of taste to my
 mind, but I know that other people (notably Alan Agresti) have
 stronger opinions.

I tend to side with Agresti, and emphasize the expected absolute error 
in confidence coverage.

 
 (People taking an interest in this may want to have a look at
 http://en.wikipedia.org/wiki/Binomial_proportion_confidence_interval )

nice to know!

Frank

__
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] multidimensional lists

2006-09-27 Thread Gabor Grothendieck
Just one other comment if the matrices have the same dimensions:
they could alternately be represented as a 4d array:

   A - matrix(1:4, 2)

   AA - matrix(list(A, 10*A, 100*A, 1000*A), 2, byrow = TRUE)
   AA[1,2]

   AAA - array(unlist(AA), c(2,2,2,2))
   AAA[,,1,2] # same

This could have an advantage if you need to do things like
easily take the top left element of each matrix,

   AAA[1,1,,]

which in terms of AA would have required the longer expression:

   replace(AA, TRUE, lapply(AA, [, 1, 1))


On 9/27/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
 Try this:

 AA - matrix(list(A, 10*A, 100*A, 1000*A), 2, byrow = TRUE)
 AA[1,2]


 On 9/27/06, Evan Cooch [EMAIL PROTECTED] wrote:
  In the process of moving a number of my scripts from MATLAB - R, I've
  discovered that there is no 'pure' equivalent of MATLAB's cell arrays,
  which I use quite often. Basically, I create matrices (as a cell array)
  where each element of the matrix is itself a matrix (e.g., 2x2 cell
  array where each element of the array is another matrix). I pass these
  cell arrays to various functions which then do clever things with the
  various matrices (of course) - basically, I need to be able to pass
  collections of matrices to functions to do various things, and I need to
  be able to control the dimensionality of the cell array to preserve some
  structural relationships among the matrices in the array. The cell array
  in MATLAB handles this with aplomb.
 
  So far, in R, I've used lists. Given (say) 4 matrices (A,B,C,D), in
  MATLAB I can use
 
  test={A,B,C,D} for a row vector cell array, or
 
  test={A;B;C;D} for a column vector cell array.
 
  In R, I get more or less the same thing using
 
  test=list(A,B,C,D)
 
  but this only gives me a row list. For a bunch of technical reasons, I
  need to be able to control the orientation (as noted)- this is
  especially true for n-dimensional cell arrays. In MATLAB, for example, I
  could generate a (say) 2x2 cell array using
 
  test={A B;C D}
 
  The only way I can figure out how to do this in R is using something like
 
  test=list(A,B,C,D);
  dim(test)  c(2,2);
 
  This seems to work, but defaults to bycolumn (in other words, instead of
 
  A  B
  C  D
 
  I get
 
  A  C
  B  D
 
  )
 
  So, I follow with
 
  test=t(test) as needed to flip the thing around to byrow.
 
  OK, so the question is - is there a better way? This *seems* to work,
  but I'm discovering that R is a lot like working with LaTeX (something I
  know much more about) - you can do most things, but there is often a
  more elegant way if you can figure out how to find out about it.
 
  Thanks in advance...
 
  __
  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] multidimensional lists

2006-09-27 Thread Evan Cooch
Gabor Grothendieck wrote:
 Just one other comment if the matrices have the same dimensions:

Indeed - that is quite often the case - thanks for the further 
suggestion(s).

 they could alternately be represented as a 4d array:

   A - matrix(1:4, 2)

   AA - matrix(list(A, 10*A, 100*A, 1000*A), 2, byrow = TRUE)
   AA[1,2]

   AAA - array(unlist(AA), c(2,2,2,2))
   AAA[,,1,2] # same

 This could have an advantage if you need to do things like
 easily take the top left element of each matrix,

   AAA[1,1,,]

 which in terms of AA would have required the longer expression:

   replace(AA, TRUE, lapply(AA, [, 1, 1))


 On 9/27/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
 Try this:

 AA - matrix(list(A, 10*A, 100*A, 1000*A), 2, byrow = TRUE)
 AA[1,2]


 On 9/27/06, Evan Cooch [EMAIL PROTECTED] wrote:
  In the process of moving a number of my scripts from MATLAB - R, I've
  discovered that there is no 'pure' equivalent of MATLAB's cell arrays,
  which I use quite often. Basically, I create matrices (as a cell 
 array)
  where each element of the matrix is itself a matrix (e.g., 2x2 cell
  array where each element of the array is another matrix). I pass these
  cell arrays to various functions which then do clever things with the
  various matrices (of course) - basically, I need to be able to pass
  collections of matrices to functions to do various things, and I 
 need to
  be able to control the dimensionality of the cell array to preserve 
 some
  structural relationships among the matrices in the array. The cell 
 array
  in MATLAB handles this with aplomb.
 
  So far, in R, I've used lists. Given (say) 4 matrices (A,B,C,D), in
  MATLAB I can use
 
  test={A,B,C,D} for a row vector cell array, or
 
  test={A;B;C;D} for a column vector cell array.
 
  In R, I get more or less the same thing using
 
  test=list(A,B,C,D)
 
  but this only gives me a row list. For a bunch of technical reasons, I
  need to be able to control the orientation (as noted)- this is
  especially true for n-dimensional cell arrays. In MATLAB, for 
 example, I
  could generate a (say) 2x2 cell array using
 
  test={A B;C D}
 
  The only way I can figure out how to do this in R is using 
 something like
 
  test=list(A,B,C,D);
  dim(test)  c(2,2);
 
  This seems to work, but defaults to bycolumn (in other words, 
 instead of
 
  A  B
  C  D
 
  I get
 
  A  C
  B  D
 
  )
 
  So, I follow with
 
  test=t(test) as needed to flip the thing around to byrow.
 
  OK, so the question is - is there a better way? This *seems* to work,
  but I'm discovering that R is a lot like working with LaTeX 
 (something I
  know much more about) - you can do most things, but there is often a
  more elegant way if you can figure out how to find out about it.
 
  Thanks in advance...
 
  __
  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] AIC Methods

2006-09-27 Thread Benjamin Zuckerberg

I am having trouble with getting AIC statistics.  I have developed a  
number of ancova models using the lm function.  I am trying to get a  
number of AIC statistics suggested by Burnham and Anderson (2002)  
including raw AIC values, AICc values, Akaike weights, and Delta AIC.   
When I use the AIC function in (stats), I only get a single AIC value  
including degrees of freedom.  When I use the summary statement as  
suggested in the (aod) package, I do not get the resulting AIC  
statistics.  What am I doing wrong?  Is this a product of using the lm  
function for my models?  I have even investigated the use of  
extractAIC, but that does not provide me with the statistics I am  
looking for as well.  Do you have any suggestions?  In addition, I am  
also curious if there is a package or procedure for model averaging.

Thank you!

-- 
Benjamin Zuckerberg
Doctoral Candidate
State University of New York
College of Environmental Science and Forestry
Illick 244A, 1 Forestry Drive
Syracuse, New York 13210
Tele: (315) 470-6985
E-mail: [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] PDE

2006-09-27 Thread Ravi Varadhan
Hi Christophe,

What is the PDE that you are trying to solve?  Is it
parabolic/hyperbolic/elliptical/somethingelse?  Is it linear/nonlinear?  

If time is one of the independent variables, you can transform the PDE into
an initial value problem (system of ODEs) by using finite difference
approximations of the partial derivatives of other independent variables
(typically, these are spatial coordinates).  Starting with an initial set of
values on a grid of points (also known as initial conditions, which are part
of the problem specification), you update them at different times, using
fixed or varying time steps.

R has very limited functionality for handling differential equations.  So,
you should look for FORTRAN libraries, from which you can create DLLs to be
used in R.

Hope this help,
Ravi.


---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: [EMAIL PROTECTED]

Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html

 




-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Christophe Nguyen
Sent: Wednesday, September 27, 2006 10:39 AM
To: r-help@stat.math.ethz.ch
Subject: [R] PDE

Dear all,
Does any know how to solve PDE with R? The archive list refers to the 
use of ODE if PDE are parabolic. I am not a mathematician and this does 
not mean anything for me!
help would be very appreciated.
Many thanks

-- 
___

Christophe NGUYEN

UMR 1220 INRA-ENITAB
Transfert sol-plante et cycle des éléments minéraux
dans les écosystèmes cultivés

Centre INRA de Bordeaux-Aquitaine
71, avenue Edouard Bourlaux, BP 81
33883 Villenave d'Ornon, FRANCE

Tel : 00 33 (0)5 57 12 25 07
Fax : 00 33 (0)5 57 12 25 15

email : [EMAIL PROTECTED]
page infoservice: http://www.bordeaux.inra.fr/tcem

__m°O°m

__
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] Single Precision (4 byte) floats with readBin

2006-09-27 Thread Peter Lauren
I would like to use readBin to read a binary data
file.  Most of the data is 4-byte floating point but,
for some reason, only double precision appears to be
offered.  I tried 
fVariable=readBin(iFile,what=single());
and got 35.87879 which looks believable except that
the correct value is 3.030303.  I then tried
fVariable=readBin(iFile,what=single(),4);
and got 
[1]  3.83e+10  6.657199e+10 -5.592394e+29
-5.592397e+29

For the second call, there were two more single
precision floats of value 3.030303 followed by two
more with values 40.46 and 0.00 respectively.

Is there any way around this problem other than to
make the input data double (which I definitely do not
want to do)? 

Many thanks in advance,
Peter.

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


[R] how to retain time zone when doing c(POSIXct)

2006-09-27 Thread Sebastian P. Luque
Hello,

What is the best way to concatenate POSIXct objects keeping the time zone
attribute in a program?  For example:


R xx - as.POSIXct(strptime(c(2006-09-26 12:00:00, 2006-09-26 13:00:00),
+   format=%Y-%m-%d %H:%M:%S), tz=GMT)
R xx
[1] 2006-09-26 12:00:00 GMT 2006-09-26 13:00:00 GMT


but, as ?c.POSIXct explains:


R c(xx, xx[1] - 60, xx[2] + 60)
[1] 2006-09-26 07:00:00 CDT 2006-09-26 08:00:00 CDT
[3] 2006-09-26 06:59:00 CDT 2006-09-26 08:01:00 CDT


Is there something better/safer than simply setting the tzone attribute
of the new object?


Cheers,

-- 
Seb

__
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] Single Precision (4 byte) floats with readBin

2006-09-27 Thread Sundar Dorai-Raj


Peter Lauren said the following on 9/27/2006 3:11 PM:
 I would like to use readBin to read a binary data
 file.  Most of the data is 4-byte floating point but,
 for some reason, only double precision appears to be
 offered.  I tried 
 fVariable=readBin(iFile,what=single());
 and got 35.87879 which looks believable except that
 the correct value is 3.030303.  I then tried
 fVariable=readBin(iFile,what=single(),4);
 and got 
 [1]  3.83e+10  6.657199e+10 -5.592394e+29
 -5.592397e+29
 
 For the second call, there were two more single
 precision floats of value 3.030303 followed by two
 more with values 40.46 and 0.00 respectively.
 
 Is there any way around this problem other than to
 make the input data double (which I definitely do not
 want to do)? 
 
 Many thanks in advance,
 Peter.
 
 __
 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.


Hi, Peter,

I believe you can use

readBin(file, double(), size = 4)

Thanks,

--sundar

__
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] Single Precision (4 byte) floats with readBin

2006-09-27 Thread Peter Lauren

--- Sundar Dorai-Raj [EMAIL PROTECTED] wrote:

 
 
 Peter Lauren said the following on 9/27/2006 3:11
 PM:
  I would like to use readBin to read a binary data
  file.  Most of the data is 4-byte floating point
 but,
  for some reason, only double precision appears to
 be
  offered.  I tried 
  fVariable=readBin(iFile,what=single());
  and got 35.87879 which looks believable except
 that
  the correct value is 3.030303.  I then tried
  fVariable=readBin(iFile,what=single(),4);
  and got 
  [1]  3.83e+10  6.657199e+10 -5.592394e+29
  -5.592397e+29
  
  For the second call, there were two more single
  precision floats of value 3.030303 followed by two
  more with values 40.46 and 0.00 respectively.
  
  Is there any way around this problem other than to
  make the input data double (which I definitely do
 not
  want to do)? 
  
  Many thanks in advance,
  Peter.
  
  __
  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.
 
 
 Hi, Peter,
 
 I believe you can use
 
 readBin(file, double(), size = 4)
 

It worked!  Thanks very much.

Peter.

__
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] Converting text to numbers

2006-09-27 Thread Dan Chan
Hi,

I have Forecast Class and Observed Class in a data matrix as below. 

 Sample1
  FCT OBS
1   1  5 
2   2   4
3  3-  3+
4   3   3
5  3+  3-
6   4   2
7   5   1

I want to find the difference between Observed and Forecast Classes.
How can I get this done?

I tried to following to convert the 1 through 5 classes, to 1 through 7
for both OBS and FCT column.
 Sample1$OBS2 - Sample1$OBS
 levels(Sample1$OBS2) - sub('5',7,levels(Sample1$OBS2),fixed=TRUE)
 levels(Sample1$OBS2) - sub('4',6,levels(Sample1$OBS2),fixed=TRUE)
 levels(Sample1$OBS2) - sub('3+',5,levels(Sample1$OBS2), fixed=TRUE)
 levels(Sample1$OBS2) - sub('3',4,levels(Sample1$OBS2),fixed=TRUE)
 levels(Sample1$OBS2) - sub('4-',3,levels(Sample1$OBS2),fixed=TRUE)
 Sample1
  FCT OBS FCT2 OBS2
1   1  5 1   7 
2   2   426
3  3-  3+35
4   3   344
5  3+  3-53
6   4   262
7   5   171

All looks good, but as I do the following, I encounter an error.
 Sample1$OBS2- Sample1$FCT2
[1] NA NA NA NA NA NA NA
Warning message:
- not meaningful for factors in: Ops.factor(Sample1$OBS2, Sample1$FCT2)

Then, I tried to convert them to numbers using the following.
 Sample1$FCT2 - as.numeric(Sample1$FCT2)
 Sample1$OBS2 - as.numeric(Sample1$OBS2)
 Sample1
  FCT OBS FCT2 OBS2
1   1  5 17
2   2   426
3  3-  3+45
4   3   333
5  3+  3-54
6   4   262
7   5   171

Sample1$FCT2[3] and Sample1$FCT2[4] switched values. 

I think it has something to do with the following: 
 Sample1$OBS
[1] 5  4  3+ 3  3- 2   1
Levels:  1 2 3 3- 3+ 4 5 

But, I don't know why and how to fix it.

Any ideas? 

Thank you. 



Daniel Chan
Meteorologist
Georgia Forestry Commission
P O Box 819
Macon, GA 
31202
Tel: 478-751-3508
Fax: 478-751-3465

__
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] t-stat Curve

2006-09-27 Thread Richard M. Heiberger
## There is some ambiguity in your example.
## You stated a one-sided hypothesis and calculated qt() values for both sides.
## I show both the one-sided and two-sided displays.

library(HH)
## HH_1.5 is available from CRAN for R-2.3.1
##
## HH_1.5 ignores the df.t argument and interprets the request as a
## normal distribution.

## HH_1.8 has been accepted for CRAN for R-2.4.0 and will be in the
## standard places on CRAN when R-2.4.0 is released.
##
## HH_1.8 uses the df.t argument and interprets the request as a
## t-distribution.

old.par - par(oma=c(4,0,2,5), mar=c(7,7,4,2)+.1)

crit.val.t - qt(c(.05,.95), 24)
crit.val - crit.val.t*(12/sqrt(25)) + 80

observed.t - -1.25
observed.ybar - 77

norm.setup(mean=80, n=25, sd=12, df.t=24, xlim=c(70,90),
   main=two-sided alpha=.10)
norm.curve(mean=80, n=25, sd=12, df.t=24, crit=crit.val)
abline(v=observed.ybar)
axis(side=3, at=observed.ybar, line=-.5)

norm.setup(mean=80, n=25, sd=12, df.t=24, xlim=c(70,90),
   main=one-sided alpha=.05)
norm.curve(mean=80, n=25, sd=12, df.t=24, crit=crit.val[1], shade=left)
abline(v=observed.ybar)
axis(side=3, at=observed.ybar, line=-.5)

par(old.par)

__
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] Space required by object?

2006-09-27 Thread Ben Fairbank
Does R provide a function analogous to LS() or str() that reports the
storage space, on disk or in memory, required by objects?

Ben Fairbank

__
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] Converting text to numbers

2006-09-27 Thread David Barron
 Then, I tried to convert them to numbers using the following.
  Sample1$FCT2 - as.numeric(Sample1$FCT2)
  Sample1$OBS2 - as.numeric(Sample1$OBS2)


This is actually an FAQ.  Do the following and it should be fine:

 Sample1$FCT2 - as.numeric(as.character(Sample1$FCT2))
 Sample1$OBS2 - as.numeric(as.character(Sample1$OBS2))



-- 
=
David Barron
Said Business School
University of Oxford
Park End Street
Oxford OX1 1HP

__
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] Space required by object?

2006-09-27 Thread jim holtman
Here is a function I use:

 my.ls  -  function(pos=1, sorted=F){
   .result - sapply(ls(pos=pos, all.names=TRUE),
   function(..x)object.size(eval(as.symbol(..x
   if (sorted){
   .result - rev(sort(.result))
   }
   .ls - as.data.frame(rbind(as.matrix(.result),**Total=sum(.result)))
   names(.ls) - Size
   .ls$Size - formatC(.ls$Size, big.mark=',', digits=0, format='f')
   .ls$Mode - c(unlist(lapply(rownames(.ls)[-nrow(.ls)],
   function(x)mode(eval(as.symbol(x), '---')
   .ls
}


On 9/27/06, Ben Fairbank [EMAIL PROTECTED] wrote:
 Does R provide a function analogous to LS() or str() that reports the
 storage space, on disk or in memory, required by objects?

 Ben Fairbank

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



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

What is the problem you are trying to solve?

__
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] Space required by object?

2006-09-27 Thread Henrik Bengtsson
See ll() in the R.oo package.  /Henrik

On 9/27/06, Ben Fairbank [EMAIL PROTECTED] wrote:
 Does R provide a function analogous to LS() or str() that reports the
 storage space, on disk or in memory, required by objects?

 Ben Fairbank

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

2006-09-27 Thread Mohsen Jafarikia
Dear all,

I want to design a histogram and I need to have the frequency at certain
points. For example I have the following 2 columns:

*X  Y*

0.125
0.422
0.45  11
0.55  21

I want the chart to have 4 columns. First column is from 0.0-0.1 (on X) and
frequency is 25. Next colum is wider and form 0.1-0.4 with 22 frequency.
Next column is narrow with 11 frequency and the last column is the same as
the first one with 21 frequency.

Can anybody tell me how I can have this chart.

Thanks,
Mohsen

[[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] Histogram

2006-09-27 Thread Ritwik Sinha
Hi,

There may be an easier way but here is one way you can do it.

# create vector that has Y[i] X[i]s
new.data - rep(X,Y)

hist(new.data, breaks=c(0,.1,.4,.6)) # or something like that look at
what exactly breaks should be.

Ritwik.

On 9/27/06, Mohsen Jafarikia [EMAIL PROTECTED] wrote:
 Dear all,

 I want to design a histogram and I need to have the frequency at certain
 points. For example I have the following 2 columns:

 *X  Y*

 0.125
 0.422
 0.45  11
 0.55  21

 I want the chart to have 4 columns. First column is from 0.0-0.1 (on X) and
 frequency is 25. Next colum is wider and form 0.1-0.4 with 22 frequency.
 Next column is narrow with 11 frequency and the last column is the same as
 the first one with 21 frequency.

 Can anybody tell me how I can have this chart.

 Thanks,
 Mohsen

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



-- 
Ritwik Sinha
Graduate Student
Epidemiology and Biostatistics
Case Western Reserve University
[EMAIL PROTECTED] | +12163682366 | http://darwin.cwru.edu/~rsinha

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

2006-09-27 Thread Marc Schwartz
On Wed, 2006-09-27 at 18:29 -0400, Mohsen Jafarikia wrote:
 Dear all,
 
 I want to design a histogram and I need to have the frequency at certain
 points. For example I have the following 2 columns:
 
 *X  Y*
 
 0.125
 0.422
 0.45  11
 0.55  21
 
 I want the chart to have 4 columns. First column is from 0.0-0.1 (on X) and
 frequency is 25. Next colum is wider and form 0.1-0.4 with 22 frequency.
 Next column is narrow with 11 frequency and the last column is the same as
 the first one with 21 frequency.
 
 Can anybody tell me how I can have this chart.
 
 Thanks,
 Mohsen

How about this:

X - c(0, 0.1, 0.4, 0.45, 0.55)
Y - c(25, 22, 11, 21)

barplot(Y, space = 0, width = diff(X))
axis(1)

See ?barplot and ?diff

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] Best use of LaTeX listings package for pretty printing R code

2006-09-27 Thread Michael Kubovy
I tried to use Frank's formatting improvements to compile Sweave- 
produced .tex, but it doesn't seem to make a difference. Advice?

On Sep 25, 2006, at 9:31 AM, Frank E Harrell Jr wrote:

 This is what I have been using.  Does anyone have a better way?  In
 particular I would like to see letters in comment strings not  
 stretched
 so much.  Thanks -Frank

 \documentclass{article}
 \usepackage{listings,relsize}
 \lstloadlanguages{R}
 \newcommand{\lil}[1]{\lstinline|#1|}

 \begin{document}
 \lstset{language=R,basicstyle=\smaller,commentstyle=\rmfamily\smaller,
   showstringspaces=false,%
   xleftmargin=4ex,literate={-}{{$\leftarrow$}}1 {~}{{$\sim$}}1}
 \lstset{escapeinside={(*}{*)}}   % for (*\ref{ }*) inside  
 lstlistings (S
 code)
 \begin{lstlisting}
 a - b   # this is a test line
 if(i==3) {  # another line, for y^2
   y - 3^3
   z - 'this string'
   qqcat - y ~ pol(x,2)
 } else y - 4
 \end{lstlisting}
 That was \lstinline|x - 22| \lil{q - 'cat'}.
 \end{document}

_
Professor Michael Kubovy
University of Virginia
Department of Psychology
USPS: P.O.Box 400400Charlottesville, VA 22904-4400
Parcels:Room 102Gilmer Hall
 McCormick RoadCharlottesville, VA 22903
Office:B011+1-434-982-4729
Lab:B019+1-434-982-4751
Fax:+1-434-982-4766
WWW:http://www.people.virginia.edu/~mk9y/

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


[R] recode problem - unexplained values

2006-09-27 Thread bgreen
I am hoping for some advice regarding the difficulties I have been having
recoding variables which are contained in a csv file.  Table 1 (below) 
shows there are two types of blanks - as reported in the first two
columns. I am using windows XP  the latets version of R.

When blanks cells are replaced with a value of n using syntax:  affect
[affect==] - n
there are still 3 blank values (Table 2).   When as.numeric is applied,
this also causes problems because values of 2,3  4 are generated rather
than just 1  2.

TABLE 1

table(group,actions)
 actions
group   n   y
1 100   2   0   3
2  30   1   1   0
3  24   0   0   0



TABLE 2

  table(group,actions)
 actions
group   n   y
1   0   2 100   3
2   0   1  31   0
3   0   0  24   0


Below is another example - for some reason there are 2 types of 'aobh'
values.


 table(group, type)
 type
group aobh aobh   gbh   m  uw
1  104  1   0   0   0
20  0  15   0  17
30  0   0  24   0


Any assistance is much appreciated,


Bob Green

__
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] Nonlinear fitting - reparametrization help

2006-09-27 Thread Suresh Krishna

Hi,

I am trying to fit a function of the form:

y = A0 + A1 * exp( -0.5* ( (X - Mu1) / Sigma1 )^2 ) - A2 * exp ( -0.5*  
( (X-Mu2)/Sigma2 )^2 )

i.e. a mean term (A0) + a difference between two gaussians.

The constraints are A1,A2 0, Sigma1,Sigma20, and usually Sigma2Sigma1.  
The plot looks like a Mexican Hat.

I had trouble (poor fits) fitting this function to toy data in Matlab and  
now I am playing with R's nls and optim functions. I keep running into  
singular gradient errors with nls, even with very different starting  
values, and have not yet figured out how to interpret the trace results  
usefully.

Can someone help ? Is there a correct parameterization for this problem ?  
I have appended some R code with sample data to fit.

Thank you !!!

Suresh; please cc [EMAIL PROTECTED] if possible.

~~~
x=seq(-10,10,length=1000)
a0=0;
ae=1;
me=0;
se=1;
ai=0.5;
mi=0;
si=3;
dogy - function(x,a0,ae,me,se,ai,mi,si){
y=a0+ae*exp(-0.5*(((x-me)/se)^2))-ai*exp(-0.5*(((x-mi)/si)^2))
y}
y=dogy(x,a0,ae,me,se,ai,mi,si)
erval=rnorm(length(y),sd=0.02)
y=y+erval
#plot(x,y+erval)

#fit=nls(y~ae*exp((x/se)^2)-ai*exp((x/si)^2),start=c(ae=.8,se=1.1,ai=.2,si=1),trace=TRUE)

#here I tried to unsuccesfully reduce the model by eliminating A0, Mu1,  
and Mu2

__
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] Nonlinear fitting - reparametrization help

2006-09-27 Thread Gabor Grothendieck
Similar question was recently asked. See this thread:
http://comments.gmane.org/gmane.comp.lang.r.general/69592

On 9/28/06, Suresh Krishna [EMAIL PROTECTED] wrote:

 Hi,

 I am trying to fit a function of the form:

 y = A0 + A1 * exp( -0.5* ( (X - Mu1) / Sigma1 )^2 ) - A2 * exp ( -0.5*
 ( (X-Mu2)/Sigma2 )^2 )

 i.e. a mean term (A0) + a difference between two gaussians.

 The constraints are A1,A2 0, Sigma1,Sigma20, and usually Sigma2Sigma1.
 The plot looks like a Mexican Hat.

 I had trouble (poor fits) fitting this function to toy data in Matlab and
 now I am playing with R's nls and optim functions. I keep running into
 singular gradient errors with nls, even with very different starting
 values, and have not yet figured out how to interpret the trace results
 usefully.

 Can someone help ? Is there a correct parameterization for this problem ?
 I have appended some R code with sample data to fit.

 Thank you !!!

 Suresh; please cc [EMAIL PROTECTED] if possible.

 ~~~
 x=seq(-10,10,length=1000)
 a0=0;
 ae=1;
 me=0;
 se=1;
 ai=0.5;
 mi=0;
 si=3;
 dogy - function(x,a0,ae,me,se,ai,mi,si){
 y=a0+ae*exp(-0.5*(((x-me)/se)^2))-ai*exp(-0.5*(((x-mi)/si)^2))
 y}
 y=dogy(x,a0,ae,me,se,ai,mi,si)
 erval=rnorm(length(y),sd=0.02)
 y=y+erval
 #plot(x,y+erval)

 #fit=nls(y~ae*exp((x/se)^2)-ai*exp((x/si)^2),start=c(ae=.8,se=1.1,ai=.2,si=1),trace=TRUE)
 #here I tried to unsuccesfully reduce the model by eliminating A0, Mu1,
 and Mu2

 __
 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] recode problem - unexplained values

2006-09-27 Thread Richard M. Heiberger
I can propose a strategy.

This example shows that there are different types of blanks when you
look at character data.

as.character(c(,  ,   ,))

Your test for  found only one of them.

Look at the data as read.csv produces it.  That will probably give you
some clues.

mydata - read.csv(filename)

mydata

as.character(mydata)




Rich

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