Re: [R] Matrix variable in C code

2006-02-03 Thread depire
Selon Gabor Csardi [EMAIL PROTECTED]:

 On Thu, Feb 02, 2006 at 06:27:47PM +0100, [EMAIL PROTECTED] wrote:
 [...]

 The problem is that as.double drops the dim attribute:
  b - matrix( 1:4, 2, 2)
  b
  [,1] [,2]
 [1,]13
 [2,]24
  as.double(b)
 [1] 1 2 3 4
 

 You can try:

  b - matrix( 1:4, 2, 2)
  d - dim(b)
  b - as.double(b)
  b
 [1] 1 2 3 4
  dim(b) - d
  b
  [,1] [,2]
 [1,]13
 [2,]24

 Another thing is that i cannot really see why the ZT parameter of the .Call
 should be a matrix anyway. It's just the vector (40 21 30 20). Or am i
 missing something?

Sorry, i made a mistake writing the small code, the correct one is the following
with the correct dim for ZT. But it doesn't work...


X-c(4,2,3,2)
Z-c(40,21,30,20)
dX-c(2,1,1)

dyn.load(test.so)

Phi-function(z,a,b)
{
Phi-z
}

VPEfron-function(XType,ZType,dXType,G,c0,c1)
{

ZT-matrix(0,3,2)
ZT[1,1]-Z[2]
ZT[1,2]-Z[4]
ZT[2,1]-Z[3]
ZT[3,1]-Z[1]


# A OPTIMISER
  VPCEfron-function(f,XT,ZT,dXT,tailleS=length(XT))
  {
f.check-function(x) {
x-f(x)
}

.Call(VPCEfron,body(f.check),as.double(XT),as.double(ZT),as.integer(dXT),as.integer(tailleS),new.env())
}
GG-function(z) G(z,c0,c1)

Vraisemblancepartielle-VPCEfron(GG,XType,ZType,dXType)
}

resultat-VPEfron(X,Z,dX,Phi,0,0)
==

The new piece of code is between ###.

Thanks,

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


Re: [R] (newbie) Saving the workspace in .txt format

2006-02-03 Thread Petr Pikal
Hi

you can also try to look at

?savehistory

which enables you to save your latest commands to a file. Or use menu 
item save history. You can edit this saved file and you can use part 
of it or whole by loadhistory or just by copy/paste to R console.

HTH
Petr



On 3 Feb 2006 at 7:41, Prof Brian Ripley wrote:

Date sent:  Fri, 3 Feb 2006 07:41:36 + (GMT)
From:   Prof Brian Ripley [EMAIL PROTECTED]
To: Thomas L Jones [EMAIL PROTECTED]
Copies to:  R-project help r-help@stat.math.ethz.ch
Subject:Re: [R] (newbie) Saving the workspace in .txt format

 On Thu, 2 Feb 2006, Thomas L Jones wrote:
 
  (newbie question) How do I save the workspace in Windows text format
  (with the file extension .txt)? Also, having saved it and edited it,
  how do I load it back into the workspace?
 
 `save' is a command in R, and it has a ascii argument.  So you could
 do save.image(workspace.txt, ascii=TRUE) to save, and
 load(workspace.txt) to reload.
 
 The underlying assumption seems to be that text format files are
 editable (by a human).  Lots of data formats are text files but have
 many rigid restrictions:  PDF is one example and R save formats are
 others.
 
 -- 
 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

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


Re: [R] RHOME

2006-02-03 Thread Martin Maechler
 Martyn == Martyn Plummer [EMAIL PROTECTED]
 on Thu, 02 Feb 2006 22:34:23 +0100 writes:

Martyn Quoting Daniel A. Powers
Martyn [EMAIL PROTECTED]:
  R-help --
 
 I built R-2.2.1 in my own directory on a sun
 (solaris). Now I would like the sysadmin to move the
 contents to /usr/local/lib and place the binary in
 /usr/local/bin. No problem.  However, the RHOME variable
 defaults to the directory from which R was built so it is
 not usable by anyone but me or ROOT. I would like to
 avoid building this again if possible. Any ideas?
 
 Thanks, Dan

Martyn R is designed to run from its build directory.  But
Martyn if your sysadmin installs it with make install (as
Martyn root), then the shell wrapper that is installed in
Martyn /usr/local/bin/R will have R_HOME pointing to the
Martyn right location (/usr/local/lib/R).  Literally moving
Martyn the build directory to another location is the wrong
Martyn thing to do.

well, but very easily fixable, and that's what Daniel is asking
for:

The default value of R_HOME is only set in exactly one place,
namely the 'R' shell script; editing that script - once after
the move - is really a piece o'cake.

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


Re: [R] Matrix variable in C code

2006-02-03 Thread depire
I correct a little my code, in R code, i use as.matrix for ZT, so i haven't
got segment fault but it seems that i transmit only the first colon and
because ncol gives 1 and not 2.

So what happen ?

Programs

 R CODE - test.R =
X-c(4,2,3,2)
Z-c(40,21,30,20)
dX-c(2,1,1)

dyn.load(test.so)

Phi-function(z,a,b)
{
Phi-z
}

VPEfron-function(XType,ZType,dXType,G,c0,c1)
{

ZT-matrix(0,3,2)
ZT[1,1]-Z[2]
ZT[1,2]-Z[4]
ZT[2,1]-Z[3]
ZT[3,1]-Z[1]


print(ZT)
# A OPTIMISER
  VPCEfron-function(f,XT,ZT,dXT,tailleS)
  {
f.check-function(x) {
x-f(x)
}
 
.Call(VPCEfron,body(f.check),as.double(XT),as.matrix(ZT),as.integer(dXT),as.integer(tailleS),new.env())
}

GG-function(z) G(z,c0,c1)

VPEfron-VPCEfron(GG,XType,ZType,dXType,length(XType))
}

resultat-VPEfron(X,Z,dX,Phi,0,0)
 END R CODE ==

 C CODE of test.c 
#include R.h
#include Rdefines.h
#include Rinternals.h

#define RMATRIX(m,i,j) (REAL(m)[ INTEGER(GET_DIM(m))[0]*(j)+(i) ])

SEXP mkans(double x)
{
SEXP ans;
PROTECT(ans = allocVector(REALSXP,1));
REAL(ans)[0]=x;
UNPROTECT(1);
return ans;
}

SEXP VPCEfron(SEXP f, SEXP XR, SEXP ZR, SEXP DIR, SEXP tailleR, SEXP rho)
{
double* X=REAL(XR);
int* DI=INTEGER(DIR);
int taille=INTEGER(tailleR)[0];
int nligne=INTEGER(GET_DIM(ZR))[0];
int ncol=INTEGER(GET_DIM(ZR))[1];

printf(verifie taille: %d\n,taille);
printf(verifie de X: %f - %f - %f - %f\n,X[0],X[1],X[2],X[3]);
printf(verifie dX: %d %d %d\n,DI[0],DI[1],DI[2]);

printf(verifie de Z\n);
printf(%d %d\n,nligne,ncol);
printf(%f %f\n,RMATRIX(ZR,0,0),RMATRIX(ZR,0,1));
printf(%f %f\n,RMATRIX(ZR,1,0),RMATRIX(ZR,1,1));
printf(%f %f\n,RMATRIX(ZR,2,0),RMATRIX(ZR,2,1));

return mkans(0.0);
}
 END 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


Re: [R] Matrix variable in C code

2006-02-03 Thread Gabor Csardi
No idea, your code (now that you're not using as.double) kinda works for me.

 source(test.R)
 [,1] [,2]
[1,]   21   20
[2,]   300
[3,]   400
verifie taille: 4
verifie de X: 4.00 - 2.00 - 3.00 - 2.00
verifie dX: 2 1 1
verifie de Z
4 1
40.00 0.00
21.00 0.00
30.00 0.00
 

The only thing is that your code is very messy (for me at least), and it's
true that you print the value of ZT and it is a 3x3 matrix, but if you print
its value just before the .Call it is just a vector of length 4. Then
as.matrix() creates a 4x1 matrix of this. 

Look at this simple R code, it works with your test.c file fine:

##
dyn.load(test.so)

f.check - function(a) a
XT - 1:4
ZT - matrix( c(21,30,40,20,0,0), nr=3, nc=2)
dXT - 1:3
tailleS - 5

.Call(VPCEfron,body(f.check),as.double(XT),as.matrix(ZT),as.integer(dXT),
  as.integer(tailleS),new.env()) 
#  

Gabor

On Fri, Feb 03, 2006 at 11:45:24AM +0100, [EMAIL PROTECTED] wrote:
 I correct a little my code, in R code, i use as.matrix for ZT, so i haven't
 got segment fault but it seems that i transmit only the first colon and
 because ncol gives 1 and not 2.
 
 So what happen ?
 
 Programs
 
  R CODE - test.R =
 X-c(4,2,3,2)
 Z-c(40,21,30,20)
 dX-c(2,1,1)
 
 dyn.load(test.so)
 
 Phi-function(z,a,b)
 {
   Phi-z
 }
 
 VPEfron-function(XType,ZType,dXType,G,c0,c1)
 {
   
   ZT-matrix(0,3,2)
   ZT[1,1]-Z[2]
   ZT[1,2]-Z[4]
   ZT[2,1]-Z[3]
   ZT[3,1]-Z[1]
   
   
   print(ZT)
   # A OPTIMISER
   VPCEfron-function(f,XT,ZT,dXT,tailleS)
   {
   f.check-function(x) {
 x-f(x)
 }
  
 .Call(VPCEfron,body(f.check),as.double(XT),as.matrix(ZT),as.integer(dXT),as.integer(tailleS),new.env())
   }
 
   GG-function(z) G(z,c0,c1)
 
 VPEfron-VPCEfron(GG,XType,ZType,dXType,length(XType))
 }
 
 resultat-VPEfron(X,Z,dX,Phi,0,0)
  END R CODE ==
 
  C CODE of test.c 
 #include R.h
 #include Rdefines.h
 #include Rinternals.h
 
 #define RMATRIX(m,i,j) (REAL(m)[ INTEGER(GET_DIM(m))[0]*(j)+(i) ])
 
 SEXP mkans(double x)
 {
   SEXP ans;
   PROTECT(ans = allocVector(REALSXP,1));
   REAL(ans)[0]=x;
   UNPROTECT(1);
   return ans;
 }
 
 SEXP VPCEfron(SEXP f, SEXP XR, SEXP ZR, SEXP DIR, SEXP tailleR, SEXP rho)
 {
   double* X=REAL(XR);
   int* DI=INTEGER(DIR);
   int taille=INTEGER(tailleR)[0];
   int nligne=INTEGER(GET_DIM(ZR))[0];
   int ncol=INTEGER(GET_DIM(ZR))[1];
 
   printf(verifie taille: %d\n,taille);
   printf(verifie de X: %f - %f - %f - %f\n,X[0],X[1],X[2],X[3]);
   printf(verifie dX: %d %d %d\n,DI[0],DI[1],DI[2]);
 
   printf(verifie de Z\n);
   printf(%d %d\n,nligne,ncol);
   printf(%f %f\n,RMATRIX(ZR,0,0),RMATRIX(ZR,0,1));
   printf(%f %f\n,RMATRIX(ZR,1,0),RMATRIX(ZR,1,1));
   printf(%f %f\n,RMATRIX(ZR,2,0),RMATRIX(ZR,2,1));
 
   return mkans(0.0);
 }
  END CODE =
 
 
 This message was sent using IMP, the Internet Messaging Program.

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

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


[R] Accessing row names

2006-02-03 Thread Werner Wernersen
Hi,
  
  I am doing cluster analysis and get back the vector with the clusters.  Now I 
want to access the original data according to the assigned  clusters. 
Therefore, I need the row names of the $cluster vector. Right  now I do the 
following what works but seems a little awkward:
  dat[rownames(as.data.frame(which(kcl$cluster==1))),]
  Is there maybe a better or correct way to do this?
  
  Thanks a lot!
Werner
  

-


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


[R] Application of R

2006-02-03 Thread Andy Wong
Could somebody gives me some advice what is the problem of my analysis as
per attached printed file showing the steps of the input and the error
occured.  I have also attached my data file in Excel file format for your
reference.

Thanks.

Andy


result.pdf
Description: Adobe PDF document
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Re: [R] Application of R

2006-02-03 Thread Petr Pikal
Hi

I do not know anything about mnp but the variables in your data frame 
has names V1:V23 and you request mnp to use variables x1..., y1..., 
and z1 Unless you have them somewhere, where do you suppose mnp 
to know about them?

Try to read some basic text about data structures and manipulation 
with them e.g. R-intro.pdf which is probably in doc directory.

HTH
Petr


On 3 Feb 2006 at 20:24, Andy Wong wrote:

Date sent:  Fri, 3 Feb 2006 20:24:00 +0800
From:   Andy Wong [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Subject:[R] Application of R

 Could somebody gives me some advice what is the problem of my analysis
 as per attached printed file showing the steps of the input and the
 error occured.  I have also attached my data file in Excel file format
 for your reference.
 
 Thanks.
 
 Andy
 

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


[R] question

2006-02-03 Thread Xiao Zhao
Hello,
I am a research student and I am using R to access my research. I want
to know how to multiple plot , such as for the exponetial distribution,
if I give the covariate different value, how to plot these in the same
figure,
And also I want to add the density plot in the histogramm.
How to do these?
Thank u in advance
nessie

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


Re: [R] How to get the namespace of a function?

2006-02-03 Thread Peter Dalgaard
Prof Brian Ripley [EMAIL PROTECTED] writes:

 On Thu, 2 Feb 2006, Fernando Saldanha wrote:
 
  I am trying to imitate encapsulation from other languages like Java
  or C++. Coming from that background, it bothers me that I can commit
  errors like the following:
 
  x - 1
  f - function(z) { y - x; y + 1 } # Mistake: I should have written y - z
  f(10)
  [1] 2
 
  In a language like Java the interpreter would have noticed that x was
  an undeclared variable and an error message would be issued. R, on the
  other hand, allows the code to run, as x exists in the global
  environment. I was trying to avoid such situations by  setting the
  environment of f to be NULL. If there is a better way to catch this
  type of errors I would be interested in knowing about it.
 
 The codetools package.  See http://www.stat.uiowa.edu/~luke/R/codetools.
 
 (They are not R errors, but the codetools package can tell you that 'x' is 
 not necessarily in scope.)

Yep, and nor is -, +, and {... 

(Does codetools actually check those? Probably not, but it goes to
show why full encapsulation is hard or impossible to achieve in a
language where everything, including functions and operators, are
objects.)

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


Re: [R] How to get the namespace of a function?

2006-02-03 Thread Luke Tierney
On Thu, 2 Feb 2006, Duncan Murdoch wrote:

 On 2/2/2006 5:56 PM, Berton Gunter wrote:
 Just echoing and slightly amplifying Gabor's comment...

 The semantics of R are really based on functional programming (LISP-like)
 rather than OOP (JAVA-like)? R's behavior is proper from that point of
 view; what is improper is Fernando's expectation that it should behave
 some other way.

 I don't think it's that so much as trying not to break old code.  It
 doesn't make sense to me that the search order within a namespace should
 pass through the global environment, but something would break if it
 didn't.  (I suspect it's probably the old S3 object system, which
 predates namespaces by a long time, but it's been a while since I've
 thought about this.)

S3 dispatch was the primary reason for this design.  At some point we
may be able to revisit this but probably not very soon.

Once code analysis becomes a standard part of R, either via byte code
compilation or as bart of R CMD check, there should be warnings issued
automatically for this sort of thing.  For now manually using the
codetools ackage Brian pointed to is one option.

Best,

luke


 Duncan Murdoch


  Of course, one can simulate anything with a Turing machine,
 but I consider Fernando's criticisms somewhat unfair because he is
 expecting R to behave like something he is familiar with rather than as it
 was designed to. For this reason, what bothers him seems wholly desirable to
 me -- I want there to be well-defined scoping convention (lexical scoping)
 for R to find free variables.

 Cheers,

 Bert



 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Duncan Murdoch
 Sent: Thursday, February 02, 2006 2:16 PM
 To: [EMAIL PROTECTED]
 Cc: r-help@stat.math.ethz.ch
 Subject: Re: [R] How to get the namespace of a function?

 On 2/2/2006 5:05 PM, Fernando Saldanha wrote:
 I am trying to imitate encapsulation from other languages like Java
 or C++. Coming from that background, it bothers me that I can commit
 errors like the following:

 x - 1
 f - function(z) { y - x; y + 1 } # Mistake: I should have written y -
 z
 f(10)
 [1] 2

 In a language like Java the interpreter would have noticed that x was
 an undeclared variable and an error message would be issued. R, on the
 other hand, allows the code to run, as x exists in the global
 environment. I was trying to avoid such situations by  setting the
 environment of f to be NULL. If there is a better way to catch this
 type of errors I would be interested in knowing about it.

 Put your code in a package, and use a namespace.  This isn't perfect,
 but it gives you more control than you have when running scripts at the
 console.

 There's an article by Luke Tierney in one of R News 3/1 that explains
 the search order when namespaces are involved.

 Duncan Murdoch
 FS

 On 2/2/06, Duncan Murdoch [EMAIL PROTECTED] wrote:
 On 2/2/2006 10:56 AM, Fernando Saldanha wrote:
 I declared the environment of the function myfun to be NULL as follows:

 environment(myfun) - NULL
 Since version 2.1.0, it's been recommended that you use

 environment(myfun) - baseenv()

 and since 2.2.0, you'll get a warning when using NULL (and you'll get an
 error in 2.3.0).  But why would you want to do that?  What are you
 trying to achieve?

 Duncan Murdoch


 Later on I called that myfun and got an error message because the
 function index() in the zoo package was called inside myfun and was
 not visible:

 Error in myfun(args) : couldn't find function index

 I tried to use zoo::index() instead of index(), but that did not work.
 In fact, zoo::index does not work even in the command line:

 z-ts(1:5)
 z
 Time Series:
 Start = 1
 End = 5
 Frequency = 1
 [1] 1 2 3 4 5
 index(z)
 [1] 1 2 3 4 5
 zoo::index(z)
 Error in loadNamespace(name) : package 'zoo' does not have a name space

 How can I qualify index() so that it is visible inside the body of
 myfun?
 Thanks for any suggestions,

 FS

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

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

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

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


-- 
Luke Tierney
Chair, Statistics and Actuarial Science
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa  Phone: 

[R] SVS tree lists

2006-02-03 Thread Mike Saunders
I know this is a long shot, but does anyone out there have code for converting 
a R-dataframe into a Stand Visualization System (SVS) tree list?  It would save 
me a bit of time.

I would be interested if anyone has FVS code as well.  I will be working 
(reworking) NE-TWIGS equations to a regionwide dataset.

Thanks in advance,
Mike


Mike R. Saunders
Forest Biometrician
Cooperative Forest Research Unit
University of Maine
5755 Nutting Hall
Orono, ME  04469-5755

207-581-2763 (O)
207-581-2833 (F)

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


Re: [R] question

2006-02-03 Thread Gabor Csardi
 x - seq(0, 10, by=.1)
 plot(x,pexp(x, rate=1))
 points(x,pexp(x, rate=2), pch=2, col=blue)

See help(plot), help(points), help(lines).

Gabor

On Fri, Feb 03, 2006 at 01:07:30PM -, Xiao Zhao wrote:
 Hello,
 I am a research student and I am using R to access my research. I want
 to know how to multiple plot , such as for the exponetial distribution,
 if I give the covariate different value, how to plot these in the same
 figure,
 And also I want to add the density plot in the histogramm.
 How to do these?
 Thank u in advance
 nessie
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

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

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


Re: [R] RHOME

2006-02-03 Thread Peter Dalgaard
Martin Maechler [EMAIL PROTECTED] writes:

 Martyn R is designed to run from its build directory.  But
 Martyn if your sysadmin installs it with make install (as
 Martyn root), then the shell wrapper that is installed in
 Martyn /usr/local/bin/R will have R_HOME pointing to the
 Martyn right location (/usr/local/lib/R).  Literally moving
 Martyn the build directory to another location is the wrong
 Martyn thing to do.
 
 well, but very easily fixable, and that's what Daniel is asking
 for:
 
 The default value of R_HOME is only set in exactly one place,
 namely the 'R' shell script; editing that script - once after
 the move - is really a piece o'cake.

Hmm, I was about to say the same, but there seems to be unexpected
references in other places.

find `R RHOME` | xargs grep `R RHOME`
/usr/lib64/R/bin/R:R_HOME_DIR=/usr/lib64/R
/usr/lib64/R/bin/R:R_SHARE_DIR=/usr/lib64/R/share
/usr/lib64/R/bin/R:R_INCLUDE_DIR=/usr/lib64/R/include
/usr/lib64/R/bin/R:R_DOC_DIR=/usr/lib64/R/doc

(this doesn't normally happen - a SUSE RPM specialty, or due to
configure flag settings?)


Once you start building packages, you also have things like

viggo:~/find ~/Rlibrary | xargs grep `R RHOME`
Binary file /home/bs/pd/Rlibrary/rgl/libs/rgl.so matches


viggo:~/find ~/Rlibrary | xargs grep Rlibrary
Binary file /home/bs/pd/Rlibrary/rgl/Meta/hsearch.rds matches
Binary file /home/bs/pd/Rlibrary/ISwR/Meta/hsearch.rds matches
Binary file /home/bs/pd/Rlibrary/mvtnorm/Meta/hsearch.rds matches
Binary file /home/bs/pd/Rlibrary/nlmeODE/Meta/hsearch.rds matches
B.

on my laptop I had a hit on one of the Sweave support files too.

Most likely these are quite harmless, but all in all I think Martyn
has the safest advice: Use make install, as root (don't forget
umask 022).

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


[R] Problems with ks.test

2006-02-03 Thread Emanuele Mazzola
Hi everybody,

while performing ks.test for a standard exponential distribution on samples 
of dimension 2500, generated everytime as new, i had this strange behaviour:

data-rexp(2500,0.4)
ks.test(data,pexp,0.4)

One-sample Kolmogorov-Smirnov test

data:  data
D = 0.0147, p-value = 0.6549
alternative hypothesis: two.sided

data-rexp(2500,0.4)
ks.test(data,pexp,0.4)

One-sample Kolmogorov-Smirnov test

data:  data
D = 0.019, p-value = 0.3305
alternative hypothesis: two.sided

data-rexp(2500,0.4)
ks.test(data,pexp,0.4)

One-sample Kolmogorov-Smirnov test

data:  data
D = 0.0171, p-value = 0.4580
alternative hypothesis: two.sided

data-rexp(2500,0.4)
ks.test(data,pexp,0.4)

One-sample Kolmogorov-Smirnov test

data:  data
D = 0.0143, p-value = 0.6841
alternative hypothesis: two.sided

data-rexp(2500,0.4)
ks.test(data,pexp,0.4)

One-sample Kolmogorov-Smirnov test

data:  data
D = 0.0145, p-value = 0.6684
alternative hypothesis: two.sided

data-rexp(2500,0.4)
ks.test(data,pexp,0.4)

One-sample Kolmogorov-Smirnov test

data:  data
D = 0.0123, p-value = 0.8435
alternative hypothesis: two.sided

data-rexp(2500,0.4)
ks.test(data,pexp,0.4)

One-sample Kolmogorov-Smirnov test

data:  data
D = 0.0186, p-value = 0.3532
alternative hypothesis: two.sided


It seems kind of strange to me that max p-value obtained is 0.8435 and all 
the best i can have from the rest is a 0.66-0.68.
I'm probably not so expert in running this kind of test, but am I doing 
something wrong?
I would expect p values ranging from 0.75 (to be kind) to 0.9, 0.95. How is 
this possible?

Thank you in advance for your answers.
See you soon
EM

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


[R] How to decide between two theoretical distributions?

2006-02-03 Thread Petar Milin
Question that I have to ask has two parts: first, related to statistics,
in principle, and second, related to R-how-to, in particular.
In very brief, I have collected pretty solid sample for a phenomenon
that has two possible interpretation of how it is distributed in the
population; for example, beta and gamma distributed.
How it can be tested which model (theoretical distribution) suits better
actual data? Except some vague idea that bootstrapping or jackknifing
could be used, I have no further thoughts on that matter.
Could it be tested in R and how?

Sincerely,
Petar Milin

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


[R] How to decide between two theoretical distributions?

2006-02-03 Thread Petar Milin
Question that I have to ask has two parts: first, related to statistics,
in principle, and second, related to R-how-to, in particular.
In very brief, I have collected pretty solid sample for a phenomenon
that has two possible interpretation of how it is distributed in the
population; for example, beta and gamma distributed.
How it can be tested which model (theoretical distribution) suits better
actual data? Except some vague idea that bootstrapping or jackknifing
could be used, I have no further thoughts on that matter.
Could it be tested in R and how?

Sincerely,
Petar Milin

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


Re: [R] Matrix variable in C code

2006-02-03 Thread Douglas Bates
On 2/2/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 Selon Gabor Csardi [EMAIL PROTECTED]:

  On Thu, Feb 02, 2006 at 03:11:42PM +0100, [EMAIL PROTECTED] wrote:
  [...]
  
   and my test code in C is:
   
   SEXP VPCEfron(SEXP f, SEXP SR, SEXP ZR, SEXP DIR, SEXP nsR, SEXP rho)
   {
   int taille=INTEGER(nsR)[0];
  [...]
  
   All works, except ZS, the variable ZS is a matrix in R, and when i try to
  give
   to C code, with ZR, ZR is only a vector.
  
   How to obtain a matrix variable in C ?
 
  A matrix is the same as a vector (stored columnwise), except that is has a
  dim attribute. Use can use SET_DIM to set the dim attribute, and GET_dim to
  query it. Eg:
 
  int nrow=INTEGER(GET_DIM(ZR))[0];
  int ncol=INTEGER(GET_DIM(ZR))[1];
 
  To access the values in the matrix you might use something like:
 
  #define RMATRIX(m,i,j) (REAL(m)[ INTEGER(GET_DIM(m))[0]*(j)+(i) ])
 
  and then
 
  RMATRIX(ZR, 0, 1), etc. works. Note that according to this #define the
  matrix
  is indexed from zero.
 
  Gabor
 
 
  --
  Csardi Gabor [EMAIL PROTECTED]MTA RMKI, ELTE TTK
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide!
  http://www.R-project.org/posting-guide.html
 

 I try but i think that i make some mistake because i obtain segment fault.
 To be sure, i reduce the code to permit to test it, the goal is just to print
 the variable, i try with vector variables (real X and integer dX in the
 following), it works; but with matrix it doesn't work.

 The code of the R program - Test.R
 =
 X-c(4,2,3,2)
 Z-c(40,21,30,20)
 dX-c(2,1,1)

 dyn.load(test.so)

 Phi-function(z,a,b)
 {
 Phi-z
 }

 VPEfron-function(XType,ZType,dXType,G,c0,c1)
 {
 # A OPTIMISER
   VPCEfron-function(f,XT,ZT,dXT,tailleS=length(XT))
   {
 f.check-function(x) {
 x-f(x)
 }

 .Call(VPCEfron,body(f.check),as.double(XT),as.double(ZT),as.integer(dXT),as.integer(tailleS),new.env())
 }
 GG-function(z) G(z,c0,c1)

 Vraisemblancepartielle-VPCEfron(GG,XType,ZType,dXType)
 }

 resultat-VPEfron(X,Z,dX,Phi,0,0)
 ==

 The code of C code - test.c and test.so is obtained by R CMD SHLIB test.c
 
 #include R.h
 #include Rdefines.h

 #define RMATRIX(m,i,j) (REAL(m)[ INTEGER(GET_DIM(m))[0]*(j)+(i) ])

 SEXP mkans(double x)
 {
 SEXP ans;
 PROTECT(ans = allocVector(REALSXP,1));
 REAL(ans)[0]=x;
 UNPROTECT(1);
 return ans;
 }

 SEXP VPCEfron(SEXP f, SEXP XR, SEXP ZR, SEXP DIR, SEXP rho)
 {
 double* X=REAL(XR);
 int* DI=INTEGER(DIR);
 int nligne=INTEGER(GET_DIM(ZR))[0];
 int ncol=INTEGER(GET_DIM(ZR))[1];

 printf(verifie de X: %f - %f - %f - %f\n,X[0],X[1],X[2],X[3]);
 printf(verifie dX: %d %d %d\n,DI[0],DI[1],DI[2]);
 printf(verifie de Z\n);
 printf(%d %d\n,nligne,ncol);
 printf(%f %f\n,RMATRIX(ZR,0,0));
 printf(%f %f\n,RMATRIX(ZR,0,1));
 printf(%f %f\n,RMATRIX(ZR,1,0));
 printf(%f %f\n,RMATRIX(ZR,2,0));

 return mkans(0.0);
 }
 =

 You can save these two simple programs in order to test my code.

It's a small point but there is no need to write the C function mkans
- you can use the function ScalarReal (or ScalarLogical, ScalarInt,
...).

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


Re: [R] Problems with ks.test

2006-02-03 Thread Don MacQueen
7 repetitions is not nearly enough to get a good estimate of the 
variability of the test statistic.
Try this:

nrep - 500
pvals - tstvals - numeric(nrep)

for (i in seq(nrep)) {
   tmp -  ks.test(rexp(2500,0.4),pexp,0.4)
   pvals[i] - tmp$p.value
   tstvals[i] - tmp$statistic
}

hist(pvals)
hist(tstvals)
round(quantile(pvals,pr=seq(0.05,.95,.05)),2)

At 2:36 PM + 2/3/06, Emanuele Mazzola wrote:
Hi everybody,

while performing ks.test for a standard exponential distribution on samples
of dimension 2500, generated everytime as new, i had this strange behaviour:

data-rexp(2500,0.4)
ks.test(data,pexp,0.4)

   One-sample Kolmogorov-Smirnov test

data:  data
D = 0.0147, p-value = 0.6549
alternative hypothesis: two.sided

data-rexp(2500,0.4)
ks.test(data,pexp,0.4)

   One-sample Kolmogorov-Smirnov test

data:  data
D = 0.019, p-value = 0.3305
alternative hypothesis: two.sided

data-rexp(2500,0.4)
ks.test(data,pexp,0.4)

   One-sample Kolmogorov-Smirnov test

data:  data
D = 0.0171, p-value = 0.4580
alternative hypothesis: two.sided

data-rexp(2500,0.4)
ks.test(data,pexp,0.4)

   One-sample Kolmogorov-Smirnov test

data:  data
D = 0.0143, p-value = 0.6841
alternative hypothesis: two.sided

data-rexp(2500,0.4)
ks.test(data,pexp,0.4)

   One-sample Kolmogorov-Smirnov test

data:  data
D = 0.0145, p-value = 0.6684
alternative hypothesis: two.sided

data-rexp(2500,0.4)
ks.test(data,pexp,0.4)

   One-sample Kolmogorov-Smirnov test

data:  data
D = 0.0123, p-value = 0.8435
alternative hypothesis: two.sided

  data-rexp(2500,0.4)
ks.test(data,pexp,0.4)

   One-sample Kolmogorov-Smirnov test

data:  data
D = 0.0186, p-value = 0.3532
alternative hypothesis: two.sided


It seems kind of strange to me that max p-value obtained is 0.8435 and all
the best i can have from the rest is a 0.66-0.68.
I'm probably not so expert in running this kind of test, but am I doing
something wrong?
I would expect p values ranging from 0.75 (to be kind) to 0.9, 0.95. How is
this possible?

Thank you in advance for your answers.
See you soon
EM

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


-- 
--
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA

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


Re: [R] Problems with ks.test

2006-02-03 Thread Patrick Burns
The distribution of p-values should be uniform under
the null hypothesis.  When I do:

  jj - numeric(1)
  for(i in 1:1) jj[i] - ks.test(rexp(2500, .4), 'pexp', .4)$p.value
Warning messages:
1: cannot compute correct p-values with ties in: ks.test(rexp(2500, 
0.4), pexp, 0.4)
2: cannot compute correct p-values with ties in: ks.test(rexp(2500, 
0.4), pexp, 0.4)
3: cannot compute correct p-values with ties in: ks.test(rexp(2500, 
0.4), pexp, 0.4)
4: cannot compute correct p-values with ties in: ks.test(rexp(2500, 
0.4), pexp, 0.4)
  hist(jj, 50, col='yellow'); abline(h=200, col='green')

I get a histogram that looks reasonably flat to me.

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


Emanuele Mazzola wrote:

Hi everybody,

while performing ks.test for a standard exponential distribution on samples 
of dimension 2500, generated everytime as new, i had this strange behaviour:

  

data-rexp(2500,0.4)
ks.test(data,pexp,0.4)



   One-sample Kolmogorov-Smirnov test

data:  data
D = 0.0147, p-value = 0.6549
alternative hypothesis: two.sided

  

data-rexp(2500,0.4)
ks.test(data,pexp,0.4)



   One-sample Kolmogorov-Smirnov test

data:  data
D = 0.019, p-value = 0.3305
alternative hypothesis: two.sided

  

data-rexp(2500,0.4)
ks.test(data,pexp,0.4)



   One-sample Kolmogorov-Smirnov test

data:  data
D = 0.0171, p-value = 0.4580
alternative hypothesis: two.sided

  

data-rexp(2500,0.4)
ks.test(data,pexp,0.4)



   One-sample Kolmogorov-Smirnov test

data:  data
D = 0.0143, p-value = 0.6841
alternative hypothesis: two.sided

  

data-rexp(2500,0.4)
ks.test(data,pexp,0.4)



   One-sample Kolmogorov-Smirnov test

data:  data
D = 0.0145, p-value = 0.6684
alternative hypothesis: two.sided

  

data-rexp(2500,0.4)
ks.test(data,pexp,0.4)



   One-sample Kolmogorov-Smirnov test

data:  data
D = 0.0123, p-value = 0.8435
alternative hypothesis: two.sided

  

data-rexp(2500,0.4)
ks.test(data,pexp,0.4)



   One-sample Kolmogorov-Smirnov test

data:  data
D = 0.0186, p-value = 0.3532
alternative hypothesis: two.sided


It seems kind of strange to me that max p-value obtained is 0.8435 and all 
the best i can have from the rest is a 0.66-0.68.
I'm probably not so expert in running this kind of test, but am I doing 
something wrong?
I would expect p values ranging from 0.75 (to be kind) to 0.9, 0.95. How is 
this possible?

Thank you in advance for your answers.
See you soon
EM

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



  


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


[R] How to get all the data in a specific column from a dataframe?

2006-02-03 Thread Vincent Deng
Dear R-helpers:

Suppose I have a datafram called test_frame like this
 col1   col2  col3  col4
r1   xxx x
r2   xxx x
r3   xxx x
..xxx x
rn   xxx x

I know I can get data of col3 by using test_frame[,3].

My question is, if I want to do this by specifying col3 rather than 3,
what should I do?

Many thanks

[[alternative HTML version deleted]]

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


Re: [R] RHOME

2006-02-03 Thread Martyn Plummer
Far be it for me to tell people what they can and cannot do. Perhaps I
can rephrase myself in a less inflammatory way.  

R runs from the build directory as a convenience for developers, so you
don't have to reinstall R every time you change something. But for
users, the standard mechanism make install has a number of advantages
over moving the build directory to a publicly accessible location: it is
guaranteed to work, you don't have to do any post-hoc editing of files,
it takes up a lot less space, about 4.6 times less on my system

[EMAIL PROTECTED] r-devel]$ du -sh R
356MR
[EMAIL PROTECTED] r-devel]$ du -sh /usr/local/lib64/R
77M /usr/local/lib64/R

But if you do want to copy the build directory the, as Martin says,
you can edit the file bin/R so that the line that starts
R_HOME_DIR points to the correct location, e.g.
 
R_HOME_DIR=/usr/local/lib/R

M.

On Fri, 2006-02-03 at 14:48 +0100, Peter Dalgaard wrote:
 Martin Maechler [EMAIL PROTECTED] writes:
 
  Martyn R is designed to run from its build directory.  But
  Martyn if your sysadmin installs it with make install (as
  Martyn root), then the shell wrapper that is installed in
  Martyn /usr/local/bin/R will have R_HOME pointing to the
  Martyn right location (/usr/local/lib/R).  Literally moving
  Martyn the build directory to another location is the wrong
  Martyn thing to do.
  
  well, but very easily fixable, and that's what Daniel is asking
  for:
  
  The default value of R_HOME is only set in exactly one place,
  namely the 'R' shell script; editing that script - once after
  the move - is really a piece o'cake.
 
 Hmm, I was about to say the same, but there seems to be unexpected
 references in other places.
 
 find `R RHOME` | xargs grep `R RHOME`
 /usr/lib64/R/bin/R:R_HOME_DIR=/usr/lib64/R
 /usr/lib64/R/bin/R:R_SHARE_DIR=/usr/lib64/R/share
 /usr/lib64/R/bin/R:R_INCLUDE_DIR=/usr/lib64/R/include
 /usr/lib64/R/bin/R:R_DOC_DIR=/usr/lib64/R/doc
 
 (this doesn't normally happen - a SUSE RPM specialty, or due to
 configure flag settings?)

I think this is normal. But the RedHat RPM behaves differently.

(because the RPM build process installs into a temporary build root
which is distinct from the final installation directory, requiring more
sed voodoo).

 
 Once you start building packages, you also have things like
 
 viggo:~/find ~/Rlibrary | xargs grep `R RHOME`
 Binary file /home/bs/pd/Rlibrary/rgl/libs/rgl.so matches
 
 
 viggo:~/find ~/Rlibrary | xargs grep Rlibrary
 Binary file /home/bs/pd/Rlibrary/rgl/Meta/hsearch.rds matches
 Binary file /home/bs/pd/Rlibrary/ISwR/Meta/hsearch.rds matches
 Binary file /home/bs/pd/Rlibrary/mvtnorm/Meta/hsearch.rds matches
 Binary file /home/bs/pd/Rlibrary/nlmeODE/Meta/hsearch.rds matches
 B.
 
 on my laptop I had a hit on one of the Sweave support files too.
 
 Most likely these are quite harmless, but all in all I think Martyn
 has the safest advice: Use make install, as root (don't forget
 umask 022).
 

---
This message and its attachments are strictly confidential. ...{{dropped}}

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


[R] Infinite loop running Mod_R/Rapache

2006-02-03 Thread BJ
I installed mod_r according to the specifications, and have been trying 
to get the demo script to work correctly. I am running debian, the 
latest build of R, apache 2 with prefork mpm, and the latest mod_r. Is 
anyone else using this module successfully? I added:

LoadModule R_module mod_R.so
Location /test/hello
SetHandler r-handler
Rsource /var/www/html/test.R
RreqHandler handler
/Location

to my http.conf and

test.R in /var/www/html is:

handler-function(r){
apache.write(r,h1Hello World!/h1)
OK
}

When I start apache2, my /tmp directory fills with rtmp directories 
until memory is exausted. The first time it created 32,000 before I 
noticed. Does anyone have any idea as to what I could be doing wrong, or 
have a software configuration that works? Thank you for all of your 
help. ~BJ

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


Re: [R] How to get all the data in a specific column from a dataframe?

2006-02-03 Thread Chuck Cleland
test_frame[,col3]

or

subset(test_frame, select = col3)

Vincent Deng wrote:
 Dear R-helpers:
 
 Suppose I have a datafram called test_frame like this
  col1   col2  col3  col4
 r1   xxx x
 r2   xxx x
 r3   xxx x
 ..xxx x
 rn   xxx x
 
 I know I can get data of col3 by using test_frame[,3].
 
 My question is, if I want to do this by specifying col3 rather than 3,
 what should I do?
 
 Many thanks
 
   [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
 

-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 452-1424 (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


Re: [R] How to get all the data in a specific column from a dataframe?

2006-02-03 Thread Peter Dalgaard
Chuck Cleland [EMAIL PROTECTED] writes:

 test_frame[,col3]
 
 or
 
 subset(test_frame, select = col3)

or 

test_frame$col3

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


[R] statistical modelling SAS vs R

2006-02-03 Thread Bill Szkotnicki
Hello,

Recently I have been reading a lot of material about statistical modeling
using R. There seems to be conflicting opinions about what the best approach
is between the SAS community and the R community.
1) In R one might start with a model that has all possible effects of
interest in it and then simplify by eliminating/adding insignificant effects
using a stepwise procedure.
2) In SAS one may starts with a reasonable model and look at type 3 SS's
to test hypotheses and report LSMEANS. This can be done in R too I think.

Does anyone have current opinions about this? I know it's been discussed
before but I would be very interested in hearing about the advantages and
pitfalls of both approaches.

Bill

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


[R] workspace question

2006-02-03 Thread Afshartous, David

All,

When starting R, how does one prevent the loading the previous 
workspace which was saved?  I'd like to start a new project
and save the new image in a different directory, but I'd like to 
partition this from the old project.  Does there exist a better
way than just deleting the files associated w/ the old project
manually?  I looked in the Intro to R manual and searched for 
workspace and didn't see anything on this aspect.

Kind regards,
Dave

ps - please reply directly to [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


Re: [R] statistical modelling SAS vs R

2006-02-03 Thread Frank E Harrell Jr
Bill Szkotnicki wrote:
 Hello,
 
 Recently I have been reading a lot of material about statistical modeling
 using R. There seems to be conflicting opinions about what the best approach
 is between the SAS community and the R community.
 1) In R one might start with a model that has all possible effects of
 interest in it and then simplify by eliminating/adding insignificant effects
 using a stepwise procedure.
 2) In SAS one may starts with a reasonable model and look at type 3 SS's
 to test hypotheses and report LSMEANS. This can be done in R too I think.
 
 Does anyone have current opinions about this? I know it's been discussed
 before but I would be very interested in hearing about the advantages and
 pitfalls of both approaches.
 
 Bill

You'll get lots of opinions about this.  Both R and SAS can be abused 
terribly, and both approaches you mentioned have major problems if you 
use P-values to specify models.  Better and more replicable results can 
be obtained using modern shrinkage methods and being more liberal with 
inclusion of variables, or by using Bayesian model averaging.

Note that LSMEANS and Type III tests are SAS concoctions and that if you 
have interactions in the model, type III tests have been criticized.  If 
there are no interactions, type Type III = Type II.

Frank Harrell

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


[R] Clustering for social/complex networks

2006-02-03 Thread Kel Lam
Hi group,

Here is another clustering question.  Is there
anything available in R that I can cluster groups with
overlaps?  It looks like a Venn Diagram with two or
more circles overlapping one another.  

I realize that Hierarchical Clustering (hclust in
Stats) only group individuals into distinct groups. 
My scenario is I have to group Physicians that each of
them may belong to more than one group.  That reflects
the complexity of relationhip, something analogous to
Social Network.  

Thanks!

kel

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


Re: [R] is there a way to visualize 3D normal distributions?

2006-02-03 Thread Ben Bolker

   In response to your last question --

   Duncan already gave you the answer in his last e-mail -- to give
an explicit example, for a particular set of means and
variance-covariance matrix:

library(rgl)
demo(shapes3d)
rgl.clear()
sphere - ellipsoid3d(2,2,2,qmesh=TRUE)
means - c(0,0,0)
S - matrix(c(3,1,-1,1,2,-1,-1,-1,2),nrow=3)
ellipsoid - translate3d(rotate3d(sphere,matrix=chol(S)*qnorm(0.975)),
 means[1],means[2],means[3])
shade3d(ellipsoid)
axis3d()


Duncan Murdoch wrote:
 On 2/2/2006 5:01 PM, Michael wrote:
 
 shape3d only gives rigid sphere... not the free form ellipsoid that I
 want...
 
 
 ? If you run the demo, you'll see ellipsoids...
 
 You just need to work out the appropriate transform to apply to a sphere 
 to get the ellipsoid you want.  I imagine something like this:
 
 sphere - ellipsoid3d(2,2,2, qmesh=TRUE)
 ellipsoid - translate3d(rotate3d(sphere, matrix=chol(S)), xbar, ybar, 
 zbar)
 
 shade3d(ellipsoid)
 
 is what you want, where S is the covariance matrix, and xbar,ybar,zbar 
 have the obvious meaning.  (rotate3d() is used with a matrix that isn't 
 a rotation matrix; it may not be obvious that this is allowed, but it is.)
 
 Duncan Murdoch
 
 

 On 2/2/06, Ben Bolker [EMAIL PROTECTED] wrote:

 Duncan Murdoch murdoch at stats.uwo.ca writes:

 On 2/2/2006 3:39 AM, Michael wrote:

 Hi all,

 How do I visualize a contour of a tri-variate normal distribution?

 I just like to see the ellipsoid very much. I hope there is a easy way

 or

 existing method in R.

 The misc3d package includes a function for 3d contour plots; that 
 should
 do what you want.

   is contour3d really necessary or could you just plot ellipsoids?
 (library(rgl); demo(shapes3d)) -- still a little bit of figuring
 to do, but this should get you most of the way there.

   Ben Bolker

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


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


-- 
620B Bartram Hall[EMAIL PROTECTED]
Zoology Department, University of Floridahttp://www.zoo.ufl.edu/bolker
Box 118525   (ph)  352-392-5697
Gainesville, FL 32611-8525   (fax) 352-392-3704

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


Re: [R] Infinite loop running Mod_R/Rapache

2006-02-03 Thread Jeffrey Horner
BJ wrote:
 I installed mod_r according to the specifications, and have been trying 
 to get the demo script to work correctly. I am running debian, the 
 latest build of R, apache 2 with prefork mpm, and the latest mod_r. Is 
 anyone else using this module successfully? I added:
 
 LoadModule R_module mod_R.so
 Location /test/hello
 SetHandler r-handler
 Rsource /var/www/html/test.R
 RreqHandler handler
 /Location
 
 to my http.conf and
 
 test.R in /var/www/html is:
 
 handler-function(r){
 apache.write(r,h1Hello World!/h1)
 OK
 }
 
 When I start apache2, my /tmp directory fills with rtmp directories 
 until memory is exausted. The first time it created 32,000 before I 
 noticed. Does anyone have any idea as to what I could be doing wrong, or 
 have a software configuration that works? Thank you for all of your 
 help. ~BJ

This is definitely an apache configuration problem. After responding to 
you privately about this issue, I got paranoid and checked the latest 
R/Apache code release (rapache-0.1.1) with the following debian packages:

apache2-common/unstable uptodate 2.0.55-4
apache2-utils/unstable uptodate 2.0.55-4
apache2-mpm-prefork/unstable uptodate 2.0.55-4
apache2-prefork-dev/unstable uptodate 2.0.55-4

I could not reproduce the behavior you are witnessing. Maybe you can 
send me (off-list) your /etc/apache2/apache2.conf, 
/etc/apache2/sites-enabled/* and  see if I can't help you troubleshoot.

But this bit of R creating a temp dir (for transient files?) needs to be 
handled more delicately in a server environment. I'm going to do some 
more digging in the R source... I hope I haven't made some glaringly 
wrong assumptions.

-- 
Jeffrey Horner   Computer Systems Analyst School of Medicine
615-322-8606 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


[R] R-2.2.1-INSTALL Issue with TCLTK

2006-02-03 Thread Bhola, Gautam
Hi 

 

I am not able to have a working tcltk library in R-2.2.1 inspite of
trying different options suggested in the FAQ's. I am using the
following configure option and I do get the tcltk package installed but
with a missing libs folder. 

 

./configure -prefix= ~R-2.2.1  --enable-R-shlib --enable-linux-lfs
--with-zlib --with-gnu-ld --with-tcltk
--with-tcl-config=~tcl-8.4.12/lib --with-tk-config=~tk-8.4.12/lib

 

I have ensured that I have a valid tclsh in my path and have even
provided the include path for covering the tcl.h

 

Operating system: RHEL 

 

The error I get while trying to invoke the libarary for tcltk is:

 

Error in firstlib(which.lib.loc, package) :

 Tcl/Tk support is not available on this system

Error in library(tcltk) : .First.lib failed for 'tcltk'

Execution halted

 

Any help to identify the cause is highly appreciated.

 

Respectfully

Gautam

--
LEGAL NOTICE\ Unless expressly stated otherwise, this messag...{{dropped}}

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


Re: [R] workspace question

2006-02-03 Thread Liaw, Andy
If you start R with the argument --no-restore (or even --vanilla, I think),
no workspace will be loaded.

Personally I almost never save a workspace image.  Whatever I need I
explicitly save() and load() or attach().

Andy

From: Afshartous, David
 
 All,
 
 When starting R, how does one prevent the loading the previous 
 workspace which was saved?  I'd like to start a new project
 and save the new image in a different directory, but I'd like to 
 partition this from the old project.  Does there exist a better
 way than just deleting the files associated w/ the old project
 manually?  I looked in the Intro to R manual and searched for 
 workspace and didn't see anything on this aspect.
 
 Kind regards,
 Dave
 
 ps - please reply directly to [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
 


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


Re: [R] Difficulty with qqline in logarithmic context

2006-02-03 Thread François Pinard
[Brian Ripley]
Is there a good reason to use qqnorm in a single-log context?

Yes.  Googling around reveals this is not so uncommon.

 Should one not rather use

qqnorm(log(freq))
qqline(log(freq))

In the display produced by qqnorm, the y-axis would then show 
log(value) labels, while the user (me!) expects value labels.

since you are (I guess) looking at log-normality of freq?

Once again, I was merely toying with qqplot.  I found intriguing that, 
while shuffling messages around between folders, for a good while, the 
distribution of log(number of messages) per folder appears vagueley 
normal, as I do not quickly see a reasonable justification for this.

Another way to look at that is

qqplot(qlnorm(ppoints(length(freq))), freq, log=xy)

the same plot, different scales.

Interesting, thanks for teaching me about ppoints.  Yet, I stay more 
happy with the abcissa scale produced by qqnorm.  Besides, how would 
one uses qqline with the above?

(I believe a QQ plot should always have comparable scales on the two 
axes.)

While comparable scales are somewhat simpler to compare, this is not 
necessarily what is most adequate for the user.  Proof is that while 
quantiles are being compared here, scales do not show quantiles, but 
units as meaningful to the user.  One might want to compare variables 
scaled very differently, maybe because of different units from the same 
distribution, of from different but similar distributions using 
different scales and shifted to different means.  Or even, why not, if 
this is what is meaningful for users, a log scale.

The point is that qqline is tied to normality, not to log-normality.

As it stands, yes.  As a convenience, it could be extended (probably 
easily) to log-normality.  qqnorm already does something sensible in 
log-context, so a user might expect qqline to do equally well.

The real point might be that qqline is tied to abline a bit too 
blindly.  What is the meaning of intercept and slope of a straight line 
on a graphic in log context?  First, the intercept might not even exist.  
Second, abline interpretation depends on the clippling, and possibly 
on the extrema of the pretty breakpoints chosen for scales, so making it 
hard to predict on average use.   There ought to be some reason for the 
log-aware code in abline, yet I did not find documentation for it.

The wisest for abline, in my very humble opinion, would be for it to 
complain if ever called in log context.  Then, qqline would indirectly 
complain through abline, if qqline is not modified to do something 
more proper.  Moreover, if it is definitely out of question that 
qqline be ever meaningfully called in log context, then so qqnorm, 
which should then complain as well.

Currently, qqline misbehaves, in that it silently produces 
a meaningless result, while it could either diagnose that the result is 
meaningless, or produce a mearningful result.


[Remainder of the reply top-quoted, as usual on r-help.]

On Wed, 1 Feb 2006, François Pinard wrote:

Hi, R friends.  I had some difficulty with the following code:

   qqnorm(freq, log='y')
   qqline(freq)

as the line drawn was seemingly random.  The exact data I used appears
below.  After wandering a bit within the source code for abline,
I figured out I should rather write:

   qqnorm(freq, log='y')
   par(ylog=FALSE)
   qqline(log10(freq))
   par(ylog=TRUE)

I'm proposing that this little stunt be rather be hidden and
automatically effected within qqline proper, whenever par('ylog') is
TRUE.  I thought about providing a patch, as qqline is so small.  Yet
it would be more noise than useful, as I'm not familiar with the datax
argument usage, which should probably be addressed as well.



Here is the data, in case useful:

freq -
as.integer(c(33, 79, 21, 436, 58, 18, 1106, 498, 1567, 393, 2,
104, 50, 67, 113, 76, 327, 331, 196, 145, 86, 59, 12, 215, 293,
154, 500, 314, 246, 587, 85, 23, 323, 3, 13, 576, 29, 37, 24,
21, 1230, 137, 13, 93, 3, 101, 72, 218, 59, 17, 2, 8, 86, 143,
150, 22, 19, 234, 119, 157, 4, 255, 146, 126, 76, 15, 271, 170,
4, 6, 16, 3048, 2175, 3350, 5017, 5706, 1610, 665, 322, 1, 16,
47, 51, 168, 94, 66, 154, 99, 11, 547, 953, 1, 1071, 80, 184,
168, 52, 187, 103, 187, 361, 46, 85, 135, 597, 121, 283, 26,
12, 20, 169, 9, 79, 15, 114, 75, 30, 111, 556, 173, 32, 99, 438,
2, 2, 1, 117, 5, 3, 51, 8, 41, 12, 23, 2, 13, 5, 1, 9, 4, 1,
7, 15, 5, 48, 16, 112, 6, 1, 39, 60, 5, 23, 5, 19, 1, 8, 32,
4, 13, 1, 14, 71, 5, 1, 35, 30, 100, 389, 22, 8, 1, 192, 40,
6, 3, 17, 2, 14, 71, 14, 1, 5, 4, 32, 21, 18, 13, 2, 2, 45, 342,
46, 144, 18, 131, 188, 112, 37, 85, 90, 8, 195, 173, 5, 53, 96,
37, 16, 16, 281, 64, 50, 92, 336, 31, 744, 4, 134, 74, 1, 227,
6, 48, 418, 64, 66, 59, 20, 45, 20, 370, 148, 22, 7, 30, 601,
29, 82, 113, 938, 252, 65, 137, 72, 22, 98, 12, 152, 212, 13,
8, 35, 3, 77))

Yet this really is the value of courriel$freq after data(courriel),
with a file .../R/data/courriel.R here, holding:

courriel - read.table(pipe('grep -c 

Re: [R] Clustering for social/complex networks

2006-02-03 Thread Christian Schulz
try:

cmeans Fuzzy C-Means Clustering in library(e1071)

regards, christian

Hi group,

Here is another clustering question.  Is there
anything available in R that I can cluster groups with
overlaps?  It looks like a Venn Diagram with two or
more circles overlapping one another.  

I realize that Hierarchical Clustering (hclust in
Stats) only group individuals into distinct groups. 
My scenario is I have to group Physicians that each of
them may belong to more than one group.  That reflects
the complexity of relationhip, something analogous to
Social Network.  

Thanks!

kel

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


  


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


[R] Function assign

2006-02-03 Thread Marco Venanzi
I'm trying to apply the function assign( ) to a subset of a matrix, but it 
doesn't work...

i.e.

example-matrix(nrow=5,ncol=5)
assign(example[c(1,3),],matrix(1:10,nrow=2,ncol=5))

but matrix example doesn't change ( get(example[c(1,3),]) is not useful to 
me)...how can I do this assignment?
Thanks in advance,

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


Re: [R] Function assign

2006-02-03 Thread Ferdinand Alimadhi
example-matrix(nrow=5,ncol=5)
example[c(1,3),]-matrix(1:10,nrow=2,ncol=5)



Marco Venanzi wrote:

I'm trying to apply the function assign( ) to a subset of a matrix, but it 
doesn't work...

i.e.

example-matrix(nrow=5,ncol=5)
assign(example[c(1,3),],matrix(1:10,nrow=2,ncol=5))

but matrix example doesn't change ( get(example[c(1,3),]) is not useful to 
me)...how can I do this assignment?
Thanks in advance,

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



-- 
Ferdinand Alimadhi
Programmer / Analyst
Harvard University
The Institute for Quantitative Social Science
(617) 496-0187
[EMAIL PROTECTED]
www.iq.harvard.edu

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


Re: [R] R-2.2.1-INSTALL Issue with TCLTK

2006-02-03 Thread Prof Brian Ripley
Those don't look like valid paths to config files to me.  On FC3 they 
would be

/usr/lib/tclConfig.sh
/usr/lib/tkConfig.sh

So even if you have users tcl-8.4.12 and tk-8.4.12 (do you?), your paths 
are almost surely not to config files.

Configure reports what works, including that it is not going to build 
tcl/tk support.  Look back at the relevant parts of its output.

On Fri, 3 Feb 2006, Bhola, Gautam wrote:

 Hi



 I am not able to have a working tcltk library in R-2.2.1 inspite of
 trying different options suggested in the FAQ's. I am using the
 following configure option and I do get the tcltk package installed but
 with a missing libs folder.



 ./configure -prefix= ~R-2.2.1  --enable-R-shlib --enable-linux-lfs
 --with-zlib --with-gnu-ld --with-tcltk
 --with-tcl-config=~tcl-8.4.12/lib --with-tk-config=~tk-8.4.12/lib



 I have ensured that I have a valid tclsh in my path and have even
 provided the include path for covering the tcl.h



 Operating system: RHEL



 The error I get while trying to invoke the libarary for tcltk is:



 Error in firstlib(which.lib.loc, package) :

 Tcl/Tk support is not available on this system

 Error in library(tcltk) : .First.lib failed for 'tcltk'

 Execution halted



 Any help to identify the cause is highly appreciated.



 Respectfully

 Gautam

 --
 LEGAL NOTICE\ Unless expressly stated otherwise, this messag...{{dropped}}

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


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


[R] all.equal() and which()

2006-02-03 Thread tom wright
Please excuse the lack of a complete dataset here, if its needed I'll be
happy to provide it.
Can anyone show me how to rewrite this?

Browse[1] time(data)[24210:24220]
[1] 24.209 24.210 24.211 24.212 24.213 24.214 24.215 24.216 24.217 
[10] 24.218 24.219

Browse[1] which(time(data)==24.211)
numeric(0)

I'm assuming its an eps fault but
which(all.equal(time(data),24.211))

dosnt seem to work

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


Re: [R] all.equal() and which()

2006-02-03 Thread Marc Schwartz (via MN)
On Fri, 2006-02-03 at 10:41 -0500, tom wright wrote:
 Please excuse the lack of a complete dataset here, if its needed I'll be
 happy to provide it.
 Can anyone show me how to rewrite this?
 
 Browse[1] time(data)[24210:24220]
 [1] 24.209 24.210 24.211 24.212 24.213 24.214 24.215 24.216 24.217 
 [10] 24.218 24.219
 
 Browse[1] which(time(data)==24.211)
 numeric(0)
 
 I'm assuming its an eps fault but
 which(all.equal(time(data),24.211))
 
 dosnt seem to work


There might be an easier way, but here is one approach:

 mydat
 [1] 24.209 24.210 24.211 24.212 24.213 24.214 24.215 24.216 24.217
[10] 24.218 24.219

 which(sapply(mydat, function(x) isTRUE(all.equal(24.211, x
[1] 3


This uses sapply() to check each element of 'mydat' against the target
value of 24.211.  The use of 'isTRUE(all.equal(...))' returns a boolean
result of either TRUE or FALSE, enabling the use of which() against the
vector returned from sapply():

 sapply(mydat, function(x) isTRUE(all.equal(24.211, x)))
 [1] FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE

See ?all.equal and ?isTRUE for more information.

HTH,

Marc Schwartz

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


[R] Using string vectors as for loop arguments

2006-02-03 Thread Kevin Middleton
Is there a mechanism to interate through a vector of strings? Say I  
have a data frame of 50 variables (VAR1 to VAR50), each with 100  
measurements along with some coding factors (EXP and DOSE). I want to  
calculate the mean of a subset of each of VAR1 to VAR 50 (selecting  
by EXP and DOSE). Rather than just copy/pasting the same code 50  
times, I thought of using a for loop to go through a vector of VAR1  
to VAR50 (VAR.LIST below). Each iteration would be the variable name  
for which the mean would be calculated.

Trying this, I get an error that the argument is not numeric or  
logical. So I assume that for loops with vectors of strings are  
disallowed. What I am wondering is whether there a way to mimic this  
sort of procedure?

The code looked something like this:

VAR.LIST-paste(c(VAR), 1:50, sep=)

for (i in VAR.LIST){
mean(i[EXP==1  DOSE==1], na.rm=T)
}



Thanks
Kevin Middleton

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


Re: [R] statistical modelling SAS vs R

2006-02-03 Thread Wensui Liu
bill,

what kind of modeling are you talking about? based on your desc on SAS, you
are doing general linear model, aren't you?

Frank gave you a great suggestion of using shrinkage methods, such as lasso,
instead of stepwise/backforward/forward methods. But no matter shrinkage or
stepwise, both can be implemented in R and SAS. At this point, there is no
difference at all.

On 2/3/06, Bill Szkotnicki [EMAIL PROTECTED] wrote:

 Hello,

 Recently I have been reading a lot of material about statistical modeling
 using R. There seems to be conflicting opinions about what the best
 approach
 is between the SAS community and the R community.
 1) In R one might start with a model that has all possible effects of
 interest in it and then simplify by eliminating/adding insignificant
 effects
 using a stepwise procedure.
 2) In SAS one may starts with a reasonable model and look at type 3 SS's
 to test hypotheses and report LSMEANS. This can be done in R too I think.

 Does anyone have current opinions about this? I know it's been discussed
 before but I would be very interested in hearing about the advantages and
 pitfalls of both approaches.

 Bill

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




--
WenSui Liu
(http://statcompute.blogspot.com)
Senior Decision Support Analyst
Health Policy and Clinical Effectiveness
Cincinnati Children Hospital Medical Center

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


[R] How to generate pitch strings

2006-02-03 Thread Atte Tenkanen
If I calculate a transition probability matrix, first order markov 12x12
or second order 144x144 from musical pitch classes (0-11), is it possible
to generate pitch class strings similar as those original strings using
those probability matrix with R? If, how?

Atte Tenkanen, Turku, Finland

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


Re: [R] Using string vectors as for loop arguments

2006-02-03 Thread Berton Gunter
?apply

as in:

answer-apply(yourframe,2,function(x)x[EXP==1  DOSE==1])

Note that there are slicker ways to do this call.
Note also for that for the particular case of column means, you have a
built-in much faster alternative:

answer-colMeans(yourframe[EXP==1  DOSE==1,],na.rm=TRUE)

Also note that the == construction may be problematic if EXP or DOSE are not
factors, say.

Finally, you need to start reading the R docs to learn about this yourself.
An Introduction to R is a good place to start.

Oh... and your attempt below will certainly not work. After you read the
basic docs, you'll see why not.


-- Bert Gunter
Genentech Non-Clinical Statistics
South San Francisco, CA


 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Kevin Middleton
 Sent: Friday, February 03, 2006 1:41 PM
 To: r-help@stat.math.ethz.ch
 Subject: [R] Using string vectors as for loop arguments
 
 Is there a mechanism to interate through a vector of strings? Say I  
 have a data frame of 50 variables (VAR1 to VAR50), each with 100  
 measurements along with some coding factors (EXP and DOSE). I 
 want to  
 calculate the mean of a subset of each of VAR1 to VAR 50 (selecting  
 by EXP and DOSE). Rather than just copy/pasting the same code 50  
 times, I thought of using a for loop to go through a vector of VAR1  
 to VAR50 (VAR.LIST below). Each iteration would be the variable name  
 for which the mean would be calculated.
 
 Trying this, I get an error that the argument is not numeric or  
 logical. So I assume that for loops with vectors of strings are  
 disallowed. What I am wondering is whether there a way to mimic this  
 sort of procedure?
 
 The code looked something like this:
 
 VAR.LIST-paste(c(VAR), 1:50, sep=)
 
 for (i in VAR.LIST){
   mean(i[EXP==1  DOSE==1], na.rm=T)
   }
 
 
 
 Thanks
 Kevin Middleton
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html


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


Re: [R] RHOME

2006-02-03 Thread Prof Brian Ripley
On Fri, 3 Feb 2006, Peter Dalgaard wrote:

 Martin Maechler [EMAIL PROTECTED] writes:

 Martyn R is designed to run from its build directory.  But
 Martyn if your sysadmin installs it with make install (as
 Martyn root), then the shell wrapper that is installed in
 Martyn /usr/local/bin/R will have R_HOME pointing to the
 Martyn right location (/usr/local/lib/R).  Literally moving
 Martyn the build directory to another location is the wrong
 Martyn thing to do.

 well, but very easily fixable, and that's what Daniel is asking
 for:

 The default value of R_HOME is only set in exactly one place,
 namely the 'R' shell script; editing that script - once after
 the move - is really a piece o'cake.

 Hmm, I was about to say the same, but there seems to be unexpected
 references in other places.

 find `R RHOME` | xargs grep `R RHOME`
 /usr/lib64/R/bin/R:R_HOME_DIR=/usr/lib64/R
 /usr/lib64/R/bin/R:R_SHARE_DIR=/usr/lib64/R/share
 /usr/lib64/R/bin/R:R_INCLUDE_DIR=/usr/lib64/R/include
 /usr/lib64/R/bin/R:R_DOC_DIR=/usr/lib64/R/doc

 (this doesn't normally happen - a SUSE RPM specialty, or due to
 configure flag settings?)

That only happens in the installed copy.  Martin is right if one is 
talking about moving the build tree (and Martyn is right that there is a 
lot of stuff that does not need to be installed in the build tree and that 
`make install' takes all the strain of copying the right bits).

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


[R] Cause of Error 1:nrow(X) : argument NA / NaN

2006-02-03 Thread Jean-Louis Abitbol
Dear R Helpers

I am trying to get function smedian.hilow to work using Hmisc summarize
on variable conc in dataframe pkindivmtd by time and dose using:

attach(pkindivmtd)
sconc - summarize(conc,llist(time,dose),smedian.hilow)

I get the error message

Erreur dans 1:nrow(X) : argument NA / NaN

Contents of pkindivmtd is 

 contents(pkindivmtd)

Data frame:pkindivmtd   1296 observations and 9 variablesMaximum #
NAs:0

Labels Units Levels Storage
dose  Dosemginteger
day integer
hourinteger
subjectSubject  integer
conc Concentration ng/mL double
fday 10 integer
fsubject 37 integer
fdose Dose4 integer
time  Time hoursinteger

.
 

What I am doing wrong ?

Sorry for not providing a reproducible example as when I generate
randomly the 3 variables it works ! 

Many thanks,

Jean-Louis

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


[R] Tobit Regression

2006-02-03 Thread bambang pramono
I'm statistician
I have thesis : Tobit Regression
my book : Greene, William H. 1997. Econometric Analysis. Third
Edition, prentice Hall
Is there the program in R ?
may I ask the manual how make the program? and also how to test the assumption ?
If there are anyone have Amemiya journal may I asked ?

please help me! I already googling and I don't get the answer.
Before i use STATA 6 to analyze. but I don't get the manual.

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


[R] rgl install problem on Solaris 10 X86

2006-02-03 Thread Dongseok Choi
Hi,
 
  Could you help me to install the rgl package on Solaris 10 x86?
  I tried and got the following error messages.
  When I compiled my R as 64bit, I used the SUN ProW compilers.
  However, gcc seems to being used below as well as missing some information.
 
Thank you in advance,
Dongseok
 
 install.packages(rgl)
--- Please select a CRAN mirror for use in this session ---
* Installing *source* package 'rgl' ...
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking how to run the C preprocessor... gcc -E
checking for X... libraries /usr/openwin/lib, headers /usr/openwin/include
 
checking for libpng-config... yes
configure: creating ./config.status
config.status: creating src/Makevars
** libs
CC -xtarget=generic64 -I/export/home/choid/bin/R2.2.1/lib/R/include 
-I/usr/openwin/include -DHAVE_PNG_H -I/usr/include/libpng12 
-I/mounts/devel/SUNWspro/prd/include 
-I/mounts/devel/GNU/repoz/readline43/include   -KPIC  -O -xlibmil -dalign 
-I/mounts/devel/SUNWspro/prod/include -c api.cpp -o api.o
CC: Warning: Option -dalign passed to ld, if ld is invoked, ignored otherwise
CC -xtarget=generic64 -I/export/home/choid/bin/R2.2.1/lib/R/include 
-I/usr/openwin/include -DHAVE_PNG_H -I/usr/include/libpng12 
-I/mounts/devel/SUNWspro/prd/include 
-I/mounts/devel/GNU/repoz/readline43/include   -KPIC  -O -xlibmil -dalign 
-I/mounts/devel/SUNWspro/prod/include -c Background.cpp -o Background.o
CC: Warning: Option -dalign passed to ld, if ld is invoked, ignored otherwise
Background.cpp, line 54: Warning: boundingBox hides Shape::boundingBox.
1 Warning(s) detected.
CC -xtarget=generic64 -I/export/home/choid/bin/R2.2.1/lib/R/include 
-I/usr/openwin/include -DHAVE_PNG_H -I/usr/include/libpng12 
-I/mounts/devel/SUNWspro/prd/include 
-I/mounts/devel/GNU/repoz/readline43/include   -KPIC  -O -xlibmil -dalign 
-I/mounts/devel/SUNWspro/prod/include -c BBoxDeco.cpp -o BBoxDeco.o
CC: Warning: Option -dalign passed to ld, if ld is invoked, ignored otherwise
CC -xtarget=generic64 -I/export/home/choid/bin/R2.2.1/lib/R/include 
-I/usr/openwin/include -DHAVE_PNG_H -I/usr/include/libpng12 
-I/mounts/devel/SUNWspro/prd/include 
-I/mounts/devel/GNU/repoz/readline43/include   -KPIC  -O -xlibmil -dalign 
-I/mounts/devel/SUNWspro/prod/include -c Color.cpp -o Color.oCC: Warning: 
Option -dalign passed to ld, if ld is invoked, ignored otherwise
Color.cpp, line 142: Error: The function realloc must have a prototype.
Color.cpp, line 159: Error: The function realloc must have a prototype.
Color.cpp, line 160: Error: The function memcpy must have a prototype.
Color.cpp, line 168: Error: The function free must have a prototype.
Color.cpp, line 175: Error: The function realloc must have a prototype.
Color.cpp, line 196: Error: The function realloc must have a prototype.
Color.cpp, line 247: Error: The function realloc must have a prototype.
7 Error(s) detected.
*** Error code 7
make: Fatal error: Command failed for target `Color.o'
ERROR: compilation failed for package 'rgl'
** Removing '/export/home/choid/bin/R2.2.1/lib/R/library/rgl'
 
The downloaded packages are in
/tmp/Rtmp9Yaawc/downloaded_packages
 



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


Re: [R] rgl install problem on Solaris 10 X86

2006-02-03 Thread Duncan Murdoch
On 2/3/2006 6:37 PM, Dongseok Choi wrote:
 Hi,
  
   Could you help me to install the rgl package on Solaris 10 x86?

No, but there have been a lot of changes to it since the last upload to 
CRAN.  You might want to grab a new copy from 
http://rgl.neoscientists.org/About.html by getting the latest Subversion 
checkout.

Duncan Murdoch


   I tried and got the following error messages.
   When I compiled my R as 64bit, I used the SUN ProW compilers.
   However, gcc seems to being used below as well as missing some information.
  
 Thank you in advance,
 Dongseok
  
 install.packages(rgl)
 --- Please select a CRAN mirror for use in this session ---
 * Installing *source* package 'rgl' ...
 checking for gcc... gcc
 checking for C compiler default output file name... a.out
 checking whether the C compiler works... yes
 checking whether we are cross compiling... no
 checking for suffix of executables...
 checking for suffix of object files... o
 checking whether we are using the GNU C compiler... yes
 checking whether gcc accepts -g... yes
 checking for gcc option to accept ANSI C... none needed
 checking how to run the C preprocessor... gcc -E
 checking for X... libraries /usr/openwin/lib, headers /usr/openwin/include
  
 checking for libpng-config... yes
 configure: creating ./config.status
 config.status: creating src/Makevars
 ** libs
 CC -xtarget=generic64 -I/export/home/choid/bin/R2.2.1/lib/R/include 
 -I/usr/openwin/include -DHAVE_PNG_H -I/usr/include/libpng12 
 -I/mounts/devel/SUNWspro/prd/include 
 -I/mounts/devel/GNU/repoz/readline43/include   -KPIC  -O -xlibmil -dalign 
 -I/mounts/devel/SUNWspro/prod/include -c api.cpp -o api.o
 CC: Warning: Option -dalign passed to ld, if ld is invoked, ignored otherwise
 CC -xtarget=generic64 -I/export/home/choid/bin/R2.2.1/lib/R/include 
 -I/usr/openwin/include -DHAVE_PNG_H -I/usr/include/libpng12 
 -I/mounts/devel/SUNWspro/prd/include 
 -I/mounts/devel/GNU/repoz/readline43/include   -KPIC  -O -xlibmil -dalign 
 -I/mounts/devel/SUNWspro/prod/include -c Background.cpp -o Background.o
 CC: Warning: Option -dalign passed to ld, if ld is invoked, ignored otherwise
 Background.cpp, line 54: Warning: boundingBox hides Shape::boundingBox.
 1 Warning(s) detected.
 CC -xtarget=generic64 -I/export/home/choid/bin/R2.2.1/lib/R/include 
 -I/usr/openwin/include -DHAVE_PNG_H -I/usr/include/libpng12 
 -I/mounts/devel/SUNWspro/prd/include 
 -I/mounts/devel/GNU/repoz/readline43/include   -KPIC  -O -xlibmil -dalign 
 -I/mounts/devel/SUNWspro/prod/include -c BBoxDeco.cpp -o BBoxDeco.o
 CC: Warning: Option -dalign passed to ld, if ld is invoked, ignored otherwise
 CC -xtarget=generic64 -I/export/home/choid/bin/R2.2.1/lib/R/include 
 -I/usr/openwin/include -DHAVE_PNG_H -I/usr/include/libpng12 
 -I/mounts/devel/SUNWspro/prd/include 
 -I/mounts/devel/GNU/repoz/readline43/include   -KPIC  -O -xlibmil -dalign 
 -I/mounts/devel/SUNWspro/prod/include -c Color.cpp -o Color.oCC: Warning: 
 Option -dalign passed to ld, if ld is invoked, ignored otherwise
 Color.cpp, line 142: Error: The function realloc must have a prototype.
 Color.cpp, line 159: Error: The function realloc must have a prototype.
 Color.cpp, line 160: Error: The function memcpy must have a prototype.
 Color.cpp, line 168: Error: The function free must have a prototype.
 Color.cpp, line 175: Error: The function realloc must have a prototype.
 Color.cpp, line 196: Error: The function realloc must have a prototype.
 Color.cpp, line 247: Error: The function realloc must have a prototype.
 7 Error(s) detected.
 *** Error code 7
 make: Fatal error: Command failed for target `Color.o'
 ERROR: compilation failed for package 'rgl'
 ** Removing '/export/home/choid/bin/R2.2.1/lib/R/library/rgl'
  
 The downloaded packages are in
 /tmp/Rtmp9Yaawc/downloaded_packages
 
 
 
   [[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

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


Re: [R] RHOME

2006-02-03 Thread Dan Powers
R-help

My thanks goes out to all who responded to this. I am tying to avoid
burdening the sysadmin with this project so I opted for the simple fix of
modifying the shell script. My aim here is to build the libraries in my
local directory and copy those as needed to /usr/local/lib/R/library. I will
have to direct the sysadmin in the installation of future versions of R.

Cheers,
Dan


Daniel A. Powers, Ph.D.
Department of Sociology
University of Texas at Austin
1 University Station A1700
Austin, TX  78712-0118
phone: 512-232-6335
fax:   512-471-1748
[EMAIL PROTECTED]


-Original Message-
From: Martyn Plummer [mailto:[EMAIL PROTECTED]
Sent: Friday, February 03, 2006 9:46 AM
To: Peter Dalgaard
Cc: Martin Maechler; Daniel A. Powers; r-help@stat.math.ethz.ch
Subject: Re: [R] RHOME


Far be it for me to tell people what they can and cannot do. Perhaps I
can rephrase myself in a less inflammatory way.

R runs from the build directory as a convenience for developers, so you
don't have to reinstall R every time you change something. But for
users, the standard mechanism make install has a number of advantages
over moving the build directory to a publicly accessible location: it is
guaranteed to work, you don't have to do any post-hoc editing of files,
it takes up a lot less space, about 4.6 times less on my system

[EMAIL PROTECTED] r-devel]$ du -sh R
356MR
[EMAIL PROTECTED] r-devel]$ du -sh /usr/local/lib64/R
77M /usr/local/lib64/R

But if you do want to copy the build directory the, as Martin says,
you can edit the file bin/R so that the line that starts
R_HOME_DIR points to the correct location, e.g.

R_HOME_DIR=/usr/local/lib/R

M.

On Fri, 2006-02-03 at 14:48 +0100, Peter Dalgaard wrote:
 Martin Maechler [EMAIL PROTECTED] writes:

  Martyn R is designed to run from its build directory.  But
  Martyn if your sysadmin installs it with make install (as
  Martyn root), then the shell wrapper that is installed in
  Martyn /usr/local/bin/R will have R_HOME pointing to the
  Martyn right location (/usr/local/lib/R).  Literally moving
  Martyn the build directory to another location is the wrong
  Martyn thing to do.
 
  well, but very easily fixable, and that's what Daniel is asking
  for:
 
  The default value of R_HOME is only set in exactly one place,
  namely the 'R' shell script; editing that script - once after
  the move - is really a piece o'cake.

 Hmm, I was about to say the same, but there seems to be unexpected
 references in other places.

 find `R RHOME` | xargs grep `R RHOME`
 /usr/lib64/R/bin/R:R_HOME_DIR=/usr/lib64/R
 /usr/lib64/R/bin/R:R_SHARE_DIR=/usr/lib64/R/share
 /usr/lib64/R/bin/R:R_INCLUDE_DIR=/usr/lib64/R/include
 /usr/lib64/R/bin/R:R_DOC_DIR=/usr/lib64/R/doc

 (this doesn't normally happen - a SUSE RPM specialty, or due to
 configure flag settings?)

I think this is normal. But the RedHat RPM behaves differently.

(because the RPM build process installs into a temporary build root
which is distinct from the final installation directory, requiring more
sed voodoo).


 Once you start building packages, you also have things like

 viggo:~/find ~/Rlibrary | xargs grep `R RHOME`
 Binary file /home/bs/pd/Rlibrary/rgl/libs/rgl.so matches


 viggo:~/find ~/Rlibrary | xargs grep Rlibrary
 Binary file /home/bs/pd/Rlibrary/rgl/Meta/hsearch.rds matches
 Binary file /home/bs/pd/Rlibrary/ISwR/Meta/hsearch.rds matches
 Binary file /home/bs/pd/Rlibrary/mvtnorm/Meta/hsearch.rds matches
 Binary file /home/bs/pd/Rlibrary/nlmeODE/Meta/hsearch.rds matches
 B.

 on my laptop I had a hit on one of the Sweave support files too.

 Most likely these are quite harmless, but all in all I think Martyn
 has the safest advice: Use make install, as root (don't forget
 umask 022).


---
This message and its attachments are strictly confidential. ...{{dropped}}

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


Re: [R] weights argument in the lmer function in lme4

2006-02-03 Thread Spencer Graves
  I agree:  The lmer weights argument seems not to have any effect.  To 
check this, I modified the first example in the lmer documentation as 
follows:

Sleep - sleepstudy
Sleep$wts - 1:180
(fm1 - lmer(Reaction ~ Days + (Days|Subject), Sleep))
(fm1w - lmer(Reaction ~ Days + (Days|Subject),
  weights=wts, Sleep))

  The numbers from both seemed to be the same.  To try to help diagnose 
this, I listed lmer, and found that it consisted of a call to 
standardGeneric.  Then 'getMethods(lmer)' listed only one method 
for the case where the argument formula had class formula.  I tried 
to trace this further, e.g., by giving it a different name and using 
debug.  After being stopped a couple of time by functions hidden in 
the Matrix namespace, I gave ups.

  However, at least you know that it's not you.  And I've included Doug 
Bates as a cc so he can use this info as he sees fit.

  hope this helps.
  spencer graves

  sessionInfo()
R version 2.2.1, 2005-12-20, i386-pc-mingw32

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

other attached packages:
  lme4   latticeMatrix
0.995-2 0.12-11 0.995-4
   

Patrick Connolly wrote:

 I suspect the weights argument is not having any effect.
 
 Package:  Matrix
 Version:  0.995-2
 Date: 2006-01-19
 
 
 Beginning with this:
 
 Browse[1]   resp.lmer - lmer(SensSSC ~ Block + Season + (1 | Plot) + (1 | 
 Ma) + (1 | Pa) + 
 + (1 | MaPa), weights = SensSSC.N, data = xx)
 
 I group the output into a table with my ran.eff function and get this:
 
 Browse[1] ran.eff(resp.lmer)
   01 02 03 04 05 06 07   GCAf RankF
 A 13.714 13.709 13.886 14.124 15.120 13.546 14.586  0.472 1
 B 13.452 NA 13.426 13.632 14.439 13.512 13.713  0.069 3
 C 13.922 13.770 14.353 NA 14.661 13.529 14.367  0.453 2
 D NA NA 13.353 NA NA NA NA -0.051 4
 E 12.775 12.767 12.823 12.767 14.036 12.631 13.645 -0.495 6
 F 13.043 13.338 12.641 12.977 13.848 12.425 13.530 -0.448 5
 GCAm  -0.200 -0.169 -0.165 -0.103  0.736 -0.428  0.329 NANA
 RankM  6.000  5.000  4.000  3.000  1.000  7.000  2.000 NANA
 
 
 Despite any shortcomings in my ran.eff function, those values look
 alright, but they're the same (to any number of decimal places) as I'd
 get without a weights argument.  Just to check that the weights really
 don't effect it, I tried using only the rows with a weight of 5
 (almost 90% of the data) but it was substantially different.
 
 Browse[1]   resp.lmer5 - lmer(SensSSC ~ Block + Season + (1 | Plot) + (1 | 
 Ma) + (1 | Pa) + 
 + (1 | MaPa), subset = SensSSC.N == 5, data = xx)
 
 Browse[1] ran.eff(resp.lmer5)
   01 02 03 04 05 06 07   GCAf RankF
 A 13.435 13.349 13.595 13.914 14.722 13.161 14.414  0.345 2
 B 13.068 NA 13.110 13.447 14.121 13.296 13.637 -0.014 4
 C 13.702 13.537 14.256 NA 14.371 13.575 14.247  0.469 1
 D NA NA 13.276 NA NA NA NA -0.001 3
 E 12.717 12.659 12.786 12.719 13.642 12.659 13.556 -0.425 6
 F 13.015 13.101 12.549 12.920 13.629 12.438 13.474 -0.374 5
 GCAm  -0.210 -0.230 -0.146 -0.049  0.596 -0.353  0.391 NANA
 RankM  5.000  6.000  4.000  3.000  1.000  7.000  2.000 NANA
 
 That seems to indicate that weights cannot be readily ignored.
 
 Has anyone had experience to indicate that the weights argument does
 produce a difference, and so I should be looking somewhere else for
 the reason why I'm getting such results?
 
 
 TIA


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


Re: [R] Density estimation with monotonic constaints

2006-02-03 Thread Spencer Graves
  There are multiple functions for density estimation in R, but I don't 
know of any for estimating a monotonically decreasing density.  If you 
haven't already, I encourage you to use, e.g., the help.search and 
RSiteSearch functions to find and explore their capabililties.

  Why do you ask?  Are you interested in analyzing particular data 
set(s) or are you doing research on density estimation?

  If it were my problem, I might just try something like the function 
density and then evaluate the results to find out if it satisfied my 
constraints.  If it did and if I were only interested in that data set, 
I'd be done.  If not, I'd increase the smoothing until I got something 
that was monotonic.  If I wanted a more general method, I might wrap a 
call to a function like density inside another function, and 
automatically adjust the smoothing until it satisfied some optimality 
criterion I might devise.  If I didn't get what I wanted doing that, I 
might list, e.g., the density function and walk through it line by 
line until I figured out what I needed to change to get what I wanted. 
I just listed density and found that it consists solely of a call to 
UseMethod.  To get beyond that, I tried 'methods(density), which 
told me there was only one method called density.default.  Then 
requesting density.default gave me the code for that.  Another tip:  I 
find debug extrememly helpeful for walking through code like this.

  I suspect this will not solve your problem, but I hope at least it 
helps.  If you'd like further assistance from this listserve, please 
submit another post.  However, I encourage you first to PLEASE do read 
the posting guide! www.R-project.org/posting-guide.html.  Doing so 
might increase your chances for getting useful information more quickly.

  spencer graves

Debayan Datta wrote:
 Hi All,
I have a sample x={x1,x2,..,xn} fom a distribution with density f. I 
 wish to estimate the density. I know a priori that the density is 
 monotonically decreasing. Is there a way to do this in R?
 Thanks
 Debayan
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

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


Re: [R] output hessian matrix in constrOptim

2006-02-03 Thread Spencer Graves
  The documentation for constrOptim says it has a ... argument, 
which can contain Other arguments passed to 'optim', which will pass 
them to 'f' and 'grad' if it does not used them.  I routinely get an 
estimated hessian from 'optim' just by specifying the argument 
'hessian=TRUE'.  This led me to try the following

# an example from 'constrOptim' that works:
  fQP - function(b) {-sum(c(0,5,0)*b)+0.5*sum(b*b)}
  Amat   - matrix(c(-4,-3,0,2,1,0,0,-2,1),3,3)
  bvec   - c(-8,2,0)
  constrOptim(c(2,-1,-1), fQP, NULL, ui=t(Amat),ci=bvec)

# The following generated an error:
constrOptim(c(2,-1,-1), fQP, NULL, ui=t(Amat),ci=bvec,
 hessian=TRUE)
Error in f(theta, ...) : unused argument(s) (hessian ...)

  If it were my problem, I might first try 'fit - constrOptim(...)'. 
Then if the optimum was NOT at a constraint, I'd use the outpt from 
'constrOptim' as an input to optim with 'hessian=TRUE'.  If it was at 
a constraint, I'd have to think very carefully about what I wanted in 
terms of a hessian, because that does not seem obvious to me at the 
moment.  Then I'd program something to get that.  If I wanted more than 
that, I'd list 'constrOptim' and / or 'optim', and walk through them 
line by line using debug until I figured out what I wanted to do next.

  If you'd like more help from this listserve, please submit another 
post -- but first, PLEASE do read the posting guide! 
http://www.R-project.org/posting-guide.html.

  hope this helps,
  spencer graves

liu wrote:

 Hi, 
 
 Is there any way to get the hessian matrix from the constrOptim  
function without supplying gradient function?   Thanks.
 
 
 
   
 -
 Bring words and photos together (easily) with
 
   [[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

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


[R] RUnit - need advice on a good directory structure or tips...

2006-02-03 Thread Sung Soo Kim
I made my own RUnit testing convention, and I want to introduce this to one
of my friends.
Before that, I'd like to review my codes.

The problem that I met when I tried to polish my codes is: How can I get the
file path in the file???
I.e., I want to get the path to the file that I'm writing using some magic R
functions. But I couldn't find any good magic.
Is there any magic?

So, I made a convention.
1. Put both testr files and suite...r files in the same directory.
2. Current working path should be the same directory as that of test files.
3. In test files, use .setUp and .tearDown functions to properly modify
current working directory.
4. 'source' the source codes to test them.

This is pretty much restriction, and I want to reduce the number of
restrictions.
More specifically, if the function defineTestSuite support optionally
setting current working directory to that of test files, it would be great
help, because it can remove the need of placing both test files and suite
files in the same directory.
But the best solution is the way to get the path to the file of the current
file.

BTW, here is an example. I welcome any kind of advice.

==

There are three files. Two are in the tests
directory(suite_foo.r   test_foo.r), and the other one is in the codes
directory (foo.r).

In your R prompt, do setwd(path to test directory) and then do
source(suite_foo.r) to run tests.

==

##
##  ../tests/test_foo.r
##
##  A test file sample.
##
##  Restrictions.
##Because of current directory problem, here I suggest convention.
##
##1. The testSuite files and test files should be in the same directory
like this example.
##
##2. Always include the following five objects in your own test file
##as it is shown in this example and modify them as you want.
##  (-  pathToCode, codeFileName, currentPath, .setUp, .tearDown)
##
##3. Then, properly change the pathToCode and the codeFileName.
##You can add your own codes to .setUP and .tearDown.
##
##4. Use one test file for each code file. This is a good practice.
##
##

pathToCode - ../codes## relative path to code directory.
codeFileName - foo.r ## code file name in 'pathToCode' directory

currentPath - getwd()
.setUp - function() {  ## called before each test case. Add your own codes.
  setwd(paste(currentPath,pathToCode,sep=/))
  source(codeFileName)
  print(.setUp)
}
.tearDown - function() {  ## called before each test case. Add your own
codes.
  setwd(currentPath)
  print(.tearDown)
}


##
##
##  Start of test functions.
##
##  Add your own test functions with names starting with test
##
##


test.c2f - function() {
#  print(currentPath)
  checkEquals(c2f(0), 32)
  checkEquals(c2f(10), 50)
  checkException(c2f(xx))
}

test.f2c - function() {
  checkEquals(f2c(32), 0)
  checkEquals(f2c(50), 10)
  checkTrue(identical(f2c(50),10))
  checkException(f2c(xx))
}

test.errordemo - function() {
  DEACTIVATED(Fanta long star king)
  stop(this is just to show what an error looks like as opposed to a
failure)
}





==



##
##  ../tests/suite_foo.r
##
##  A testSuite file sample
##
##  Restrictions.
##Because of current directory problem, here I suggest convention.
##
##1. A testSuite file should be in the same directory as that of test
files.
##
##2. A testSuite file should be sourced (or executed)
##ONLY WHEN the 'current working directory' of R is in that of the
restSuite file.
##
##3. The name of a testSuite file must start with 'suite', not 'test'.
##
##

library(RUnit)

suite_foo - defineTestSuite(foo,
dirs = .,
testFileRegexp = ^test.+\\.r,
testFuncRegexp = ^test.+
)
result_foo - runTestSuite(suite_foo)
printTextProtocol(result_foo)
## printHTMLProtocol(result_foo, fileName=result_foo.html)
## runTestFile(test_foo.r)







==


##
##  ../codes/foo.r
##
##  A code file sample
##
##


## centigrade to fahrenheit
c2f - function(a) return(9/5 * a + 32)

## fahrenheit to centigrade
f2c - function(f) return(5/9 * (f - 32))




=

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