[R] lmer{lme4}, poisson family and residuals

2006-04-20 Thread Amelie LESCROEL
Hello,

 

I’m trying to fit the following model:

Dependent variable: MAXDEPTH (the maximum depth reached by a penguin during
a given dive)

Fixed effects: SUCCESSMN (an index of the “individual quality” of a bird),
STUDYDAY (the day of the study, from -5 to 20, with 0=Dec 20), and the
interaction SUCCESSMN*STUDYDAY

Random effect: BIRD (the bird id, as each bird is performing several dives)

 

Using lmer with a poisson family, I got a huge amount of warning messages:

 

 reml.res - lmer(MAXDEPTH~SUCCESSMN*STUDYDAY+(1|BIRD), family=poisson,
method=”Laplace”)

There were 50 or more warnings (use warnings() to see the first 50)

 warnings()

Warning messages:

1: non-integer x = 18.50

2: non-integer x = 20.50

3: non-integer x = 16.50

…

 

Whereas it seems to be fine using the quasipoisson family:

 

 reml.res - lmer(MAXDEPTH~SUCCESSMN*STUDYDAY+(1|BIRD),
family=quasipoisson(link=log), method=Laplace)

 summary(reml.res)

Generalized linear mixed model fit using Laplace 

Formula: MAXDEPTH ~ SUCCESSMN * STUDYDAY + (1 | BIRD) 

 Family: quasipoisson(log link)

  AIC  BIClogLik deviance

 39581.16 39616.86 -19785.58 39571.16

Random effects:

 Groups   NameVariance Std.Dev.

 BIRD (Intercept) 0.12383  0.3519  

 Residual 4.05206  2.0130  

number of obs: 9324, groups: BIRD, 12

 

Fixed effects:

Estimate Std. Error t value

(Intercept)3.6725244  0.1063978  34.517

SUCCESSMN  0.2978806  0.6824748   0.436

STUDYDAY   0.0069852  0.0021121   3.307

SUCCESSMN:STUDYDAY 0.0571982  0.0123831   4.619

 

Correlation of Fixed Effects:

(Intr) SUCCESSMN STUDYD

SUCCESSMN   -0.276 

STUDYDAY-0.099 -0.017  

SUCCESSMN:S -0.075 -0.035 0.823

 

My first question is therefore: can someone tell me why I can’t fit the
model with family=poisson?

 

Second, I would like to check the residuals but I really don’t know how,
even after several hours searching the archives and other helps. I tried:

 

 residuals(reml.res)

Error: 'residuals' is not implemented yet

 resid(reml.res)

Error: 'resid' is not implemented yet

 names(reml.res)

NULL

 mcmcsamp(reml.res)

Error in .local(object, n, verbose, ...) : 

mcmcsamp for GLMMs not yet implemented in supernodal representation

 

I’m supposed to give a talk tomorrow and would be very grateful if someone
can help me…

 

I’m working with the following versions:

Package:  Matrix

Version:  0.995-8

Date: 2006-03-21

Package:   lme4

Version:   0.995-2

Date:  2006-01-17

 

Thank you!

 

Amélie

 


[[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] PCA biplot question

2006-04-20 Thread Tyler Smith
I think you're asking how to plot arrows for variables in one dataset 
onto the PCA plot for another dataset? You can do this with functions 
from the vegan package. Particularly, vector and factor fitting can be 
done with envfit() and surface fitting with ordisurf().

There's a good tutorial at:

http://cc.oulu.fi/~jarioksa/softhelp/vegan.html

Cheers,

Tyler

__
R-help@stat.math.ethz.ch 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] the difference between x1 and x1

2006-04-20 Thread Chad Reyhan Bhatti
Hello,

I am not sure what to write in the subject line, but I would like to take
a character string that is a variable in a data frame and apply a function
that takes a numeric argument to this character string.

Here is a simplified example that would solve my problem.
Imagine I have my data stored in a data frame.
 x1 - x2 - x3 - x4 - x5 - rnorm(20,0,1);
 data - as.data.frame(cbind(x1,x2,x3,x4,x5));

I have a vector containing the variables of interest as such.
 model.list - c(x1,x3,x4);

 model.list[1]
[1] x1

I would like to loop through this vector and apply the floor() function to
each variable.  In the current form the elements of model.list do not
represent the variables in the data frame.

 floor(model.list[1])
Error in floor(model.list[1]) : Non-numeric argument to mathematical
function

 floor(eval(model.list[1]))
Error in floor(eval(model.list[1])) : Non-numeric argument to mathematical
function

 s - expression(paste(floor(,model.list[1],),sep=))
 s
expression(paste(floor(, model.list[1], ), sep = ))
 eval(s)
[1] floor(x1)


I have tried the obvious (to me) without success.  Perhaps someone could
suggest a
solution and some tidbits for me to read up on about the how and why.

Thanks,

Chad R. Bhatti

__
R-help@stat.math.ethz.ch 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] Parallel computing with the snow package: external file I/O possible?

2006-04-20 Thread Waichler, Scott R
Hello,

After getting help to solve part of my problem and some delay on my
part, I am posting a more refined version to see if someone can help me
further.  I am trying to autocalibrate a model in my subject area using
the snow and rgenoud packages.  I want to use the key function fn that
is called by genoud() to finalize input, run the model executable, and
compute the objective function on the model output.  My problem is that
only in the master node do all of these steps happen.  In the slave node
of a cluster of two, the input file gets created but my system() call to
execute the model doesn't happen.  I don't understand why the model
doesn't get run in the slave mode, but I noticed something described
below that I thought might be related. 

It is hard for me to figure out a short and simple example of my
genoud() problem for posting here, so let me start with some code that
uses clusterCall().  As I understand the snow package, each execution of
the function fun from clusterCall() (or of the function fn() from
genoud()) should be independent.  However, in the code below, the
directory created by each node has the same random number in its name.
I was expecting the contents of fun() or fn() to be independent from all
other executions of the same function.  What am I missing here?

#  Begin code
library(snow)
setDefaultClusterOptions(outfile=/tmp/cluster1)
setDefaultClusterOptions(master=moab)
cl - makeCluster(c(moab, escalante), type=SOCK)

# Define base pathname for output from my.test()
base.dir - ~

# Define a function that is called by clusterCall()
my.test - function(base.dir) {
  this.host - as.character(system(hostname, intern=T))
  this.rnd - sample(1:1e6, 1)
  test.file - paste(sep=, base.dir, this.host, _, this.rnd)
  file.create(test.file)
}  # end my.test()

clusterCall(cl, my.test, base.dir)
stopCluster(cl)
#  End code 

For example, the files moab_65835 and escalante_65835 are created.

Regards,
Scott Waichler
Pacific Northwest National Laboratory
[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] the difference between x1 and x1

2006-04-20 Thread Gabor Grothendieck
Try this:

# test data
set.seed(1)
DF - data.frame(x1 = rnorm(5), x2 = rnorm(5), x3 = rnorm(5))
DF
model.list - c(x2, x3)

# transform
for(v in model.list) DF[v] - floor(DF[v])

On 4/20/06, Chad Reyhan Bhatti [EMAIL PROTECTED] wrote:
 Hello,

 I am not sure what to write in the subject line, but I would like to take
 a character string that is a variable in a data frame and apply a function
 that takes a numeric argument to this character string.

 Here is a simplified example that would solve my problem.
 Imagine I have my data stored in a data frame.
  x1 - x2 - x3 - x4 - x5 - rnorm(20,0,1);
  data - as.data.frame(cbind(x1,x2,x3,x4,x5));

 I have a vector containing the variables of interest as such.
  model.list - c(x1,x3,x4);

  model.list[1]
 [1] x1

 I would like to loop through this vector and apply the floor() function to
 each variable.  In the current form the elements of model.list do not
 represent the variables in the data frame.

  floor(model.list[1])
 Error in floor(model.list[1]) : Non-numeric argument to mathematical
 function

  floor(eval(model.list[1]))
 Error in floor(eval(model.list[1])) : Non-numeric argument to mathematical
 function

  s - expression(paste(floor(,model.list[1],),sep=))
  s
 expression(paste(floor(, model.list[1], ), sep = ))
  eval(s)
 [1] floor(x1)
 

 I have tried the obvious (to me) without success.  Perhaps someone could
 suggest a
 solution and some tidbits for me to read up on about the how and why.

 Thanks,

 Chad R. Bhatti

 __
 R-help@stat.math.ethz.ch 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] the difference between x1 and x1

2006-04-20 Thread Duncan Murdoch
On 4/20/2006 7:02 PM, Chad Reyhan Bhatti wrote:
 Hello,
 
 I am not sure what to write in the subject line, but I would like to take
 a character string that is a variable in a data frame and apply a function
 that takes a numeric argument to this character string.

Remember that dataframes are lists with named members.  So to apply 
something to the x1 member of a dataframe, you can do the usual

data$x1

but you can also do

data[[x1]]

In addition, dataframes implement the same style of index handling as 
matrices, so you can refer to the x1 column as

data[,x1]

You could replace x1 with any expression (e.g. model.list[1]) in 
either of the latter two examples, e.g.

data[[model.list[1]]]

or

data[,model.list[1]]

You say below that you want to loop through the vector; in fact, there's 
no need to do that.  The floor function would work fine on the whole 
thing at once, e.g.

floor(data[,model.list])

Duncan Murdoch
 
 Here is a simplified example that would solve my problem.
 Imagine I have my data stored in a data frame.
 x1 - x2 - x3 - x4 - x5 - rnorm(20,0,1);
 data - as.data.frame(cbind(x1,x2,x3,x4,x5));
 
 I have a vector containing the variables of interest as such.
 model.list - c(x1,x3,x4);
 
 model.list[1]
 [1] x1
 
 I would like to loop through this vector and apply the floor() function to
 each variable.  In the current form the elements of model.list do not
 represent the variables in the data frame.
 
 floor(model.list[1])
 Error in floor(model.list[1]) : Non-numeric argument to mathematical
 function
 
 floor(eval(model.list[1]))
 Error in floor(eval(model.list[1])) : Non-numeric argument to mathematical
 function
 
 s - expression(paste(floor(,model.list[1],),sep=))
 s
 expression(paste(floor(, model.list[1], ), sep = ))
 eval(s)
 [1] floor(x1)
 
 I have tried the obvious (to me) without success.  Perhaps someone could
 suggest a
 solution and some tidbits for me to read up on about the how and why.
 
 Thanks,
 
 Chad R. Bhatti
 
 __
 R-help@stat.math.ethz.ch 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] the difference between x1 and x1

2006-04-20 Thread Francisco J. Zagmutt
Is this what you are after?

floor(data[,model.list])

Or I just didn't understand what you are trying to accomplish?

cheers

Francisco

PS: try to avoid using names that are already reserved to a function like 
data See ?data

From: Chad Reyhan Bhatti [EMAIL PROTECTED]
To: R-help@stat.math.ethz.ch
Subject: [R] the difference between x1 and x1
Date: Thu, 20 Apr 2006 18:02:02 -0500 (CDT)

Hello,

I am not sure what to write in the subject line, but I would like to take
a character string that is a variable in a data frame and apply a function
that takes a numeric argument to this character string.

Here is a simplified example that would solve my problem.
Imagine I have my data stored in a data frame.
  x1 - x2 - x3 - x4 - x5 - rnorm(20,0,1);
  data - as.data.frame(cbind(x1,x2,x3,x4,x5));

I have a vector containing the variables of interest as such.
  model.list - c(x1,x3,x4);

  model.list[1]
[1] x1

I would like to loop through this vector and apply the floor() function to
each variable.  In the current form the elements of model.list do not
represent the variables in the data frame.

  floor(model.list[1])
Error in floor(model.list[1]) : Non-numeric argument to mathematical
function

  floor(eval(model.list[1]))
Error in floor(eval(model.list[1])) : Non-numeric argument to mathematical
function

  s - expression(paste(floor(,model.list[1],),sep=))
  s
expression(paste(floor(, model.list[1], ), sep = ))
  eval(s)
[1] floor(x1)
 

I have tried the obvious (to me) without success.  Perhaps someone could
suggest a
solution and some tidbits for me to read up on about the how and why.

Thanks,

Chad R. Bhatti

__
R-help@stat.math.ethz.ch 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] R and ViM

2006-04-20 Thread Jose Quesada
To: Martin Maechler [EMAIL PROTECTED]

 Indeed. Please do check the archives.

Yep. Post is there.

 Now back to the subject:  Jose, I think your main contribution
 is based on autoHotKeys  and that only works on Windoze, right?
 Michael explicitly mentioned he's working in Mac OS X.

 Martin

That's correct, autoHotKeys is a win-only solution.
Bill West's solution uses use Win32::OLE, so I guess that means it's
win-only solution.

I think  François Pinard's is the easiest since it uses vim and R only
(no 3rd application/language requireed), and that would probably work
in all platforms (not sure if the GNU readline inferface is
implemented in all builds of R, though).

I find autoHotKey very useful (e.g., it fires vim to fill textboxes
like this one -gmail editing window-, offering syntax highlighting
etc) so I use it all the time and don't mind. I can understand those
who don't want to install it just to communicate R and an editor. In
that case, the other two solutions are better. I'll refer to them in
my Rvim page (archives).

However, the new R.vim syntax file has 3-level coloring, and I'm
working to get improved indentation, TODO, DEBUG, etc highlighting,
and other improvements. The code templates using tSkeleton (not ready
yet) may be an added advantage. Those two things you can use even if
you don't use autohotkeys of course.

--
Cheers,
-Jose

PS: it seems that google mail (as an email reader) doesn't let you see
your own messages when posting to a list you are subscribed to.

--
Jose Quesada, PhD.

[EMAIL PROTECTED]   Dept. of Psychology
http://www.andrew.cmu.edu/~jquesada Sussex University
Brighton, UK



--
Cheers,
-Jose
--
Jose Quesada, PhD.

[EMAIL PROTECTED]   Dept. of Psychology
http://www.andrew.cmu.edu/~jquesada Sussex University
Brighton, UK

__
R-help@stat.math.ethz.ch 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] second try; writing user-defined GLM link function

2006-04-20 Thread Jessi Brown
An update for all:

Using the combined contributions from Mark and Dr. Ripley, I've been
(apparently) successfully  formulating both GLM's and GLMM's (using
the MASS function glmmPQL) analyzing my nest success data. The beta
parameter estimates look reasonable and the top models resemble those
from earlier analyses using a different nest survival analysis
approach.

However, I've now run into problems when trying to predict the daily
survival rates from fitted models. For example, for a model
considering nest height (NestHtZ) and nest age effects (MeanAge and
related terms; there is an overall cubic time trend in this model), I
tried to  predict the daily survival rate for each day out of a 67 day
nest cycle (so MeanAge is a vector of 1 to 67) with mean nest height
(also a vector 67 rows in length; both comprise the matrix nestday).
Here's what happens:

 summary(glm.24)

Call:
glm(formula = Success ~ NestHtZ + MeanAge + I(MeanAge^2) + I(MeanAge^3),
family = logexposure(ExposureDays = vc.apfa$days), data = vc.apfa)

Deviance Residuals:
Min   1Q   Median   3Q  Max
-3.3264  -1.2341   0.6712   0.8905   1.5569

Coefficients:
   Estimate Std. Error z value Pr(|z|)
(Intercept)   6.5742015  1.7767487   3.700 0.000215 ***
NestHtZ   0.6205444  0.2484583   2.498 0.012504 *
MeanAge  -0.6018978  0.2983656  -2.017 0.043662 *
I(MeanAge^2)  0.0380521  0.0152053   2.503 0.012330 *
I(MeanAge^3) -0.0006349  0.0002358  -2.693 0.007091 **
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for binomial family taken to be 1)

Null deviance: 174.86  on 136  degrees of freedom
Residual deviance: 233.82  on 132  degrees of freedom
AIC: 243.82

Number of Fisher Scoring iterations: 13

 glm.24.pred-predict(glm.24,newdata=nestday, type=response, SE.fit=T)
Warning message:
longer object length
is not a multiple of shorter object length in: plogis(eta)^days


Can anyone tell me what I'm doing wrong?

cheers, Jessi Brown

__
R-help@stat.math.ethz.ch 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 control the data type

2006-04-20 Thread zhongmiao wang
Hello:
I am generating a random number with rnorm(1). The generated number
has 8 decimals. I don't want so many decimals. How to control the
number of decimals in R?
Thanks!

Zhongmiao Wang

__
R-help@stat.math.ethz.ch 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 do Splus compare() function in R

2006-04-20 Thread Bellinger Instruments P/L
The sign() function requires one argument,
and returns the sign of the value, where I require a number
-1, 0, or 1 depending on if the value is , ==, or  the 
first argument.

This is the Splus function when listed,
 compare
function(e1, e2)
.Internal(compare(e1, e2), do_op, T, 18)

unfortunately I do not understand the .internal function
and cannot find any description of this type of programming
on the CRAN site



This is how I am using it in the source file. 


zz - readline()# keyboard input eg: f15


if (charmatch(substring(zz,1,1),f,  
nomatch=-1) 0){
ii - as.numeric(substring(zz,2,99))

iii - compare(ii*1e9,f) # f is a vector of length(146) frequencies 
 # compare() searches thru f and
 # creates vector iii with 
   # -1 if numeric is  f[i],  
   #  0 if numeric is == f[i], and
 #  1 if numeric is  f[i]

# the end result is a vector(iii) length(146) 
  # with -1,0,1 if the numeric is in f


   i - match(-1,c(iii,-1))-1 # if vector(iii) contains 0 assign the
index
  }

# error traps for if 0 is not in vector(iii)

if (i1){cat(Min n = 1\n)
  i - 1}
if (ilength(f)){cat(Max n =,length(f),\n)
  i - length(f)} 

-Original Message-
From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] 
Sent: Thursday, 20 April 2006 4:02 PM
Subject: Re: [R] how to do Splus compare() function in R

You would need to tell us what it does (and what the inputs are).

I think it is likely that compare(x, y) in S-PLUS is the same as sign(x-y)
in R, at least with numeric vector inputs.

-- 
Bob Kelly   [EMAIL PROTECTED]
Metrologist  Microwave Eng.http://www.bellinger.com.au
Bellinger Instruments Pty Ltd   Tel: 612 9684 1442
4 Muriel AveFax: 612 9638 4435
Rydalmere NSW
Australia  2116

__
R-help@stat.math.ethz.ch 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 do Splus compare() function in R

2006-04-20 Thread Christos Hatzis
As suggested below,

sign(ii*1e9-f) 

will give you the same result as the S-plus
 
compare(ii*1e-9,f)

-Christos

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Bellinger Instruments
P/L
Sent: Thursday, April 20, 2006 11:02 PM
To: 'Prof Brian Ripley'
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] how to do Splus compare() function in R

The sign() function requires one argument, and returns the sign of the
value, where I require a number -1, 0, or 1 depending on if the value is ,
==, or  the first argument.

This is the Splus function when listed,
 compare
function(e1, e2)
.Internal(compare(e1, e2), do_op, T, 18)

unfortunately I do not understand the .internal function and cannot find any
description of this type of programming on the CRAN site



This is how I am using it in the source file. 


zz - readline()# keyboard input eg: f15


if (charmatch(substring(zz,1,1),f,  
nomatch=-1) 0){
ii - as.numeric(substring(zz,2,99))

iii - compare(ii*1e9,f) # f is a vector of length(146) frequencies 
 # compare() searches thru f and
 # creates vector iii with 
   # -1 if numeric is  f[i],  
   #  0 if numeric is == f[i], and
 #  1 if numeric is  f[i]

# the end result is a vector(iii) length(146) 
  # with -1,0,1 if the numeric is in f


   i - match(-1,c(iii,-1))-1 # if vector(iii) contains 0 assign the
index
  }

# error traps for if 0 is not in vector(iii)

if (i1){cat(Min n = 1\n)
  i - 1}
if (ilength(f)){cat(Max n =,length(f),\n)
  i - length(f)} 

-Original Message-
From: Prof Brian Ripley [mailto:[EMAIL PROTECTED]
Sent: Thursday, 20 April 2006 4:02 PM
Subject: Re: [R] how to do Splus compare() function in R

You would need to tell us what it does (and what the inputs are).

I think it is likely that compare(x, y) in S-PLUS is the same as sign(x-y)
in R, at least with numeric vector inputs.

-- 
Bob Kelly   [EMAIL PROTECTED]
Metrologist  Microwave Eng.http://www.bellinger.com.au
Bellinger Instruments Pty Ltd   Tel: 612 9684 1442
4 Muriel AveFax: 612 9638 4435
Rydalmere NSW
Australia  2116

__
R-help@stat.math.ethz.ch 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] how to do Splus compare() function in R [Broadcast]

2006-04-20 Thread Liaw, Andy
You need to tell us what compare() in S-PLUS does; i.e., what does it take
as input and what does it output.  Presumably the information would be in
the help page for compare().  

Telling us what the function looks like in S-PLUS is of no use, since most
likely the code cannot be used in R without violating S-PLUS copyright
and/or license.  Even if that wasn't an obstacle, the fact that it calls
.Internal() says the actual code is written in C, and of course no one
outside of Insightful (and perhaps Bell Labs) has access to code at that
level.  And even then, R and S-PLUS are not likely to be compatible at that
level.

Andy

From: Bellinger Instruments P/L
 
 The sign() function requires one argument,
 and returns the sign of the value, where I require a number
 -1, 0, or 1 depending on if the value is , ==, or  the 
 first argument.
 
 This is the Splus function when listed,
  compare
 function(e1, e2)
 .Internal(compare(e1, e2), do_op, T, 18)
 
 unfortunately I do not understand the .internal function
 and cannot find any description of this type of programming
 on the CRAN site
 
 
 
 This is how I am using it in the source file. 
 
 
 zz - readline()# keyboard input eg: f15
   
 
 if (charmatch(substring(zz,1,1),f,  
 nomatch=-1) 0){
 ii - as.numeric(substring(zz,2,99))
 
 iii - compare(ii*1e9,f) # f is a vector of 
 length(146) frequencies 
  # compare() searches thru f and
# creates vector iii with 
  # -1 if numeric is  f[i],  
  #  0 if numeric is == f[i], and
#  1 if numeric is  f[i]
 
   # the end result is a vector(iii) length(146) 
   # with -1,0,1 if the numeric is in f
 
 
i - match(-1,c(iii,-1))-1 # if vector(iii) contains 0 
 assign the index
 }
 
 # error traps for if 0 is not in vector(iii)
 
 if (i1){cat(Min n = 1\n)
 i - 1}
 if (ilength(f)){cat(Max n =,length(f),\n)
 i - length(f)} 
 
 -Original Message-
 From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, 20 April 2006 4:02 PM
 Subject: Re: [R] how to do Splus compare() function in R
 
 You would need to tell us what it does (and what the inputs are).
 
 I think it is likely that compare(x, y) in S-PLUS is the same 
 as sign(x-y) in R, at least with numeric vector inputs.
 
 -- 
 Bob Kelly [EMAIL PROTECTED]
 Metrologist  Microwave Eng.  http://www.bellinger.com.au
 Bellinger Instruments Pty Ltd Tel: 612 9684 1442
 4 Muriel Ave  Fax: 612 9638 4435
 Rydalmere NSW
 Australia  2116
 
 __
 R-help@stat.math.ethz.ch 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] I am surprised (and a little irritated)

2006-04-20 Thread Tom Backer Johnsen
Detlef Steuer wrote:
 Hi again,
 
...

 This new rpm R-base-2.3.0-beta should automatically resolve dependencies. At 
 least it did so on my machine. I would be happy to get a report, if you try 
 to install this one and find difficulties or success!.
 Most important would be to report missing dependencies. As this is my first 
 try to add those, I`m not sure having catched them all.

I have not tried it yet, but when I think about it I think that you 
have resolved the dependencies part already in 2.2.1.  When I had set 
up YaST according to the hacking link and then opened the R-base rpm 
file everything went smooth with no intervention on my part.

Tom

++
| Tom Backer Johnsen, Psychometrics Unit,  Faculty of Psychology |
| University of Bergen, Christies gt. 12, N-5015 Bergen,  NORWAY |
| Tel : +47-5558-9185Fax : +47-5558-9879 |
| Email : [EMAIL PROTECTED]URL : http://www.galton.uib.no/ |
++

__
R-help@stat.math.ethz.ch 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] Linker incompatability in stalling R on Solaris 2.9

2006-04-20 Thread Min Shao
Hi,

I am trying to compile R-2.2.1 on Solaris 2.9 with a 64-bit build. Following
the instructions in R Installation and Adminstration, I changed the
following settings in config.site:

[[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] Linker problem in installing 64-bit R

2006-04-20 Thread Min Shao
 Hi,

I am trying to compile R-2.2.1 on Solaris 2.9 with a 64-bit build. Following
the instructions in R Installation and Adminstration, I changed the
following settings in config.site:
 CC=gcc -m64
F77=g77 -64
CXX=g++ -m64
LDFLAGS=-L/usr/local/lib/sparcv9 -L/usr/local/lib

But I got the following error messages:
configure:3987: gcc -m64  -I/usr/local/include -L/usr/local/lib/sparcv9
-L/usr/local/lib conftest.c  5
/usr/ccs/bin/ld: skipping incompatible /work/net-local-b/sparc-
sun-solaris2.9/bin/../lib/gcc/sparc-sun-solaris2.9/3.4.2/sparcv9/libgcc.a
when search
ing for -lgcc
/usr/ccs/bin/ld: skipping incompatible /work/net-local-b/sparc-
sun-solaris2.9/bin/../lib/gcc/sparc-sun-solaris2.9/3.4.2/sparcv9/libgcc_eh.a
when sea
rching for -lgcc_eh
/usr/ccs/bin/ld: skipping incompatible /lib/sparcv9/libc.so when searching
for -lc
/usr/ccs/bin/ld: skipping incompatible /usr/lib/sparcv9/libc.so when
searching for -lc
/usr/ccs/bin/ld: skipping incompatible /usr/lib/sparcv9/libc.so when
searching for -lc
/usr/ccs/bin/ld: skipping incompatible /work/net-local-b/sparc-
sun-solaris2.9/bin/../lib/gcc/sparc-sun-solaris2.9/3.4.2/sparcv9/libgcc.a
when search
ing for -lgcc
/usr/ccs/bin/ld: skipping incompatible /work/net-local-b/sparc-
sun-solaris2.9/bin/../lib/gcc/sparc-sun-solaris2.9/3.4.2/sparcv9/libgcc_eh.a
when sea
rching for -lgcc_eh
/usr/ccs/bin/ld: skipping incompatible /lib/sparcv9/libc.so when searching
for -lc
/usr/ccs/bin/ld: skipping incompatible /usr/lib/sparcv9/libc.so when
searching for -lc
/usr/ccs/bin/ld: skipping incompatible /usr/lib/sparcv9/libc.so when
searching for -lc
/usr/ccs/bin/ld: warning: sparc:v9 architecture of input file
`/work/net-local-b/sparc-sun-solaris2.9/bin/../lib/gcc/sparc-sun-solaris2.9
/3.4.2/spar
cv9/crt1.o' is incompatible with sparc output
/usr/ccs/bin/ld: warning: sparc:v9 architecture of input file
`/work/net-local-b/sparc-sun-solaris2.9/bin/../lib/gcc/sparc-sun-solaris2.9
/3.4.2/spar
cv9/crti.o' is incompatible with sparc output
/usr/ccs/bin/ld: warning: sparc:v9 architecture of input file
`/usr/ccs/lib/sparcv9/values-Xa.o' is incompatible with sparc output
/usr/ccs/bin/ld: warning: sparc:v9 architecture of input file
`/work/net-local-b/sparc-sun-solaris2.9/bin/../lib/gcc/sparc-sun-solaris2.9
/3.4.2/spar
cv9/crtbegin.o' is incompatible with sparc output
/usr/ccs/bin/ld: warning: sparc:v9 architecture of input file
`/var/tmp//cckWp3Sb.o' is incompatible with sparc output
/usr/ccs/bin/ld: warning: sparc:v9 architecture of input file
`/work/net-local-b/sparc-sun-solaris2.9/bin/../lib/gcc/sparc-sun-solaris2.9
/3.4.2/spar
cv9/crtend.o' is incompatible with sparc output
/usr/ccs/bin/ld: warning: sparc:v9 architecture of input file
`/work/net-local-b/sparc-sun-solaris2.9/bin/../lib/gcc/sparc-sun-solaris2.9
/3.4.2/spar
cv9/crtn.o' is incompatible with sparc output
configure:3990: $? = 0
configure:4036: result: a.out
configure:4041: checking whether the C compiler works
configure:4047: ./a.out
configure: line 1: 25817 Bus Error   (core dumped) ./$ac_file
configure:4050: $? = 138
configure:4059: error: cannot run C compiled programs.

I would appreciate any help with resolving the problem.

Thanks,

Min

[[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] how to do Splus compare() function in R

2006-04-20 Thread Prof Brian Ripley
You would need to tell us what it does (and what the inputs are).

I think it is likely that compare(x, y) in S-PLUS is the same as sign(x-y) 
in R, at least with numeric vector inputs.

On Thu, 20 Apr 2006, Bellinger Instruments P/L wrote:

 Hi
 I have a source file in Splus that fails in R as I am using the Splus
 function compare().

compare( ii * 1e9,f )   where ii is a single variable and f
 is a vector of length 146

  R  returns with no function error

 Can anyone inform me how I can do this in R


 thanks in advance

 Bob Kelly

 Bellinger Instruments Pty Ltd


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


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


Re: [R] there is no xls reader in R?

2006-04-20 Thread Ko-Kang Kevin Wang
Have a look at the read.xls() in gdata package.

HTH,

Kevin

Michael wrote:
 Currently I have to convert all my xls into csv before I can read it in
 and process the excel data in R...
 
 Is there a way to directly read in xls data?
 
 Thanks a lot!
 
   [[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

-- 
Ko-Kang Kevin Wang
Homepage: http://wwwmaths.anu.edu.au/~wangk/
Ph (W): +61-2-6125-2431
Ph (H): +61-2-6125-7471
Ph (M): +61-40-451-8301

__
R-help@stat.math.ethz.ch 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] comparing execition time: R vs matlab linear algebra...

2006-04-20 Thread Prof Brian Ripley
You haven't told us your platform.  On most platforms, R does not 
build/ship with an optimized BLAS, and this can make a big difference to 
execution times of such problems.  See the R-admin manual.

Beyond that, qr/qr.coef is not the most obvious way to solve linear 
systems (solve is), and the option LAPACK=TRUE will be faster, not least 
because it can make better use of an optimzed BLAS.

And yes, if `sparse' is a form of sparseness that packages can exploit, it 
will help to use them, and you must be using sparseness in Matlab to even
be able to store the matrices.

R is not a numerical linear algbra system and does not intend to compete 
with say Octave. Rather, it aims to have enough facilities that in almost 
all uses of R, the slowness of linear algebra is not the limiting factor. 
I do wonder why you are porting Matlab scripts to R if Matlab can handle 
them.


On Wed, 19 Apr 2006, Rick Reeves wrote:

 Greetings:

 We are evaluating the performance of R matrix algebra es as we port a
 MATLAB R14 script into R.

 The MATLAB code basically evaluates the AX=B system on sparse matrices
 that result in output matrices of 100 to 1,000,000 rows/columns.

 Our R prototype script uses spase base matrices and the methods qr() and
 qr.coeff().

 The following statements are called inside a doubly-nested loop:
 G is an n x m sparse matrix with most nonzero values near the main diagonal,
 CURR is an n x 1 vector:

 the MATALAB script:

 P = G  \ CURR;  % matrix left-divide

QG = qr(G)
P = qr.coef(QG, CURR)

 The answer we get matches  that of the MATLAB code for small (60x60)
 problems.
 But, execution times are much longer (40 minutes, compared to 2 minutes for
 the MATLAB script)

 Also, the R version cannot accommodate a solution matrix greater than
 aprox 10,000 x 10,000 elements,while the MATLAB script has generated
 solutions for 10**6 x 10**6 solution matrices.

 My questions: 1) Have others noticed this difference in performance
 between R and MATLAB?
  2) Is there R literature (I have searched, not
 found) that discusses optimizing these
  solutions in R? such as.
  2) Would developing a solution using the Matrix or
 SparseM classes improve performance?

 Thanks in advance for any insights!

 Regards,
 Rick R



-- 
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] R-squared for MARS models

2006-04-20 Thread Marco Girardello
Hi,

is there an R function which can compute the R-squared
for a mars model fitted using the mda package?

many thanks in advance

best regards

Marco Girardello

__
R-help@stat.math.ethz.ch 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-squared for MARS models

2006-04-20 Thread Gavin Simpson
On Wed, 2006-04-19 at 21:18 +0200, Marco Girardello wrote:
 Hi,
 
 is there an R function which can compute the R-squared
 for a mars model fitted using the mda package?
 
 many thanks in advance
 
 best regards
 
 Marco Girardello

Julian Faraway's Extending the Linear Model with R Chapman  Hall/CRC
(page 248)has a small section on MARS and compares the MARS fit with
other methods by using the MARS basis functions in a linear model to get
an R^2:

# page 248 example
library(faraway)
library(mda)
data(ozone)
a - mars(ozone[,-1], ozone[,])
(a.summ - summary(lm(ozone[,1] ~ a$x-1)))
a.summ$r.squared

HTH

G
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 *Note new Address and Fax and Telephone numbers from 10th April 2006*
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Gavin Simpson [t] +44 (0)20 7679 0522
ECRC  [f] +44 (0)20 7679 0565
UCL Department of Geography
Pearson Building  [e] gavin.simpsonATNOSPAMucl.ac.uk
Gower Street
London, UK[w] http://www.ucl.ac.uk/~ucfagls/cv/
WC1E 6BT  [w] http://www.ucl.ac.uk/~ucfagls/
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

__
R-help@stat.math.ethz.ch 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] Need R code

2006-04-20 Thread stat stat
Dear r-users,
  
Suppose I have three datasets:
  Dataset-1:
  Date  x y
  Jan-1,2005120   230
Jan-2,2005123   -125
Jan-3,2005-110  300
Jan-4,2005114   -21
Jan-7,200511299
Mar-5,2005200   311
   
  Dataset-2:
  Date  x  y
  Jan-2,2005123   -125
Jan-3,2005-110  300
Jan-4,2005114   -21
Jan-5,200511299
Jan-6,2005-23   12
Mar-5,2005200   311
   
  Dataset-3:
  Date  x  y
  Jan-3,2005-110  300
Jan-4,2005114   -21
Jan-5,200511299
Mar-5,2005200   311
Apl-23,2005   123   200
  Now I want to get the common dates along with x and y from this above three 
datasets keeping the same order
in date-variable as it is.
  For ex. I want to get:
  Datex  y xy  
x  y
   (from dataset-1) (from dataset-2)  (from 
dataset-3)

  Jan-3,2005-110  300  -110 300  -110  
300
Jan-4,2005 114  -21 114-21   114   
-21
Mar-5,2005200   311   200 311  200   311
  Can anyone give me any R code to implement this for any number of datasets ?
  Thanks and regards
   


thanks in advance

-


[[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] Bootstrap error message: Error in statistic(data, original, ...) : unused argument(s) ( ...)

2006-04-20 Thread Michael
Dear colleagues,

I've been swamped and fighting with error for a few hours but still
desperately having absolutely no clue:

What's wrong with my bootstraping code?

Thanks a lot!


Error Message:

 bootResults=boot(X, myFun, R=1);
Error in statistic(data, original, ...) : unused argument(s) ( ...)


My code is:

X=cbind(column_vector_1, column_vector_2);
myFun=function(X)
{
 return(mean(X[, 1])/var(X[, 2]));
}

bootResults=boot(X, myFun, R=1);

-

[[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] A question about nlme

2006-04-20 Thread Peter Dalgaard
zhongmiao wang [EMAIL PROTECTED] writes:

 Hello,
 I have used nlme to fit a model, the R syntax is like
 
 fmla0-as.formula(paste(~,paste(colnames(ldata[,9:13]),collapse=+),-1))
  fmla1-as.formula(paste(~,paste(colnames(ldata[,14:18]),collapse=+),-1))
  fmla2-as.formula(paste(~,paste(colnames(ldata[,19:23]),collapse=+),-1))
  Block=pdBlocked(list(pdIdent(fmla0),pdIdent(fmla1),pdIdent(fmla2)))
  lme(fixed=Score ~ factor(time)-1,data=ldata,random=list(Block),
 + weights=varIdent(form= ~ 1|time),
 + correlation=corSymm(form= ~ 1|Block/ID))
 
 and the Error message is
 Error in parse(file, n, text, prompt) : syntax error in ~ 
 
 I repeatedly check the ~, however, I cannot find anything wrong with
 it. Is there anybody can tell what is wrong? Thank you so much!

Is the character following ~ _really_ a space in all three cases?
Shift-space sometimes catches people off guard.

-- 
   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] about vsn

2006-04-20 Thread XinMeng
Hi all: 
As to vsn package,how can I transform my raw data format to the demo data of 
vsn(named kidney)? 

My raw data: 
namesignal  dye
gene1   815.32  green
gene2   671.66  green
gene3   713.93  green
gene4   703.97  green
gene5   493.59  green
gene6   477.92  green
gene7   346.55  green

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


Re: [R] 3D pie

2006-04-20 Thread Ted Harding
On 19-Apr-06 Peter Ehlers wrote:
 This discussion of 3-d pie charts comes at an opportune time. I have
 just formulated a new theory of graphical information transfer which
 is particularly simple in the case of 3-d pie charts.
 
 Let theta denote the angle between the normal to the pie cylinder and
 the pie-eyed line (connecting eye and centre of pie). Then the
 information transmitted from pie to viewer is
 
K * (pi/2 - theta)^3
 
 for theta in [0, pi/2]. The normalizing constant may be written in
 the obvious manner as
 
K = 8 * I_0 / pi^3.
 
 I conjecture that I_0 is not large, but I'm still waiting to hear
 from Microsoft regarding my application for funding to allow me to
 conduct extensive testing.

I think I can confirm your conjecture. With theta = 0, you have in
effect a 2-D pie, and then, according to my calculations, if you take

  I_0 = 3.14159265358979...

the information you get is 1 pie.

Ted.


E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 20-Apr-06   Time: 09:10:01
-- XFMail --

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


Re: [R] 3D pie

2006-04-20 Thread COMTE Guillaume
Hi all,
I can understand that it isn't the right way to represent data, i knew that i 
would hurt some people on this mailling list to discuss about pie.
As i've specified on my first message:
My only purpose of drawing 3D pie is for customer who don't have to understand 
what is drawn , but only be impressed by the beauty of the result (like people 
at commercial division which purchase what you've done but don't use it).

Then the expert (who are the ending users) will use the dotchart version (which 
i've putted too) instead of the pie.
Note:it isn't my idea, i wish to follow these advices, but i'm not the buyer...

That's all, and for shure i won't forget that pie isn't good, or only at dinner 
time.

Bring me a 3D apple pie and a coffee it's the morning here! (or a sandwich with 
hamm)

Thks for all the answers,

Grothendieck, thanks for the R tips with excel,but i'm working under linux, 
will keep this example in a safe place, could be usefull one day, who knows...

Cheers
COMTE Guillaume
 


-Message d'origine-
De : Frank E Harrell Jr [mailto:[EMAIL PROTECTED] 
Envoyé : mercredi 19 avril 2006 21:14
À : Rolf Turner
Cc : [EMAIL PROTECTED]; COMTE Guillaume; r-help@stat.math.ethz.ch
Objet : Re: [R] 3D pie

Rolf Turner wrote:
 Gabor Grothendieck wrote:
 
 
Since everyone else wimped out with a tedious you-do-not-want-to-do-that,
here is a solution that uses R to control Excel and create a 3d chart.
 
 .
 .
 .
 
 People really ***should not*** be encouraged or abetted in
 wrong-headedness.  Excel is terrible.  Pie charts are terrible.
 Don't mess with them.  Period.
 
 
   cheers,
 
   Rolf Turner
   [EMAIL PROTECTED]

I second that.  Helping people do things known to have major problems 
with the approaches can actually hurt others in the long run.  2-D pie 
charts are terrible.  That makes 3-D pie charts terrible to the 3/2 
power.  Excel has serious errors and is not a good model for 
reproducible research.
-- 
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] R-Help

2006-04-20 Thread stat stat
Dear r-users,
  
Suppose I have three datasets:
  Dataset-1:
  Date  x y
  Jan-1,2005120   230
Jan-2,2005123   -125
Jan-3,2005-110  300
Jan-4,2005114   -21
Jan-7,200511299
Mar-5,2005200   311
   
  Dataset-2:
  Date  x  y
  Jan-2,2005123   -125
Jan-3,2005-110  300
Jan-4,2005114   -21
Jan-5,200511299
Jan-6,2005-23   12
Mar-5,2005200   311
   
  Dataset-3:
  Date  x  y
  Jan-3,2005-110  300
Jan-4,2005114   -21
Jan-5,200511299
Mar-5,2005200   311
Apl-23,2005   123   200
  Now I want to get the common dates along with x and y from this above three 
datasets keeping the same order
in date-variable as it is.
  For ex. I want to get:
  Datex  y xy  
x  y
   (from dataset-1) (from dataset-2)  (from 
dataset-3)

  Jan-3,2005-110  300  -110 300  -110  
300
Jan-4,2005 114  -21 114-21   114   
-21
Mar-5,2005200   311   200 311  200   311
  Can anyone give me any R code to implement this for any number of datasets ?
  Thanks and regards


thanks in advance

-


[[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] prop.table on three-way table?

2006-04-20 Thread Fredrik Karlsson
Hi marc,

I did not manage ctab to do this for me. Again, I am probably using it
wrong, but I don't know that the problem is.

You asked for a more illustrated example, so here goes:

Take this table:

 ftable(table(sample(paste(dim1_no,1:5,sep=),10,replace=TRUE),
sample(paste(dim2_no,1:5,sep=),10,replace=TRUE),
sample(paste(dim3_no,1:5,sep=),10,replace=TRUE)))

   dim3_no1 dim3_no2 dim3_no3 dim3_no5

dim1_no1 dim2_no1 0000
 dim2_no2 0020
 dim2_no3 0000
 dim2_no4 0000
 dim2_no5 0000
dim1_no2 dim2_no1 0000
 dim2_no2 0000
 dim2_no3 0000
 dim2_no4 0000
 dim2_no5 0101
dim1_no3 dim2_no1 0000
 dim2_no2 0000
 dim2_no3 0010
 dim2_no4 0000
 dim2_no5 0000
dim1_no4 dim2_no1 1000
 dim2_no2 0000
 dim2_no3 0000
 dim2_no4 0000
 dim2_no5 1000
dim1_no5 dim2_no1 0000
 dim2_no2 0100
 dim2_no3 1000
 dim2_no4 0100
 dim2_no5 0000


Now, I would like to get the per cent occurrence of each level of
dim3_noX witin the cells by dim1 and dim2. Thus, for this part section
of the table above:

   dim3_no1 dim3_no2 dim3_no3 dim3_no5
dim1_no2 dim2_no1 0000
 dim2_no2 0000
 dim2_no3 0000
 dim2_no4 0000
 dim2_no5 0101

I would like to get:

   dim3_no1 dim3_no2 dim3_no3 dim3_no5
dim1_no2 dim2_no1 0000
 dim2_no2 0000
 dim2_no3 0000
 dim2_no4 0000
 dim2_no5 00.500.5

since dim3_no2 represented 50% of the frequency within the cell
created by dim1_no2 and dim2_no5.


Hope that helped clarify my previous explanation of the problem.

/Fredrik

2006/4/19, Marc Schwartz (via MN) [EMAIL PROTECTED]:
 On Wed, 2006-04-19 at 16:39 +0200, Fredrik Karlsson wrote:
  Dear list,
 
  I am trying to create a three-way table with percent occurrence
  instead of raw frequencies. However, I cannot get the results I
  expected:
 
  I have the following table:
 
   ftable(table( mannerDF$agem, mannerDF$target, mannerDF$manner ))
  snip
  50 bak 0 0   0 0   1 0
 pak 0 0   0 0   3 0
 sak 0 1   0 0   0 0
 spak0 0   0 0   0 0
 
  Now, If I use the prop-table function, I newer get a 1 ratio in any cell:
 
 
 
  With 'margin=1':
 
  50 bak0. 0. 0. 0. 0.2000 0.
 pak0. 0. 0. 0. 0.6000 0.
 sak0. 0.2000 0. 0. 0. 0.
 spak   0. 0. 0. 0. 0. 0.
 
  With 'margin=2':
 
  50 bak   0.0 0.0 0.0 0.0 0.004347826 
  0.0
 pak   0.0 0.0 0.0 0.0 0.010752688 
  0.0
 sak   0.0 0.005747126 0.0 0.0 0.0 
  0.0
 spak  0.0 0.0 0.0 0.0 0.0 
  0.0
 
  With 'margin=3':
 
  50 bak   0.0 0.0 0.0 0.0 0.001373626 
  0.0
 pak   0.0 0.0 0.0 0.0 0.004120879 
  0.0
 sak   0.0 0.008695652 0.0 0.0 0.0 
  0.0
 spak  0.0 0.0 0.0 0.0 0.0 
  0.0
 
  What I was looking for is this:
 
 
  50 bak 0 0   0 0   1 0
 pak 0 0   0 0   1 0
 sak 0 1   0 0   0 0
 spak0 0   0 0   0 0
 
  (With more digits)
 
  Am I doing something stupid?

 I may be missing what you 

Re: [R] I am surprised (and a little irritated)

2006-04-20 Thread Tom Backer Johnsen
Detlef Steuer wrote:
 Hi,
 
 I`m the one to blame for the readme :-) and for providing the rpms.

I am sorry, but the note was not primarily directed at you, perhaps (I
am not sure) just as much at Linux in general, or Suse, or OpenSuse,
or ...  In any case, I am sure you do a great job at providing the
rpm's.  As to the readme, from my point of view there are some
information missing.
 
 If you encounter such big problems my readme sucks. But I'm open for
 critisism and will improve on the current situation for the
 release of R-2.3.0 next monday.

Using the word sucks is too strong.  But, so far, and from my point
of view, there is room for improvement.
 
 It would have helped, if I got the error messages you saw. Now  I just
 have to guess.

After installing Linux using the OpenSuse download CD's, when I try to
install the rpm for R-base, I am informed that libblas.so.3 is not
available and the same with libgfortran.so.0.  Neither of the two
are in the list in the readme.  However, I guess (which should not be
necessary) that the first refers to blas-3.0-926 in the list, and
the second to gcc-fortran-4.0.2  But I have have been unable to
locate these elements, neither on the CD's, nor on the dvd included in
the book on SUSE Linux 10 by McAllister which is supposed to have the
complete OpenSuse 10.  I may be wrong there, there are VERY many
rpms's on the dvd, but the task is not very simple.

The key is probably (perhaps) in the part where you have written:

quoteFrom R-2.2.1 on you can use the CRAN-Mirror near you as YAST
installation source. Just add $CRANMIRROR/bin/linux/suse/MAJOR.MINOR
as a http source as an installation source for yast. Alternatively you
may use the main package repository
http://fawn.hsu-hh.de/~steuer/SL-10.0-OSS ./quote

But I have been unable to see where to use this information with YAST
and how.  So, what is needed is information for the uninformed.

As far as I can see, a possible solution may be in using the apt
approach as suggested in the McAllister book.  Therefore I have
installed the synaptic program as well, but so far (that was late in
the day at the office and I do not have a full connection with the
Internet and Linux from home yet, only http), it did not help.  I'll
try again later today.
 
 I think you'll be able to find a step by step instruction by the end of
 the week on CRAN.

I am looking forward to that.  I hope that my tale of unsuccessful
attempts will be useful.

 Part of the problem is that R and Suse are moving targets. On the
 opensuse side there are packages, which are not on the CDs but in the
 online repositories that have to be downloaded seperately. Ranting
 alone won't help.

I am sure you are right about the problem.  As I have said before, I
do not intend to rant in any way.  But I would very much like to see
that R is as available on SUSE Linux (and Linux in general) as it is
on Windows for newcomers like me.

 Look here: http://www.thejemreport.com/mambo/content/view/178/42/
 for some introductory material.
 You can add http://fawn.hsu-hh.de/~steuer/SL-10.0-OSS as installation
 source for R and ESS.

That link looks very useful.  Perhaps the readme could be somewhat
similar?

 That the installation procedure is different for any flavour of Linux
 than the one you know from windows should not surprise you. Whatever
 distribution you'll end up using: the time invested to learn the
 respective package management system will pay back.

Yes, I am sure you are right, and I am not surprised at the
differences between the various flavours of Linux.  Still, I think
that instructions on installing R on a particular distribution should
be oriented towards the completely unintiated user.  More experienced
users can skip the trivial (in their view) parts.  But it should be
there by default.

I have to add that it is not very constructive to say read the
manual as some of the responses (not you) to my mail imply.  I do not
mind to read the manual, but at least I would like to know where to
look in the manuals.

In any case, would it be possible to persuade SUSE to include R in the
installation, at least as an option?
 
 Feel free to ask any question on R on SuSE. I would be happy to send
  you the next readme for review.

Thank you.  I look forward to that.

Tom

++
| Tom Backer Johnsen, Psychometrics Unit,  Faculty of Psychology |
| University of Bergen, Christies gt. 12, N-5015 Bergen,  NORWAY |
| Tel : +47-5558-9185Fax : +47-5558-9879 |
| Email : [EMAIL PROTECTED]URL : http://www.galton.uib.no/ |
++

__
R-help@stat.math.ethz.ch 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] Extract AIC, BIC

2006-04-20 Thread Sumanta Basak
Hi All,

How can extract AIC,BIC from a fitted Garch model?

--
SUMANTA BASAK.

[[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] I am surprised (and a little irritated)

2006-04-20 Thread Tom Backer Johnsen
Gabor Csardi wrote:
 So you don't want to read that manual after all? :)

I did not say so, not at all.  The point is that it is not very 
helpful to say Read the manual when the the problem is very much one 
of not knowing where to look in the manual.  Instructions for 
installing on a particular distribution should be focused on the 
uninitiated, not the experiences users.
 
 The thing is that for Linux you cannot just develop a program which 'just
 installs' or 'just works' on any Linux system. (Or even if you could do
 that, it is not worth the effort.) This is because 'Linux' is just an
 operating system kernel, shells, compilers, window managers, GUI's are NOT
 part of it.

I know.  But it should be possible to do so for a few of the major 
distros.  According to some of the responses, some of them even 
include R in the installation.

 This is what Linux disributions are for. They are collections of software
 containing both the kernel and the user tools (compilers, shells, R, etc.). 
 There are many thousends of linux distribution and they are not at all
 compatible with each other. It might happen that R is packaged differently
 in a distribution than in another, etc. This is a tough world, but also
 gives you the freedom of choice, some people like it, some people don't.
 
 For a software package like R, it is absolutely impossible to ensure that it
 can be installed cleanly without any problems on all the (say) two thousend
 linux distributions. Usually the people who packaged the piece of software
 (R in this case) for the specific distribution are the ones who can help you
 with installation problems. (Not always, but very likely with your problem.)
 And for most suse packages these people are the suse developers.

I am not referring to 2000 distributions.  I am referring to one of 
the most popular ones, SUSE.
 
 This is why i suggested to post to the suse list. But you got some useful
 hints from helpful people here, so after all you are lucky. :)

Yes, I am grateful (in the most part) for the responses, where 
Ditlef's one was in particular very constructive.  But (a) I am 
interested in using R, (b) I want to try R on one of the major 
distributions of Linux (c) I do not succeed in doing so.  What I 
wonder is then:  How many others have made the same attempt, not 
succeeded, and then given up?  Which I do not intend to do.

 I might have overreacted this, but it is really irritating that you
 just take the result of the really hard work of many people, the R software,
 for free, and then complain about something which you could solve easily
 just by searching on google or in the R mailing list archive, or reading the
 suse manuals.

Yes, I think you are being oversensitive.  On the contrary, it is 
because I DO realize that there is an enormous effort involved in the 
development of R that I am surprised that the final step, making it 
available to users is so difficult in this particular case.  That is, 
as far as I can see, something that is (or should be) of concern to 
the advocates of R (where I regard myself as included).  That is the 
reason for my mail to the list.

Tom

++
| Tom Backer Johnsen, Psychometrics Unit,  Faculty of Psychology |
| University of Bergen, Christies gt. 12, N-5015 Bergen,  NORWAY |
| Tel : +47-5558-9185Fax : +47-5558-9879 |
| Email : [EMAIL PROTECTED]URL : http://www.galton.uib.no/ |
++

__
R-help@stat.math.ethz.ch 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] nls and factor

2006-04-20 Thread Manuel Gutierrez
Is it possible to include a factor in an nls formula?
I've searched the help pages without any luck so I
guess it is not feasible.
I've given it a few attempts without luck getting the
message:
+ not meaningful for factors in:
Ops.factor(independ^EE, a)

This is a toy example, my realworld case is much more
complicated (and can not be solved linearizing an
using lm)
a-as.factor(c(rep(1,50),rep(0,50)))
independ-rnorm(100)
respo-rep(NA,100)
respo[a==1]-(independ[a==1]^2.3)+2
respo[a==0]-(independ[a==0]^2.1)+3
nls(respo~independ^EE+a,start=list(EE=1.8),trace=TRUE)

Any pointers welcomed
Many Thanks,
Manu

__
R-help@stat.math.ethz.ch 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] Breakdown a number

2006-04-20 Thread Paul Roebuck
On Thu, 20 Apr 2006, Gabor Grothendieck wrote:

 On 4/19/06, Paul Roebuck [EMAIL PROTECTED] wrote:
  On Wed, 19 Apr 2006, Gabor Grothendieck wrote:
 
   On 4/19/06, Paul Roebuck [EMAIL PROTECTED] wrote:
  
Isn't there a builtin method for doing this and, if so,
what is it called?
   
   breakdown - function(whole) {
   breaks - c(250, 800)
   pieces - integer(length(breaks) + 1)
   if (whole  breaks[2]) {
   pieces[3] - whole - breaks[2]
   whole - breaks[2]
   }
   if (whole  breaks[1]) {
   pieces[2] - whole - breaks[1]
   whole - breaks[1]
   }
   pieces[1] - whole
   
   return(pieces)
   }
   
breakdown(1200) # 250 550 400
  
   Maybe you could discuss in words what you want but perhaps
   you are looking for diff:
 
  That was rather my problem searching for my answer as I
  was unsure what this was called. I was searching for
  'bins' or 'breaks' (like in hist method but not for
  plotting) and leading nowhere fast. Alas, I thought
  sample code would go further than my description.
 
 
bp - c(0, 250, 800, 1200)
diff(bp)
   [1] 250 550 400
 
  Don't think diff method is going to work either, at
  least in cases where the 'whole' is less than greatest
  'break'.
 
   breakdown2 - function(x, breaks = c(250, 800)) {
   diff(c(0, breaks, x))
   }
   breakdown(10) # 10 0 0
   breakdown2(10)# 250 550 -790
  
   breakdown(400)# 250 150 0
   breakdown2(400)   # 250 550 -400
 

 Just sort it:

 bd - function(x, breaks = c(250, 800)) diff(sort(c(0, breaks, x)))

Doesn't work either. Tests below didn't fare well.

 If you don't want the 0 values in the case that x is one of the
 breaks then use diff(sort(unique(c(0, breaks, x

I did want the zeros in the result.

###
check.results - function(input) {
stopifnot(input = 0)
output - bd(input)
expected - breakdown(input)
if (!identical(output, expected)) {
cat(expected:, expected, \n)
cat(output:  , output,   \n)
return(FALSE)
} else {
return(TRUE)
}
}

check.results(1200) # TRUE
check.results(800)  # TRUE
check.results(799)  # FALSE
check.results(500)  # FALSE
check.results(250)  # FALSE
check.results(200)  # FALSE
check.results(1)# FALSE
check.results(0)# FALSE

Goal was to split value according to breaks such that each
piece of it could later be multiplied with a corresponding
rate. It's not unlike the type of processing that would go
into figuring out how much a hypothetical out-of-state phone
call would cost (for example, .10 for first five minutes,
0.07 for next ten minutes, and 0.05 for rest of the call)

calc.cost.per.call - function(minutes) {
duration - bd(minutes, breaks = c(5, 10))
rates - c(0.10, 0.07, 0.05)
sum(duration * rates)
}

calc.cost.per.call(24)  # would be 1.65


Thanks for your help.

--
SIGSIG -- signature too long (core dumped)

__
R-help@stat.math.ethz.ch 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] nls and factor

2006-04-20 Thread Andrew Robinson
Manuel,

I don't think that it works very easily.  Instead, try gnls() in the
nlme package.

Cheers

Andrew

On Thu, Apr 20, 2006 at 11:18:02AM +0200, Manuel Gutierrez wrote:
 Is it possible to include a factor in an nls formula?
 I've searched the help pages without any luck so I
 guess it is not feasible.
 I've given it a few attempts without luck getting the
 message:
 + not meaningful for factors in:
 Ops.factor(independ^EE, a)
 
 This is a toy example, my realworld case is much more
 complicated (and can not be solved linearizing an
 using lm)
 a-as.factor(c(rep(1,50),rep(0,50)))
 independ-rnorm(100)
 respo-rep(NA,100)
 respo[a==1]-(independ[a==1]^2.3)+2
 respo[a==0]-(independ[a==0]^2.1)+3
 nls(respo~independ^EE+a,start=list(EE=1.8),trace=TRUE)
 
 Any pointers welcomed
 Many Thanks,
 Manu
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

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

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


[R] info : Manova - eigenvector analysis and canonical analysis

2006-04-20 Thread Céline Hauzy

Hello everybody !

I try to obtain in R eigenvectors and canonical analysis on MANOVA results, 
but I don't find how to process?
In particular, I would be interesting to obtain standardized canonical 
coefficients of the canonical variates. There analysis give some 
information on the correlation between response variates.

My data are organised in 2 terms (one is continu, one is a factor) and 3 
response variates (continus).

summary(manova(cbind(dureeL,dureeI,dureeR)~denst*etatav, data=durt))
Df  Pillai approx F num Df den DfPr(F)
 denst  1  0.3047  10.6629  3 73 6.795e-06 ***
 etatav 1  0.1070   2.9146  3 73   0.03995 *
 denst:etatav   1  0.0324   0.8138  3 73   0.49035
Residuals  75
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1


I hope you can help me.
best regards

Céline Hauzy



Céline Hauzy

Laboratoire Bioemco
Ecole Normale Supérieure
46 rue d'Ulm
75230 Paris Cedex 05

Tel : 01 44 32 38 78
Fax : 01 44 32 38 85

info

__
R-help@stat.math.ethz.ch 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] nls and factor

2006-04-20 Thread Manuel Gutierrez
Thanks Andrew. I am now trying but without much
success. I don't now how to give start values for the
factor?.
Could you give me an example solution with my toy
example?

a-as.factor(c(rep(1,50),rep(0,50)))
independ-1:100
respo-rep(NA,100)
respo[a==1]-(independ[a==1]^2.3)+2
respo[a==0]-(independ[a==0]^2.1)+3
library(nlme)
gnls(respo~independ^b+a,start=list(b=1.8))

Many thanks.
Manu

 --- Andrew Robinson [EMAIL PROTECTED]
escribió:

 Manuel,
 
 I don't think that it works very easily.  Instead,
 try gnls() in the
 nlme package.
 
 Cheers
 
 Andrew
 
 On Thu, Apr 20, 2006 at 11:18:02AM +0200, Manuel
 Gutierrez wrote:
  Is it possible to include a factor in an nls
 formula?
  I've searched the help pages without any luck so I
  guess it is not feasible.
  I've given it a few attempts without luck getting
 the
  message:
  + not meaningful for factors in:
  Ops.factor(independ^EE, a)
  
  This is a toy example, my realworld case is much
 more
  complicated (and can not be solved linearizing an
  using lm)
  a-as.factor(c(rep(1,50),rep(0,50)))
  independ-rnorm(100)
  respo-rep(NA,100)
  respo[a==1]-(independ[a==1]^2.3)+2
  respo[a==0]-(independ[a==0]^2.1)+3
 

nls(respo~independ^EE+a,start=list(EE=1.8),trace=TRUE)
  
  Any pointers welcomed
  Many Thanks,
  Manu
  
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html
 
 -- 
 Andrew Robinson  
 Department of Mathematics and Statistics   
 Tel: +61-3-8344-9763
 University of Melbourne, VIC 3010 Australia
 Fax: +61-3-8344-4599
 Email: [EMAIL PROTECTED]
 http://www.ms.unimelb.edu.au


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


Re: [R] Randomly selecting one row for each factor level [Broadca st]

2006-04-20 Thread Liaw, Andy
The following should work:

 dfr.samp - dfr[tapply(1:nrow(dfr), dfr$x, sample, 1),]
 dfr.samp
   x  y z
10 a 10 J
2  b  2 B
9  c  9 I

Andy

From: Kelly Hildner
 
 I don't use R much, and I have been unable to figure out how 
 to get the 
 subset of my data frame that I would like.
 
 For example, if this were my data frame:
 
   dfr - data.frame(x=rep(letters[1:3], 4), y=(1:12), 
 z=(LETTERS[1:12]))   dfr
 x  y z
 1  a  1 A
 2  b  2 B
 3  c  3 C
 4  a  4 D
 5  b  5 E
 6  c  6 F
 7  a  7 G
 8  b  8 H
 9  c  9 I
 10 a 10 J
 11 b 11 K
 12 c 12 L
 
 I would like to randomly select one row for each level of the 
 factor x 
 and create a new data frame with the results.  For example, 
 the result 
 might be:
 
 x  y z
 1  a  1 A
 5  b  5 E
 6  c  6 F
 
 Any help would be greatly appreciated!
 
 Thanks,
 Kelly
 
 -- 
 K. Kelly Hildner, Ph.D.
 NOAA Fisheries
 Southwest Fisheries Science Center
 110 Shaffer Rd.
 Santa Cruz, CA 95060
 
 __
 R-help@stat.math.ethz.ch 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] I am surprised (and a little irritated)

2006-04-20 Thread Tom Backer Johnsen
Detlef Steuer wrote:
 On Thu, 20 Apr 2006 10:51:57 +0200

.

 Sometimes it is very hard to think of the questions a new user has,
 if you do it yourself on a daily basis for years.

I understand that very well.  Now I can tell you that I used the info 
in the Hacking OpenSuse link you provided to the letter, and 
followed all the instructions in the paragraph with the heading 
Adding sources to YaST.

After that installing R from the R-base rpm was simple.  It took a few 
minutes, but that does not matter.  Evidently all the necessary 
packages were located on from the locations on the net and were 
installed automatically.  So now R is installed and works.  The only 
drawback I can think of is that you have to be online to install.

Conclusion:  Put something like the info from the link in the readme 
and other users of R can be recruited from the SUSE world.

Thank you!

Tom

++
| Tom Backer Johnsen, Psychometrics Unit,  Faculty of Psychology |
| University of Bergen, Christies gt. 12, N-5015 Bergen,  NORWAY |
| Tel : +47-5558-9185Fax : +47-5558-9879 |
| Email : [EMAIL PROTECTED]URL : http://www.galton.uib.no/ |
++

__
R-help@stat.math.ethz.ch 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] 3D pie

2006-04-20 Thread Barry Rowlingson
Rolf Turner wrote:

 
 People really ***should not*** be encouraged or abetted in
 wrong-headedness.  Excel is terrible.  Pie charts are terrible.
 Don't mess with them.  Period.
 

  Now I realise the opportunity I missed on April 1st, when I was going 
to try and (anonymously) post the most flammable R-help posting ever. 
Something like:

  I'm trying to make a library with R 1.6.1 to create a 3-d pie chart 
in excel but seq(0,1,by=0.1)[4]==0.3 is false.


Barry

__
R-help@stat.math.ethz.ch 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] info : Manova - eigenvector analysis and canonical analysis

2006-04-20 Thread Céline Hauzy

Hello everybody !

I try to obtain in R eigenvectors and canonical analysis on MANOVA results, 
but I don't find how to process?
In particular, I would be interesting to obtain standardized canonical 
coefficients of the canonical variates. There analysis give some 
information on the correlation between response variates.

My data are organised in 2 terms (one is continu, one is a factor) and 3 
response variates (continus).

summary(manova(cbind(dureeL,dureeI,dureeR)~denst*etatav, data=durt))
Df  Pillai approx F num Df den DfPr(F)
 denst  1  0.3047  10.6629  3 73 6.795e-06 ***
 etatav 1  0.1070   2.9146  3 73   0.03995 *
 denst:etatav   1  0.0324   0.8138  3 73   0.49035
Residuals  75
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1


I hope you can help me.
best regards

Céline Hauzy



Céline Hauzy

Laboratoire Bioemco
Ecole Normale Supérieure
46 rue d'Ulm
75230 Paris Cedex 05

Tel : 01 44 32 38 78
Fax : 01 44 32 38 85

info

__
R-help@stat.math.ethz.ch 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] 3D pie

2006-04-20 Thread Stuart Leask
 On 19-Apr-06 Peter Ehlers wrote:
 This discussion of 3-d pie charts comes at an opportune time. I have
 just formulated a new theory of graphical information transfer which
 is particularly simple in the case of 3-d pie charts.

 Let theta denote the angle between the normal to the pie cylinder and
 the pie-eyed line (connecting eye and centre of pie). Then the
 information transmitted from pie to viewer is

K * (pi/2 - theta)^3

 for theta in [0, pi/2]. The normalizing constant may be written in
 the obvious manner as

K = 8 * I_0 / pi^3.

 I conjecture that I_0 is not large, but I'm still waiting to hear
 from Microsoft regarding my application for funding to allow me to
 conduct extensive testing.

 I think I can confirm your conjecture. With theta = 0, you have in
 effect a 2-D pie, and then, according to my calculations, if you take

  I_0 = 3.14159265358979...

 the information you get is 1 pie.

 Ted.

Unless you cut it into quarters, in which case you have that rare situation 
where pie by two equals pie by four...
... sorry 

Stuart



This message has been checked for viruses but the contents of an attachment
may still contain software viruses, which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.

__
R-help@stat.math.ethz.ch 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] nls and factor

2006-04-20 Thread Prof Brian Ripley
On Thu, 20 Apr 2006, Manuel Gutierrez wrote:

 Is it possible to include a factor in an nls formula?

Yes.  What do you intend by it?  If you mean what it would mean for a lm 
formula, you need A[a] and starting values for A.

There's an example on p.219 of MASS4.

 I've searched the help pages without any luck so I
 guess it is not feasible.
 I've given it a few attempts without luck getting the
 message:
 + not meaningful for factors in:
 Ops.factor(independ^EE, a)

 This is a toy example, my realworld case is much more
 complicated (and can not be solved linearizing an
 using lm)
 a-as.factor(c(rep(1,50),rep(0,50)))
 independ-rnorm(100)
 respo-rep(NA,100)
 respo[a==1]-(independ[a==1]^2.3)+2
 respo[a==0]-(independ[a==0]^2.1)+3
 nls(respo~independ^EE+a,start=list(EE=1.8),trace=TRUE)

 Any pointers welcomed
 Many Thanks,
 Manu

 __
 R-help@stat.math.ethz.ch 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] (sem assunto)

2006-04-20 Thread Eric Ferreira
Dear R-colleagues,

Is it possible to mix TEXT and VALUE of objects in y (or x) label of a plot?

For instance:

f-2
plot(..., ylab='Axis f', ...)

where f means the VALUE of f.

Thany you in advance,


Eric.

--
Barba
Departamento de Ciências Exatas
Universidade Federal de Lavras
Minas Gerais - Brasil

[[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] Breakdown a number

2006-04-20 Thread Gabor Grothendieck
Try using breaks[breaks = x] in place of breaks.   Your solution
always returns three components if breaks has two whereas this one
does not but you could extend the output it if that is an essential part.

On 4/20/06, Paul Roebuck [EMAIL PROTECTED] wrote:
 On Thu, 20 Apr 2006, Gabor Grothendieck wrote:

  On 4/19/06, Paul Roebuck [EMAIL PROTECTED] wrote:
   On Wed, 19 Apr 2006, Gabor Grothendieck wrote:
  
On 4/19/06, Paul Roebuck [EMAIL PROTECTED] wrote:
   
 Isn't there a builtin method for doing this and, if so,
 what is it called?

breakdown - function(whole) {
breaks - c(250, 800)
pieces - integer(length(breaks) + 1)
if (whole  breaks[2]) {
pieces[3] - whole - breaks[2]
whole - breaks[2]
}
if (whole  breaks[1]) {
pieces[2] - whole - breaks[1]
whole - breaks[1]
}
pieces[1] - whole

return(pieces)
}

 breakdown(1200) # 250 550 400
   
Maybe you could discuss in words what you want but perhaps
you are looking for diff:
  
   That was rather my problem searching for my answer as I
   was unsure what this was called. I was searching for
   'bins' or 'breaks' (like in hist method but not for
   plotting) and leading nowhere fast. Alas, I thought
   sample code would go further than my description.
  
  
 bp - c(0, 250, 800, 1200)
 diff(bp)
[1] 250 550 400
  
   Don't think diff method is going to work either, at
   least in cases where the 'whole' is less than greatest
   'break'.
  
breakdown2 - function(x, breaks = c(250, 800)) {
diff(c(0, breaks, x))
}
breakdown(10) # 10 0 0
breakdown2(10)# 250 550 -790
   
breakdown(400)# 250 150 0
breakdown2(400)   # 250 550 -400
  
 
  Just sort it:
 
  bd - function(x, breaks = c(250, 800)) diff(sort(c(0, breaks, x)))

 Doesn't work either. Tests below didn't fare well.

  If you don't want the 0 values in the case that x is one of the
  breaks then use diff(sort(unique(c(0, breaks, x

 I did want the zeros in the result.

 ###
 check.results - function(input) {
stopifnot(input = 0)
output - bd(input)
expected - breakdown(input)
if (!identical(output, expected)) {
cat(expected:, expected, \n)
cat(output:  , output,   \n)
return(FALSE)
} else {
return(TRUE)
}
 }

 check.results(1200) # TRUE
 check.results(800)  # TRUE
 check.results(799)  # FALSE
 check.results(500)  # FALSE
 check.results(250)  # FALSE
 check.results(200)  # FALSE
 check.results(1)# FALSE
 check.results(0)# FALSE

 Goal was to split value according to breaks such that each
 piece of it could later be multiplied with a corresponding
 rate. It's not unlike the type of processing that would go
 into figuring out how much a hypothetical out-of-state phone
 call would cost (for example, .10 for first five minutes,
 0.07 for next ten minutes, and 0.05 for rest of the call)

 calc.cost.per.call - function(minutes) {
duration - bd(minutes, breaks = c(5, 10))
rates - c(0.10, 0.07, 0.05)
sum(duration * rates)
 }

 calc.cost.per.call(24)  # would be 1.65


 Thanks for your help.

 --
 SIGSIG -- signature too long (core dumped)

 __
 R-help@stat.math.ethz.ch 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] R-Help

2006-04-20 Thread Gabor Grothendieck
Read them in as zoo objects (you can replace textConnection(Lines1)
with the filename) and then merge them using all = FALSE to retain
only common time points.  Note that in my English locale I had
to modify your Apl to Apr.

Lines1 - Date  x y
Jan-1,2005120   230
Jan-2,2005123   -125
Jan-3,2005-110  300
Jan-4,2005114   -21
Jan-7,200511299
Mar-5,2005200   311

Lines2 - Date  x  y
Jan-2,2005123   -125
Jan-3,2005-110  300
Jan-4,2005114   -21
Jan-5,200511299
Jan-6,2005-23   12
Mar-5,2005200   311

Lines3 - Date  x  y
Jan-3,2005-110  300
Jan-4,2005114   -21
Jan-5,200511299
Mar-5,2005200   311
Apr-23,2005   123   200
library(zoo)
DF1 - read.zoo(textConnection(Lines1), header = TRUE, format = %b-%d,%Y)
DF2 - read.zoo(textConnection(Lines2), header = TRUE, format = %b-%d,%Y)
DF3 - read.zoo(textConnection(Lines3), header = TRUE, format = %b-%d,%Y)
merge(DF1, DF2, DF3, all = FALSE)


On 4/20/06, stat stat [EMAIL PROTECTED] wrote:
 Dear r-users,

 Suppose I have three datasets:
  Dataset-1:
  Date  x y
  Jan-1,2005120   230
 Jan-2,2005123   -125
 Jan-3,2005-110  300
 Jan-4,2005114   -21
 Jan-7,200511299
 Mar-5,2005200   311

  Dataset-2:
  Date  x  y
  Jan-2,2005123   -125
 Jan-3,2005-110  300
 Jan-4,2005114   -21
 Jan-5,200511299
 Jan-6,2005-23   12
 Mar-5,2005200   311

  Dataset-3:
  Date  x  y
  Jan-3,2005-110  300
 Jan-4,2005114   -21
 Jan-5,200511299
 Mar-5,2005200   311
 Apl-23,2005   123   200
  Now I want to get the common dates along with x and y from this above three 
 datasets keeping the same order
 in date-variable as it is.
  For ex. I want to get:
  Datex  y xy  
 x  y
   (from dataset-1) (from dataset-2)  (from 
 dataset-3)
 
  Jan-3,2005-110  300  -110 300  -110  
 300
 Jan-4,2005 114  -21 114-21   114  
  -21
 Mar-5,2005200   311   200 311  200   
 311
  Can anyone give me any R code to implement this for any number of datasets ?
  Thanks and regards


 thanks in advance

 -


[[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] (sem assunto)

2006-04-20 Thread Chuck Cleland
f - 2
plot(runif(10), ylab=paste(Axis, f, collapse= ))

?paste

Eric Ferreira wrote:
 Dear R-colleagues,
 
 Is it possible to mix TEXT and VALUE of objects in y (or x) label of a plot?
 
 For instance:
 
 f-2
 plot(..., ylab='Axis f', ...)
 
 where f means the VALUE of f.
 
 Thany you in advance,
 
 
 Eric.
 
 --
 Barba
 Departamento de Ciências Exatas
 Universidade Federal de Lavras
 Minas Gerais - Brasil
 
   [[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) 512-0171 (M, W, F)
fax: (917) 438-0894

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


Re: [R] (sem assunto)

2006-04-20 Thread Gabor Grothendieck
Try paste:

paste(Axis, f)

On 4/20/06, Eric Ferreira [EMAIL PROTECTED] wrote:
 Dear R-colleagues,

 Is it possible to mix TEXT and VALUE of objects in y (or x) label of a plot?

 For instance:

 f-2
 plot(..., ylab='Axis f', ...)

 where f means the VALUE of f.

 Thany you in advance,


 Eric.

 --
 Barba
 Departamento de Ciências Exatas
 Universidade Federal de Lavras
 Minas Gerais - Brasil

[[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] prop.table on three-way table?

2006-04-20 Thread Marc Schwartz
On Thu, 2006-04-20 at 10:28 +0200, Fredrik Karlsson wrote:
 Hi marc,
 
 I did not manage ctab to do this for me. Again, I am probably using it
 wrong, but I don't know that the problem is.
 
 You asked for a more illustrated example, so here goes:
 
 Take this table:
 
  ftable(table(sample(paste(dim1_no,1:5,sep=),10,replace=TRUE),
 sample(paste(dim2_no,1:5,sep=),10,replace=TRUE),
 sample(paste(dim3_no,1:5,sep=),10,replace=TRUE)))
 
dim3_no1 dim3_no2 dim3_no3 dim3_no5
 
 dim1_no1 dim2_no1 0000
  dim2_no2 0020
  dim2_no3 0000
  dim2_no4 0000
  dim2_no5 0000
 dim1_no2 dim2_no1 0000
  dim2_no2 0000
  dim2_no3 0000
  dim2_no4 0000
  dim2_no5 0101
 dim1_no3 dim2_no1 0000
  dim2_no2 0000
  dim2_no3 0010
  dim2_no4 0000
  dim2_no5 0000
 dim1_no4 dim2_no1 1000
  dim2_no2 0000
  dim2_no3 0000
  dim2_no4 0000
  dim2_no5 1000
 dim1_no5 dim2_no1 0000
  dim2_no2 0100
  dim2_no3 1000
  dim2_no4 0100
  dim2_no5 0000
 
 
 Now, I would like to get the per cent occurrence of each level of
 dim3_noX witin the cells by dim1 and dim2. Thus, for this part section
 of the table above:
 
dim3_no1 dim3_no2 dim3_no3 dim3_no5
 dim1_no2 dim2_no1 0000
  dim2_no2 0000
  dim2_no3 0000
  dim2_no4 0000
  dim2_no5 0101
 
 I would like to get:
 
dim3_no1 dim3_no2 dim3_no3 dim3_no5
 dim1_no2 dim2_no1 0000
  dim2_no2 0000
  dim2_no3 0000
  dim2_no4 0000
  dim2_no5 00.500.5
 
 since dim3_no2 represented 50% of the frequency within the cell
 created by dim1_no2 and dim2_no5.
 
 
 Hope that helped clarify my previous explanation of the problem.


Fredrik,

If I correctly understand what you are doing, which seems to be to
calculate row based percentages (actually proportions) within each
subgroup, the following should do it. 

Note that I am using set.seed() so that you can reproduce the data in
question here.


library(catspec)

set.seed(1)

x - table(sample(paste(dim1_no, 1:5, sep = ), 10, replace = TRUE),
   sample(paste(dim2_no, 1:5, sep = ), 10, replace = TRUE),
   sample(paste(dim3_no, 1:5, sep = ), 10, replace = TRUE))

ctab(x, type = row, percentages = FALSE)



Thus, 'x' is:

 x
, ,  = dim3_no1

  
   dim2_no1 dim2_no3 dim2_no4 dim2_no5
  dim1_no10000
  dim1_no30000
  dim1_no40010
  dim1_no50100

, ,  = dim3_no2

  
   dim2_no1 dim2_no3 dim2_no4 dim2_no5
  dim1_no10100
  dim1_no30000
  dim1_no41000
  dim1_no50000

, ,  = dim3_no3

  
   dim2_no1 dim2_no3 dim2_no4 dim2_no5
  dim1_no10100
  dim1_no30021
  dim1_no40000
  dim1_no50000

, ,  = dim3_no4

  
   dim2_no1 dim2_no3 dim2_no4 dim2_no5
  dim1_no10000
  dim1_no30000
  dim1_no40010
  dim1_no50000

, ,  = dim3_no5

  
   dim2_no1 dim2_no3 dim2_no4 dim2_no5
  dim1_no10000
  dim1_no30010
  dim1_no40000
  dim1_no50000



More concisely viewed as:

 ftable(x)
   dim3_no1 dim3_no2 dim3_no3 dim3_no4 dim3_no5
   

Re: [R] there is no xls reader in R?

2006-04-20 Thread roger bos
I like to use the RODBC package for doing this.  Here is my code sample:

xls -  odbcConnectExcel(fname)
rawdata.temp -  sqlFetch(xls, rawdata, max=2800)
close(xls)

fname is the full path to the file and rawdata is the name of the excel
sheet I want to import.  I tried one other approach (I think it was read.xls())
and that approach used perl scripts to read in the xls file and was very
slow.  RODBC is very fast and has always worked great for me.  Haven't tried
any of the other ways mentioned.



On 4/20/06, Ko-Kang Kevin Wang [EMAIL PROTECTED] wrote:

 Have a look at the read.xls() in gdata package.

 HTH,

 Kevin

 Michael wrote:
  Currently I have to convert all my xls into csv before I can read it
 in
  and process the excel data in R...
 
  Is there a way to directly read in xls data?
 
  Thanks a lot!
 
[[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

 --
 Ko-Kang Kevin Wang
 Homepage: http://wwwmaths.anu.edu.au/~wangk/
 Ph (W): +61-2-6125-2431
 Ph (H): +61-2-6125-7471
 Ph (M): +61-40-451-8301

 __
 R-help@stat.math.ethz.ch 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


Re: [R] R-Help

2006-04-20 Thread john seers \(IFR\)


I think this does what you require.

#Read your data in whatever way you wish:

d1-data.frame(Date=c(2005/1/1,2005/2/1,2005/1/3,2005/1/4,2005/
1/7,2005/3/5),
x=c(119,123,-110,114,11,200),
y=c(230,-125,300,-21,299,311))

d2-data.frame(Date=c(2005/1/3,2005/1/4,2005/1/5,2005/1/6,2005/
3/5),
x=c(-220,116,888,-239,201),
y=c(301,-23,3000,122,312))


d3-data.frame(Date=c(2005/1/4,2005/1/5,2005/3/5,2005/4/23),
x=c(392,511,600,723),
y=c(-81,6699,9311,1200))


#Make a list

listof-list(d1,d2,d3)


#loop over any number of datasets merging as you go

for ( dataset in 1:length(listof)-1) {
if (dataset == 1) {

res-merge(listof[dataset],listof[dataset+1],all=T,by=Date)   
} else {
res-merge(res,listof[dataset+1],all=T,by=Date)   
}
}


# Hope that helps


JS







 
---

John Seers
Institute of Food Research
Norwich Research Park
Colney
Norwich
NR4 7UA
 

tel +44 (0)1603 251490 
fax +44 (0)1603 255167
e-mail [EMAIL PROTECTED] 
e-disclaimer at http://www.ifr.ac.uk/edisclaimer/ 
 
Web sites:

www.ifr.ac.uk   
www.foodandhealthnetwork.com


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of stat stat
Sent: 20 April 2006 09:17
To: r-help@stat.math.ethz.ch
Subject: [R] R-Help


Dear r-users,
  
Suppose I have three datasets:
  Dataset-1:
  Date  x y
  Jan-1,2005120   230
Jan-2,2005123   -125
Jan-3,2005-110  300
Jan-4,2005114   -21
Jan-7,200511299
Mar-5,2005200   311
   
  Dataset-2:
  Date  x  y
  Jan-2,2005123   -125
Jan-3,2005-110  300
Jan-4,2005114   -21
Jan-5,200511299
Jan-6,2005-23   12
Mar-5,2005200   311
   
  Dataset-3:
  Date  x  y
  Jan-3,2005-110  300
Jan-4,2005114   -21
Jan-5,200511299
Mar-5,2005200   311
Apl-23,2005   123   200
  Now I want to get the common dates along with x and y from this above
three datasets keeping the same order
in date-variable as it is.
  For ex. I want to get:
  Datex  y xy
x  y
   (from dataset-1) (from dataset-2)  (from
dataset-3)


  Jan-3,2005-110  300  -110 300
-110  300
Jan-4,2005 114  -21 114-21   114
-21
Mar-5,2005200   311   200 311  200
311
  Can anyone give me any R code to implement this for any number of
datasets ?
  Thanks and regards


thanks in advance

-


[[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] I am surprised (and a little irritated)

2006-04-20 Thread Tom Backer Johnsen
Detlef:

For your information.  A few days ago I ordered SuSE 10, the version
corresponding to the old Professional.  It arrived today, and was
installed.  When the R-base rpm was downloaded with Mozilla Firebird,
it was only to open it when the download was finished, click the
install with YaST button, and everything went smooth.  I had to
insert the DVD, where it looked like all the other components were found.

So, most of the necessary modifications in the readme will refer to
the OpenSuse version alone.  The commercial version is very simple.

Tom

++
| Tom Backer Johnsen, Psychometrics Unit,  Faculty of Psychology |
| University of Bergen, Christies gt. 12, N-5015 Bergen,  NORWAY |
| Tel : +47-5558-9185Fax : +47-5558-9879 |
| Email : [EMAIL PROTECTED]URL : http://www.galton.uib.no/ |
++

__
R-help@stat.math.ethz.ch 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] more on aov contrasts residual error calculation

2006-04-20 Thread Steven Lacey
Hi, 
 
I haven't recieved any replies to my last email, so let me be a bit more
specific. I have a dataframe and it has the following structure:
 
Condition
Mapping SubjectABC
11 510   15 
12
13
14
15
16
17
18
29
210
 
Mapping is a between-subject factor. Condition is a within-subject factor.
There are 5 levels of mapping, 8 subjects nested in each level of mapping.
For each of the 40 combinations of mapping and subject there are 3
observations, one in each level of the condition factor. 
 
I want to estimate the pooled error associated with the following set of 4
orthogonal contrasts:
 
condition.L:mapping.L
condition.L:mapping.Q
condition.L:mapping.C
condition.L:mapping^4
 
What is the best way to do this? One way is to estimate the linear contrast
for condition for each subject, create a 40 row matrix where the measure for
each combination of mapping and subject is the linear contrast on condition.
If I pass this dataframe to aov, the mse it returns is the value I am
looking for. 
 
If possible, I would like to obtain the estimate without collapsing the
dataframe, but am not sure how to proceed. Suggestions?
 
Steve

[[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] Online course - graphics in R

2006-04-20 Thread Peter C. Bruce
Dr. Paul Murrell will offer his Graphics in R course
online at statistics.com May 5 – June 2.

This course teaches you how to produce publication-quality
statistical plots of data using R (a freely available open-
source statistical language and environment).  It will
cover plots such as scatterplots, bar plots, histograms,
boxplots and Trellis plots.  It will review the underlying
model used to produce plots in R so that you can
extensively customize these plots.  Finally, the course
will introduce the grid graphics system and look at
producing unique plots from the ground up using basic
components.

Dr. Murrell, the author of R Graphics, has been a member
of the core development team for R since 1999, with a focus
on the graphics system in R.  He is the Editor-in-Chief of
R News, the newsletter of the R project, and an Associate
Editor for Computational Statistics.  He is also Chair of
the American Statistical Association's Statistical Graphics
Section, and a Senior Lecturer in the Department of
Statistics at the University of Auckland, New Zealand.

The course lasts four weeks and consists of a series of
four weekly lessons (directed readings and/or notes, plus
exercises).  Direct interaction (QA) with the instructor
throughout the four week period takes place via a private
discussion board.  Expect to spend about 5-15 hours per
week; there are no set hours when you must be online.

Details and registration:

http://www.statistics.com/content/courses/graphicsR/

Peter Bruce
[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] (sem assunto)

2006-04-20 Thread Eric Ferreira
Thak you very much indeed!

Eric.

On 4/20/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:

 Try paste:

 paste(Axis, f)

 On 4/20/06, Eric Ferreira [EMAIL PROTECTED] wrote:
  Dear R-colleagues,
 
  Is it possible to mix TEXT and VALUE of objects in y (or x) label of a
 plot?
 
  For instance:
 
  f-2
  plot(..., ylab='Axis f', ...)
 
  where f means the VALUE of f.
 
  Thany you in advance,
 
 
  Eric.
 
  --
  Barba
  Departamento de Ciências Exatas
  Universidade Federal de Lavras
  Minas Gerais - Brasil
 
 [[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
 
 




--
Barba
Departamento de Ciências Exatas
Universidade Federal de Lavras
Minas Gerais - Brasil

[[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] S4 objects with list of objects as slots: how to subset?

2006-04-20 Thread Francois . Bastardie
Hello,

I don't manage to see if you have already focussed on this point in some 
previous messages so I post my question:

I have a little problem with the S4 style of programming.
I tried to formalize my question: please consider the following example 
that you can run I think:

#--
setClass(my.class1,
 representation(
 my.list= list),
 prototype=prototype(
 my.list=list()))

#--
setClass(my.class2,
 representation(
 my.slot= numeric),
 prototype=prototype(
 my.slot=as.numeric(1:10)))

#--
a.class - new(my.class1)
[EMAIL PROTECTED] - new(my.class2)
[EMAIL PROTECTED] - new(my.class2)


using indexation, using my class definitions, how could I avoid the 
following FOR-loop (for performance purpose if it changes something) to 
get straightforward for example result = c(1:10,1:10) ?

result -NULL
for (i in 1:length([EMAIL PROTECTED]))
{
result - c(result, [EMAIL PROTECTED]@my.slot)
}


this following code doesn't work:
[EMAIL PROTECTED]:[EMAIL PROTECTED]


I hope I have been clear,
Thank you,
Regards,

-- 

François Bastardie

French Research Institute for the Development of the Sea (IFREMER)
Ecologie et Modèles pour l'Halieutique
Rue de l'Ile d'Yeu
BP 21105
44311 NANTES Cedex 03 - France
Tél : 02 40 37 41 64
Fax : 02 40 37 40 75
E-mail : [EMAIL PROTECTED]

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


Re: [R] S4 objects with list of objects as slots: how to subset?

2006-04-20 Thread Gabor Grothendieck
Try:

c(sapply(1:2, function(i) [EMAIL PROTECTED]@my.slot))


On 4/20/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 Hello,

 I don't manage to see if you have already focussed on this point in some
 previous messages so I post my question:

 I have a little problem with the S4 style of programming.
 I tried to formalize my question: please consider the following example
 that you can run I think:

 #--
 setClass(my.class1,
 representation(
 my.list= list),
 prototype=prototype(
 my.list=list()))

 #--
 setClass(my.class2,
 representation(
 my.slot= numeric),
 prototype=prototype(
 my.slot=as.numeric(1:10)))

 #--
 a.class - new(my.class1)
 [EMAIL PROTECTED] - new(my.class2)
 [EMAIL PROTECTED] - new(my.class2)


 using indexation, using my class definitions, how could I avoid the
 following FOR-loop (for performance purpose if it changes something) to
 get straightforward for example result = c(1:10,1:10) ?

 result -NULL
 for (i in 1:length([EMAIL PROTECTED]))
{
result - c(result, [EMAIL PROTECTED]@my.slot)
}


 this following code doesn't work:
 [EMAIL PROTECTED]:[EMAIL PROTECTED]


 I hope I have been clear,
 Thank you,
 Regards,

 --
 
 François Bastardie

 French Research Institute for the Development of the Sea (IFREMER)
 Ecologie et Modèles pour l'Halieutique
 Rue de l'Ile d'Yeu
 BP 21105
 44311 NANTES Cedex 03 - France
 Tél : 02 40 37 41 64
 Fax : 02 40 37 40 75
 E-mail : [EMAIL PROTECTED]

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


__
R-help@stat.math.ethz.ch 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] parsing arguments of a function

2006-04-20 Thread Thomas Kaliwe
Hi,
 
I have a simple problem writing a function that is to be called like
 
Myfunction( Column1 = low, Column2 = high, Column3 = all, Column4 = all,
data = mydata)
{.
contourplot(z ~ mydata$Column3* mydata$Column3)
.
}
 
Where Column1 and Column1 are the names of the dataframe mydata.
How do I parse the arguments to obtain both, name and value of the
argument.
I tried strsplit(Column1, =) which gives me two strings but then I
fail to access the the corresponding columns of the dataframe with what
I get. I also tried eval(parse(text = .)) but it wont work. What am I
doing wrong. Please, somebody must have done something like that before.
I'm thankful for any hint.
 
Greetings

[[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] The contrary of command %in%

2006-04-20 Thread Ghislain Vieilledent
Dear r-list,

I've got a data base:
 HData[1:10,]
   NumTree   Site Species Date Age DBHH IdentTree
11 Queige  Spruce 2002 184  49 33.5  Queige 1
22 Queige Fir 2002  NA   5  4.6  Queige 2
33 Queige Fir 2002  25   8  6.6  Queige 3
44 Queige  Spruce 2002 198  47 32.5  Queige 4
55 Queige Fir 2002 200  59 35.3  Queige 5
66 Queige  Spruce 2002  80  16  9.4  Queige 6
77 Queige Fir 2002  NA   5  4.2  Queige 7
88 Queige Fir 2002 200  44 32.5  Queige 8
99 Queige Fir 2002  NA   5  3.4  Queige 9
10  10 Queige  Spruce 2002 167  48 32.8 Queige 10
...

I want to remove particular points determined by
 HDataPartP-HData[H1.30,]
and
 HDataPartP2-HData[H8DBH20,]

That's why I want to use subset in a close form to:
HData2-subset(HData,HData$H1.30HData$IdentTree
not%in%HDataPartP2$IdentTree)

How should I do that ?
Is there any R-syntax saying not element of that object ?

Thanks for your help.

Ghislain.

--
Ghislain Vieilledent
06 24 62 65 07

[[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] The contrary of command %in%

2006-04-20 Thread Gabor Csardi
 a - 1:10
 a
 [1]  1  2  3  4  5  6  7  8  9 10
  c(1,2,3,11,12,13) %in% a
[1]  TRUE  TRUE  TRUE FALSE FALSE FALSE
 !  c(1,2,3,11,12,13) %in% a
[1] FALSE FALSE FALSE  TRUE  TRUE  TRUE

Is this it?

Gabor
   
On Thu, Apr 20, 2006 at 02:54:39PM +0200, Ghislain Vieilledent wrote:
 Dear r-list,
 
 I've got a data base:
  HData[1:10,]
NumTree   Site Species Date Age DBHH IdentTree
 11 Queige  Spruce 2002 184  49 33.5  Queige 1
 22 Queige Fir 2002  NA   5  4.6  Queige 2
 33 Queige Fir 2002  25   8  6.6  Queige 3
 44 Queige  Spruce 2002 198  47 32.5  Queige 4
 55 Queige Fir 2002 200  59 35.3  Queige 5
 66 Queige  Spruce 2002  80  16  9.4  Queige 6
 77 Queige Fir 2002  NA   5  4.2  Queige 7
 88 Queige Fir 2002 200  44 32.5  Queige 8
 99 Queige Fir 2002  NA   5  3.4  Queige 9
 10  10 Queige  Spruce 2002 167  48 32.8 Queige 10
 ...
 
 I want to remove particular points determined by
  HDataPartP-HData[H1.30,]
 and
  HDataPartP2-HData[H8DBH20,]
 
 That's why I want to use subset in a close form to:
 HData2-subset(HData,HData$H1.30HData$IdentTree
 not%in%HDataPartP2$IdentTree)
 
 How should I do that ?
 Is there any R-syntax saying not element of that object ?
 
 Thanks for your help.
 
 Ghislain.
 
 --
 Ghislain Vieilledent
 06 24 62 65 07
 
   [[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

-- 
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] The contrary of command %in%

2006-04-20 Thread Liaw, Andy
Just negate the result of %in%; e.g.,

! a %in% b

Andy

From: Ghislain Vieilledent
 
 Dear r-list,
 
 I've got a data base:
  HData[1:10,]
NumTree   Site Species Date Age DBHH IdentTree
 11 Queige  Spruce 2002 184  49 33.5  Queige 1
 22 Queige Fir 2002  NA   5  4.6  Queige 2
 33 Queige Fir 2002  25   8  6.6  Queige 3
 44 Queige  Spruce 2002 198  47 32.5  Queige 4
 55 Queige Fir 2002 200  59 35.3  Queige 5
 66 Queige  Spruce 2002  80  16  9.4  Queige 6
 77 Queige Fir 2002  NA   5  4.2  Queige 7
 88 Queige Fir 2002 200  44 32.5  Queige 8
 99 Queige Fir 2002  NA   5  3.4  Queige 9
 10  10 Queige  Spruce 2002 167  48 32.8 Queige 10
 ...
 
 I want to remove particular points determined by
  HDataPartP-HData[H1.30,]
 and
  HDataPartP2-HData[H8DBH20,]
 
 That's why I want to use subset in a close form to: 
 HData2-subset(HData,HData$H1.30HData$IdentTree
 not%in%HDataPartP2$IdentTree)
 
 How should I do that ?
 Is there any R-syntax saying not element of that object ?
 
 Thanks for your help.
 
 Ghislain.
 
 --
 Ghislain Vieilledent
 06 24 62 65 07
 
   [[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] The contrary of command %in%

2006-04-20 Thread Christos Hatzis
A flexible way for doing this is to define logical vectors for the types of
samples that you want to include or exclude.  You can then use logical
negation to select the complementary set:

inSet1 - HData$H  1.3
inSet2 - HData$H  8  Hdata$DBH  20

HDataPart1 - Hdata[!inSet1, ]
HDataPart2 - Hdata[!inSet2, ] 

-Christos

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Ghislain Vieilledent
Sent: Thursday, April 20, 2006 8:55 AM
To: r-help@stat.math.ethz.ch
Subject: [R] The contrary of command %in%

Dear r-list,

I've got a data base:
 HData[1:10,]
   NumTree   Site Species Date Age DBHH IdentTree
11 Queige  Spruce 2002 184  49 33.5  Queige 1
22 Queige Fir 2002  NA   5  4.6  Queige 2
33 Queige Fir 2002  25   8  6.6  Queige 3
44 Queige  Spruce 2002 198  47 32.5  Queige 4
55 Queige Fir 2002 200  59 35.3  Queige 5
66 Queige  Spruce 2002  80  16  9.4  Queige 6
77 Queige Fir 2002  NA   5  4.2  Queige 7
88 Queige Fir 2002 200  44 32.5  Queige 8
99 Queige Fir 2002  NA   5  3.4  Queige 9
10  10 Queige  Spruce 2002 167  48 32.8 Queige 10
...

I want to remove particular points determined by
 HDataPartP-HData[H1.30,]
and
 HDataPartP2-HData[H8DBH20,]

That's why I want to use subset in a close form to:
HData2-subset(HData,HData$H1.30HData$IdentTree
not%in%HDataPartP2$IdentTree)

How should I do that ?
Is there any R-syntax saying not element of that object ?

Thanks for your help.

Ghislain.

--
Ghislain Vieilledent
06 24 62 65 07

[[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] Count Unique Rows/Values

2006-04-20 Thread Sachin J
Hi,
   
  I have a dataset which has both numeric and character values with 
dupllicates. For example:
   
  155   A
138   A
138   B
126   C
126   D
123   A
103   A
103   B
143   D
111   C
111   D
156   C
   
  How can I count the number of unqiue entries without counting duplicate 
entries. Also can I extract the list in a object. What I mean is
   Col1 unique count = 8  Unique Elements are : 103,111,123,126,138,143,155,156
   Col2 unique count = 4  Unique Elements are :  A,B,C,D.
   
  Any pointers would be of great help.
   
  TIA
  Sachin
   


-

[[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] Count Unique Rows/Values

2006-04-20 Thread Liaw, Andy
This might help:

 x - read.table(clipboard, colClasses=c(numeric, character))
 (x.unique - lapply(x, unique))
$V1
[1] 155 138 126 123 103 143 111 156

$V2
[1] A B C D

 sapply(x.unique, length)
V1 V2 
 8  4 

Andy

From: Sachin J
 
 Hi,

   I have a dataset which has both numeric and character 
 values with dupllicates. For example:

   155   A
 138   A
 138   B
 126   C
 126   D
 123   A
 103   A
 103   B
 143   D
 111   C
 111   D
 156   C

   How can I count the number of unqiue entries without 
 counting duplicate entries. Also can I extract the list in a 
 object. What I mean is
Col1 unique count = 8  Unique Elements are : 
 103,111,123,126,138,143,155,156
Col2 unique count = 4  Unique Elements are :  A,B,C,D.

   Any pointers would be of great help.

   TIA
   Sachin

 
   
 -
 
   [[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] Bootstrap error message: Error in statistic(data, origina l, ...) : unused argument(s) ( ...)

2006-04-20 Thread Liaw, Andy
 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Michael
 Sent: Thursday, April 20, 2006 3:50 AM
 To: R-help@stat.math.ethz.ch
 Subject: [R] Bootstrap error message: Error in 
 statistic(data, original, ...) : unused argument(s) ( ...) [Broadcast]
 
 
 Dear colleagues,
 
 I've been swamped and fighting with error for a few hours but 
 still desperately having absolutely no clue:

You really don't have to do that, but just RTFM instead.  ?boot says:

statistic   A function which when applied to data returns a vector 
containing the statistic(s) of interest. [...]
In all other cases statistic must take at least two 
arguments. The first argument passed will always be 
the original data. The second will be a vector of 
indices, frequencies or weights which define the 
bootstrap sample. [...]

Your myFun clearly does not fit that description.  boot() tried to call
myFun with a second argument, but myFun doesn't know what to do with a
second argument, and that's where you get the error.

Andy

 
 What's wrong with my bootstraping code?
 
 Thanks a lot!
 
 
 Error Message:
 
  bootResults=boot(X, myFun, R=1);
 Error in statistic(data, original, ...) : unused argument(s) ( ...)
 
 
 My code is:
 
 X=cbind(column_vector_1, column_vector_2);
 myFun=function(X)
 {
  return(mean(X[, 1])/var(X[, 2]));
 }
 
 bootResults=boot(X, myFun, R=1);
 
 -
 
   [[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] (Fwd) Re: Breakdown a number

2006-04-20 Thread Petr Pikal

--- Forwarded message follows ---
From:   Petr Pikal [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject:Re: [R] Breakdown a number
Date sent:  Thu, 20 Apr 2006 17:22:03 +0200

Hi

try this

fff-function(x,breaks=c(5,10)) {
if (sum(breaksx)==0)
result - c(x,rep(0,length(breaks)))
else
result - c(breaks[breaks=x],x-max(breaks[breaks=x]))
result
}

If you want trailing zeroes you need to add them.

HTH
Petr

Paul Roebuck wrote:

Isn't there a builtin method for doing this and, if so, what is it
called? 

breakdown - function(whole) {
breaks - c(250, 800)
pieces - integer(length(breaks) + 1)
if (whole  breaks[2]) {
pieces[3] - whole - breaks[2]
whole - breaks[2]

}
if (whole  breaks[1]) {
pieces[2] - whole - breaks[1]
whole - breaks[1]

}
pieces[1] - whole

return(pieces)
}

breakdown(1200) # 250 550 400

--

SIGSIG -- signature too long (core dumped) 
--- End of forwarded message ---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] Mutually Orthogonal Latin Squares

2006-04-20 Thread Jinsong Zhao
Hi all,

The package crossdes could contruct a complete sets of mutually orthogonal 
latin squares.
The construction works for prime powers only.

I hope to know whether there is a way to construct a mutually orthogonal Lation 
square for 
10 or other numbers that could not be prime powers.

Thanks for any suggestions.

Best wishes,
Jinsong Zhao

__
R-help@stat.math.ethz.ch 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] Count Unique Rows/Values

2006-04-20 Thread Sachin J
Hi,
   
  This one is not working for me. It is listing all the rows instead of unique 
ones. My dataset has 30 odd rows and following is the resulting o/p
  
[[308313]]
[1] 126
  [[308314]]
[1] 126
  [[308315]]
[1] 126
  [[308316]]
[1] 126
  [[308317]]
[1] 126
  [[308318]]
[1] 126
  [[308319]]
[1] 126
  [[308320]]
[1] 126
  [[308321]]
[1] 126
   
  I used following set of commands.
   
   (x.unique - lapply(x$V1, unique))
 sapply(x.unique, length)
   
  x$V1 is numeric field.
  where x is my data frame already read (therefore i ignored your first step). 
Am I missing something. ?
   
  Thanks
  Sachin

Liaw, Andy [EMAIL PROTECTED] wrote:
  This might help:

 x - read.table(clipboard, colClasses=c(numeric, character))
 (x.unique - lapply(x, unique))
$V1
[1] 155 138 126 123 103 143 111 156

$V2
[1] A B C D

 sapply(x.unique, length)
V1 V2 
8 4 

Andy

From: Sachin J
 
 Hi,
 
 I have a dataset which has both numeric and character 
 values with dupllicates. For example:
 
 155 A
 138 A
 138 B
 126 C
 126 D
 123 A
 103 A
 103 B
 143 D
 111 C
 111 D
 156 C
 
 How can I count the number of unqiue entries without 
 counting duplicate entries. Also can I extract the list in a 
 object. What I mean is
 Col1 unique count = 8 Unique Elements are : 
 103,111,123,126,138,143,155,156
 Col2 unique count = 4 Unique Elements are : A,B,C,D.
 
 Any pointers would be of great help.
 
 TIA
 Sachin
 
 
 
 -
 
 [[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
 
 


--

--



-

[[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] Count Unique Rows/Values

2006-04-20 Thread Liaw, Andy
From:Sachin J
 
 Hi,

   This one is not working for me. It is listing all the rows 
 instead of unique ones. My dataset has 30 odd rows and 
 following is the resulting o/p
   
 [[308313]]
 [1] 126
   [[308314]]
 [1] 126
   [[308315]]
 [1] 126
   [[308316]]
 [1] 126
   [[308317]]
 [1] 126
   [[308318]]
 [1] 126
   [[308319]]
 [1] 126
   [[308320]]
 [1] 126
   [[308321]]
 [1] 126

   I used following set of commands.

(x.unique - lapply(x$V1, unique))

You want x instead of x$V1 as the first argument to lapply(), so that it
runs unique() on all columns of x.

Andy


  sapply(x.unique, length)

   x$V1 is numeric field.
   where x is my data frame already read (therefore i ignored 
 your first step). Am I missing something. ?

   Thanks
   Sachin
 
 Liaw, Andy [EMAIL PROTECTED] wrote:
   This might help:
 
  x - read.table(clipboard, colClasses=c(numeric, character)) 
  (x.unique - lapply(x, unique))
 $V1
 [1] 155 138 126 123 103 143 111 156
 
 $V2
 [1] A B C D
 
  sapply(x.unique, length)
 V1 V2 
 8 4 
 
 Andy
 
 From: Sachin J
  
  Hi,
  
  I have a dataset which has both numeric and character
  values with dupllicates. For example:
  
  155 A
  138 A
  138 B
  126 C
  126 D
  123 A
  103 A
  103 B
  143 D
  111 C
  111 D
  156 C
  
  How can I count the number of unqiue entries without
  counting duplicate entries. Also can I extract the list in a 
  object. What I mean is
  Col1 unique count = 8 Unique Elements are : 
  103,111,123,126,138,143,155,156
  Col2 unique count = 4 Unique Elements are : A,B,C,D.
  
  Any pointers would be of great help.
  
  TIA
  Sachin
  
  
  
  -
  
  [[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
  
  
 
 
 --
 
 
 --
 
 
 
   
 -
 
   [[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] Count Unique Rows/Values

2006-04-20 Thread Sachin J
Thanks Andy. That works.
   
  Sachin

Liaw, Andy [EMAIL PROTECTED] wrote:
  From:Sachin J
 
 Hi,
 
 This one is not working for me. It is listing all the rows 
 instead of unique ones. My dataset has 30 odd rows and 
 following is the resulting o/p
 
 [[308313]]
 [1] 126
 [[308314]]
 [1] 126
 [[308315]]
 [1] 126
 [[308316]]
 [1] 126
 [[308317]]
 [1] 126
 [[308318]]
 [1] 126
 [[308319]]
 [1] 126
 [[308320]]
 [1] 126
 [[308321]]
 [1] 126
 
 I used following set of commands.
 
  (x.unique - lapply(x$V1, unique))

You want x instead of x$V1 as the first argument to lapply(), so that it
runs unique() on all columns of x.

Andy


  sapply(x.unique, length)
 
 x$V1 is numeric field.
 where x is my data frame already read (therefore i ignored 
 your first step). Am I missing something. ?
 
 Thanks
 Sachin
 
 Liaw, Andy wrote:
 This might help:
 
  x - read.table(clipboard, colClasses=c(numeric, character)) 
  (x.unique - lapply(x, unique))
 $V1
 [1] 155 138 126 123 103 143 111 156
 
 $V2
 [1] A B C D
 
  sapply(x.unique, length)
 V1 V2 
 8 4 
 
 Andy
 
 From: Sachin J
  
  Hi,
  
  I have a dataset which has both numeric and character
  values with dupllicates. For example:
  
  155 A
  138 A
  138 B
  126 C
  126 D
  123 A
  103 A
  103 B
  143 D
  111 C
  111 D
  156 C
  
  How can I count the number of unqiue entries without
  counting duplicate entries. Also can I extract the list in a 
  object. What I mean is
  Col1 unique count = 8 Unique Elements are : 
  103,111,123,126,138,143,155,156
  Col2 unique count = 4 Unique Elements are : A,B,C,D.
  
  Any pointers would be of great help.
  
  TIA
  Sachin
  
  
  
  -
  
  [[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
  
  
 
 
 --
 
 
 --
 
 
 
 
 -
 
 [[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
 
 


--

--



-

[[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] Count Unique Rows/Values

2006-04-20 Thread Sachin J
But it is not giving me the list of unique elements. Count works fine.
   
  Sachin

Liaw, Andy [EMAIL PROTECTED] wrote:
  From:Sachin J
 
 Hi,
 
 This one is not working for me. It is listing all the rows 
 instead of unique ones. My dataset has 30 odd rows and 
 following is the resulting o/p
 
 [[308313]]
 [1] 126
 [[308314]]
 [1] 126
 [[308315]]
 [1] 126
 [[308316]]
 [1] 126
 [[308317]]
 [1] 126
 [[308318]]
 [1] 126
 [[308319]]
 [1] 126
 [[308320]]
 [1] 126
 [[308321]]
 [1] 126
 
 I used following set of commands.
 
  (x.unique - lapply(x$V1, unique))

You want x instead of x$V1 as the first argument to lapply(), so that it
runs unique() on all columns of x.

Andy


  sapply(x.unique, length)
 
 x$V1 is numeric field.
 where x is my data frame already read (therefore i ignored 
 your first step). Am I missing something. ?
 
 Thanks
 Sachin
 
 Liaw, Andy wrote:
 This might help:
 
  x - read.table(clipboard, colClasses=c(numeric, character)) 
  (x.unique - lapply(x, unique))
 $V1
 [1] 155 138 126 123 103 143 111 156
 
 $V2
 [1] A B C D
 
  sapply(x.unique, length)
 V1 V2 
 8 4 
 
 Andy
 
 From: Sachin J
  
  Hi,
  
  I have a dataset which has both numeric and character
  values with dupllicates. For example:
  
  155 A
  138 A
  138 B
  126 C
  126 D
  123 A
  103 A
  103 B
  143 D
  111 C
  111 D
  156 C
  
  How can I count the number of unqiue entries without
  counting duplicate entries. Also can I extract the list in a 
  object. What I mean is
  Col1 unique count = 8 Unique Elements are : 
  103,111,123,126,138,143,155,156
  Col2 unique count = 4 Unique Elements are : A,B,C,D.
  
  Any pointers would be of great help.
  
  TIA
  Sachin
  
  
  
  -
  
  [[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
  
  
 
 
 --
 
 
 --
 
 
 
 
 -
 
 [[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
 
 


--

--



-

[[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] Bootstrap error message: Error in statistic(data, origina l, ...) : unused argument(s) ( ...)

2006-04-20 Thread Michael
btw, if you change myFun to any R internal function, such as cov, or
corr, it can run successfully...

On 4/20/06, Michael [EMAIL PROTECTED] wrote:

 Andy,

 I've noticed there should be a weight or frequency somewhere... but my
 function does not need it.

 I have tried to cheat it by declareing a weight, but not using it:

  myFun=function(X, w)

  {
   return(mean(X[, 1])/var(X[, 2]));
  }
 
  bootResults=boot(X, myFun, R=1, stype='w');

 The result is zero:

 Bootstrap Statistics :
 original  biasstd. error
 t1* 2.305412   0   0


 On 4/20/06, Liaw, Andy [EMAIL PROTECTED] wrote:
 
   -Original Message-
   From: [EMAIL PROTECTED]
   [mailto:[EMAIL PROTECTED] ] On Behalf Of Michael
   Sent: Thursday, April 20, 2006 3:50 AM
   To: R-help@stat.math.ethz.ch
   Subject: [R] Bootstrap error message: Error in
   statistic(data, original, ...) : unused argument(s) ( ...) [Broadcast]
 
  
  
   Dear colleagues,
  
   I've been swamped and fighting with error for a few hours but
   still desperately having absolutely no clue:
 
  You really don't have to do that, but just RTFM instead.  ?boot says:
 
  statistic   A function which when applied to data returns a vector
  containing the statistic(s) of interest. [...]
  In all other cases statistic must take at least two
  arguments. The first argument passed will always be
  the original data. The second will be a vector of
  indices, frequencies or weights which define the
  bootstrap sample. [...]
 
  Your myFun clearly does not fit that description.  boot() tried to
  call
  myFun with a second argument, but myFun doesn't know what to do with
  a
  second argument, and that's where you get the error.
 
  Andy
 
 
   What's wrong with my bootstraping code?
  
   Thanks a lot!
  
   
   Error Message:
  
bootResults=boot(X, myFun, R=1);
   Error in statistic(data, original, ...) : unused argument(s) ( ...)
  
   
   My code is:
  
   X=cbind(column_vector_1, column_vector_2);
   myFun=function(X)
   {
return(mean(X[, 1])/var(X[, 2]));
   }
  
   bootResults=boot(X, myFun, R=1);
  
   -
  
 [[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
  
  
 
 
 
  --
  Notice:  This e-mail message, together with any attachments, contains
  information of Merck  Co., Inc. (One Merck Drive, Whitehouse Station, New
  Jersey, USA 08889), and/or its affiliates (which may be known outside the
  United States as Merck Frosst, Merck Sharp  Dohme or MSD and in Japan, as
  Banyu) that may be confidential, proprietary copyrighted and/or legally
  privileged. It is intended solely for the use of the individual or entity
  named on this message.  If you are not the intended recipient, and have
  received this message in error, please notify us immediately by reply e-mail
  and then delete it from your system.
 
  --
 



[[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] there is no xls reader in R?

2006-04-20 Thread Gabor Grothendieck
Just one other thought.   There is a command line program
called xlHtml that you can find via google that will convert xls files to csv
and its used like this assuming you have placed it
somewhere in your path:

 read.csv(pipe(xlHtml -te -xc:1-10 -csv myfile.xls))

Its handy since its just a single file and in the situation that there is junk
on the first few lines of the spreadsheet you could use the skip= argument
to read.csv to skip over that.   I don't think the RODBC approach can
handle that.


On 4/20/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
 See:

 http://finzi.psych.upenn.edu/R/doc/manual/R-data.html#Reading-Excel-spreadsheets

 Also the RDCOMClient package (find it via google) and rcom (on CRAN)
 can control Excel from R and can be used.

 On 4/19/06, Michael [EMAIL PROTECTED] wrote:
  Currently I have to convert all my xls into csv before I can read it in
  and process the excel data in R...
 
  Is there a way to directly read in xls data?
 
  Thanks a lot!
 
 [[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] nlminb( ) : one compartment open PK model

2006-04-20 Thread Greg Tarpinian
All,

I have been able to successfully use the optim( ) function with
L-BFGS-B to find reasonable parameters for a one-compartment
open pharmacokinetic model.  My loss function in this case was
squared error, and I made no assumptions about the distribution
of the plasma values.  The model appeared to fit pretty well.

Out of curiosity, I decided to try to use nlminb( ) applied to
a likelihood function that assumes the plasma values are normally
distributed on the semilog scale (ie, modeling log(conc) over
time).  nlminb( ) keeps telling me that it has converged, but 
the estimated parameters are always identical to the initial
values  I am certain that I have committed ein dummheit
somewhere in the following code, but not sure what...  Any help
would be greatly appreciated.

Kind regards,

Greg



model2 - function(parms, dose, time, log.conc)
{
exp1 - exp(-parms[1]*time)
exp2 - exp(-parms[2]*time)
right.hand - log(exp1 - exp2)
numerator - dose*parms[1]*parms[2]
denominator - parms[3]*(parms[2] - parms[1])
left.hand - log(numerator/(denominator))
pred - left.hand + right.hand

# defining the distribution of the values
const - 1/(sqrt(2*pi)*parms[4])
exponent - (-1/(2*(parms[4]^2)))*(log.conc - pred)^2
likelihood - const*exp(exponent)

#defining the merit function
-sum(log(likelihood))
}

deriv2
- deriv( expr = ~   -log(1/(sqrt(2*pi)*S)*exp((-1/(2*(S^2)))*
  (log.conc-(log(dose*Ke*Ka/(Cl*(Ka-Ke)))
  +log(exp(-Ke*time)-exp(-Ka*time^2)),
  namevec = c(Ke,Ka,Cl,S),
  function.arg = function(Ke, Ka, Cl, S, dose, time, log.conc) NULL )

gradient2.1compart - function(parms, dose, time, log.conc)
{
Ke - parms[1]; Ka - parms[2]; Cl - parms[3]; S - parms[4]
colSums(attr(deriv2.1compart(Ke, Ka, Cl, S, dose, time, log.conc), gradient))
}

attach(foo.frame)
inits - c(Ke = .5,
   Ka = .5, 
   Cl = 1,
   S = 1)

#Trying out the code
nlminb(start = inits, 
   objective = model2,
   gradient = gradient2,
   control = list(eval.max = 5000, iter.max = 5000),
   lower = rep(0,4),
   dose = DOSE,
   time = TIME,
   log.conc = log(RESPONSE))

__
R-help@stat.math.ethz.ch 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] Bootstrap error message: Error in statistic(data, origina l, ...) : unused argument(s) ( ...) [Broadcast]

2006-04-20 Thread Liaw, Andy
I quoted the relevant part of the documentation for you.  Have you actually
try to read what it says?
 
Sure, you don't get any error, but have you checked whether any
bootstrapping was actually done?  Most of those functions are generics, thus
having the ... argument that can take anything.  Doesn't mean they will be
used.  See if the following helps:
 
 x - 1:10
 myMean - function(x, idx) mean(x[idx])
 library(boot)
 x.boot - boot(x, mean, R=10)
 str(x.boot)
List of 11
 $ t0   : num 5.5
 $ t: num [1:10, 1] 5.5 5.5 5.5 5.5 5.5 5.5 5.5 5.5 5.5 5.5
 $ R: num 10
 $ data : int [1:10] 1 2 3 4 5 6 7 8 9 10
 $ seed : int [1:626] 403 101 106329237 1120199471 -647917002 -657447328
355480739 291889089 -398656592 -2023350578 ...
 $ statistic:function (x, ...)  
 $ sim  : chr ordinary
 $ call : language boot(data = x, statistic = mean, R = 10)
 $ stype: chr i
 $ strata   : num [1:10] 1 1 1 1 1 1 1 1 1 1
 $ weights  : num [1:10] 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1
 - attr(*, class)= chr boot
 x.boot2 - boot(x, myMean, R=10)
 str(x.boot2)
List of 11
 $ t0   : num 5.5
 $ t: num [1:10, 1] 5.7 6.4 5.4 4.9 7.2 4.6 4.4 5.4 5.7 5.9
 $ R: num 10
 $ data : int [1:10] 1 2 3 4 5 6 7 8 9 10
 $ seed : int [1:626] 403 201 106329237 1120199471 -647917002 -657447328
355480739 291889089 -398656592 -2023350578 ...
 $ statistic:function (x, idx)  
  ..- attr(*, source)= chr function(x, idx) mean(x[idx])
 $ sim  : chr ordinary
 $ call : language boot(data = x, statistic = myMean, R = 10)
 $ stype: chr i
 $ strata   : num [1:10] 1 1 1 1 1 1 1 1 1 1
 $ weights  : num [1:10] 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1
 - attr(*, class)= chr boot
 
Andy

-Original Message-
From: Michael [mailto:[EMAIL PROTECTED] 
Sent: Thursday, April 20, 2006 12:19 PM
To: Liaw, Andy
Cc: R-help@stat.math.ethz.ch
Subject: Re: [R] Bootstrap error message: Error in statistic(data, origina
l, ...) : unused argument(s) ( ...) [Broadcast]


btw, if you change myFun to any R internal function, such as cov, or
corr, it can run successfully...


On 4/20/06, Michael [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 
wrote: 

Andy,

I've noticed there should be a weight or frequency somewhere... but my
function does not need it.

I have tried to cheat it by declareing a weight, but not using it:

 myFun=function(X, w) 

 {
  return(mean(X[, 1])/var(X[, 2]));
 }


 bootResults=boot(X, myFun, R=1, stype='w'); 

The result is zero:

Bootstrap Statistics :
original  biasstd. error 
t1* 2.305412   0   0



On 4/20/06, Liaw, Andy  [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 
wrote: 

 -Original Message-
 From: [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] 
 [mailto: [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] ] On Behalf Of Michael
 Sent: Thursday, April 20, 2006 3:50 AM
 To: R-help@stat.math.ethz.ch  mailto:R-help@stat.math.ethz.ch 
 Subject: [R] Bootstrap error message: Error in
 statistic(data, original, ...) : unused argument(s) ( ...) [Broadcast] 


 Dear colleagues,

 I've been swamped and fighting with error for a few hours but
 still desperately having absolutely no clue:

You really don't have to do that, but just RTFM instead.  ?boot says: 

statistic   A function which when applied to data returns a vector
containing the statistic(s) of interest. [...]
In all other cases statistic must take at least two
arguments. The first argument passed will always be 
the original data. The second will be a vector of
indices, frequencies or weights which define the
bootstrap sample. [...]

Your myFun clearly does not fit that description.  boot() tried to call 
myFun with a second argument, but myFun doesn't know what to do with a
second argument, and that's where you get the error.

Andy


 What's wrong with my bootstraping code? 

 Thanks a lot!

 
 Error Message:

  bootResults=boot(X, myFun, R=1);
 Error in statistic(data, original, ...) : unused argument(s) ( ...) 

 
 My code is:

 X=cbind(column_vector_1, column_vector_2);
 myFun=function(X)
 {
  return(mean(X[, 1])/var(X[, 2]));
 }
 
 bootResults=boot(X, myFun, R=1);

 -

   [[alternative HTML version deleted]]

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





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

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

[R] smooth the ecdf plots

2006-04-20 Thread Linda Lei
Hi All,

 

I have codes as follows to get the ecdf plots:

 

 
day.hos2-c(6,4,6,6,4,6,5,4,7,5,6,6,8,6,17,9,8,4,6,3,5,8,7,12,5,10,6,4,6
,13,7,6,6,25,4,9,96,6,6,6,6,9,4,5,5,4,10,5,7,6)

 

 
day.hos3-c(5,6,7,6,4,5,6,6,6,6,19,7,5,9,8,8,7,5,6,20,40,5,8,7,7,5,6,13,
11,9,4,6,9,16,6,7,6)

 

  f-ecdf(day.hos2)

 

  plot(f,col.p='red',col.h='red')

 

  g-ecdf(day.hos3)

 

 lines(g,lty=2)

 

But in order to compare the two ecdf plots. I want to smooth the ecdf
plot, make it like a continuous distribution curve. Could you please

help me with it? I try to find some arguments in plot but not
successful.

 

Thank you!


[[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] smooth the ecdf plots

2006-04-20 Thread Berton Gunter
Better idea: Compare directly. ?qqplot

-- Bert Gunter
Genentech Non-Clinical Statistics
South San Francisco, CA
 
The business of the statistician is to catalyze the scientific learning
process.  - George E. P. Box
 
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Linda Lei
 Sent: Thursday, April 20, 2006 10:08 AM
 To: r-help@stat.math.ethz.ch
 Subject: [R] smooth the ecdf plots
 
 Hi All,
 
  
 
 I have codes as follows to get the ecdf plots:
 
  
 
  
 day.hos2-c(6,4,6,6,4,6,5,4,7,5,6,6,8,6,17,9,8,4,6,3,5,8,7,12,
 5,10,6,4,6
 ,13,7,6,6,25,4,9,96,6,6,6,6,9,4,5,5,4,10,5,7,6)
 
  
 
  
 day.hos3-c(5,6,7,6,4,5,6,6,6,6,19,7,5,9,8,8,7,5,6,20,40,5,8,7
 ,7,5,6,13,
 11,9,4,6,9,16,6,7,6)
 
  
 
   f-ecdf(day.hos2)
 
  
 
   plot(f,col.p='red',col.h='red')
 
  
 
   g-ecdf(day.hos3)
 
  
 
  lines(g,lty=2)
 
  
 
 But in order to compare the two ecdf plots. I want to smooth the ecdf
 plot, make it like a continuous distribution curve. Could you please
 
 help me with it? I try to find some arguments in plot but not
 successful.
 
  
 
 Thank you!
 
 
   [[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] there is no xls reader in R?

2006-04-20 Thread Dirk Eddelbuettel
On Thu, Apr 20, 2006 at 12:29:58PM -0400, Gabor Grothendieck wrote:
 Just one other thought.   There is a command line program
 called xlHtml that you can find via google that will convert xls files to csv
 and its used like this assuming you have placed it
 somewhere in your path:
 
  read.csv(pipe(xlHtml -te -xc:1-10 -csv myfile.xls))
 
 Its handy since its just a single file and in the situation that there is junk
 on the first few lines of the spreadsheet you could use the skip= argument
 to read.csv to skip over that.   I don't think the RODBC approach can
 handle that.

An equivalent approach has long been available in Greg Warnes gregmisc
bundle via the gdata package.  It uses Perl's SpreadSheet::ParseExcel --
which it even embeds in the R package -- to parse xls, and creates a csv
which is then read. 

Cross-platform, which RODBC's approach isn't, and available directly via
install.packages().

Hth, Dirk

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

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


[R] Missing p-values using lmer()

2006-04-20 Thread Amelie LESCROEL
Hello,

 

I’m trying to perform a REML analysis using the lmer() function (lme4
package). Well, it seems to work well, except that I’m not getting any
p-value (see example below). Can someone tell me what I did wrong?

 

Thanks for your help,

 

Amélie

 

 library(gdata)

 dive - read.xls(C:/Documents and Settings/Amelie/My Documents/Postdoc/CE
2005-2006/divebydive.xls, perl=C:/perl/bin/perl.exe)

 library(lme4)

Loading required package: Matrix

Loading required package: lattice

 reml.res - lmer(UNDS~SUCCESSMN+(1|BIRD), dive)

 summary(reml.res)

Linear mixed-effects model fit by REML 

Formula: UNDS ~ SUCCESSMN + (1 | BIRD) 

  Data: dive 

  AIC BIClogLik MLdeviance REMLdeviance

 60032.37 60053.8 -30013.1960031.9 60026.37

Random effects:

 Groups   NameVariance Std.Dev.

 BIRD (Intercept)  4.4504  2.1096  

 Residual 36.4240  6.0352  

number of obs: 9324, groups: BIRD, 12

 

Fixed effects:

Estimate Std. Error t value

(Intercept) 13.397640.63887 20.9707

SUCCESSMN4.221974.11527  1.0259

 

Correlation of Fixed Effects:

  (Intr)

SUCCESSMN -0.276

 anova(reml.res)

Analysis of Variance Table

  Df Sum Sq Mean Sq

SUCCESSMN  1 38.337  38.337


[[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] [Q] Bayeisan Network with the deal package

2006-04-20 Thread Spencer Graves
  Thanks for providing such a simple, complete example.  I've never 
used deal before, but a few minutes with your example led me to 
something that might help you:

  First, the documentation for localprior says, x: an object of 
class 'node' or 'network'.  That information led me to checking 
'class(ksl)' and 'class(ksl$node[1])':  The first is class 'network', 
while the second is of class 'list'.

  However, class(ksl$node[[1]]) is of class 'node'.  Bingo:

  localprior(ksl.nw$nodes[[1]])
[[1]]
[[1]]$alpha
[1] NA

[[1]]$nu
[1] 64

[[1]]$rho
[1] 64

[[1]]$mu
[1] 179.289

[[1]]$phi
  [,1]
[1,] 113442.3

[[1]]$tau
[1] 64

  hope this helps.
  spencer graves

Young-Jin Lee wrote:

 Dear R-users
 
 I am looking for a help in using the deal package.
 I followed the manual and paper from the author's web site to learn it, as
 shown below, but I could not figure out how to access the local and
 posterior probability of the nodes in the constructed network.
 
 library(deal)
 data(ksl)
 ksl.nw - network(ksl)
 ksl.prior - jointprior(ksl.nw)
 banlist - matrix(c(5,5,6,6,7,7,9,
8,9,8,9,8,9,8), ncol = 2)
 ksl.nw$banlist - banlist
 ksl.nw - learn(ksl.nw, ksl, ksl.prior)$nw
 
 According to the manual, the local prior and posterior can be accessed for
 each node using localprior()
 and localposterior(). However, I got null from localprior(ksl.nw$nodes[1])
 and localposterior(ksl.nw$nodes[1]).
 Can anyone tell me what I should do to access the local prior and posterior?
 
 Any help would be appreciated.
 Thanks in advance.
 
 Young-Jin
 
   [[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] Missing p-values using lmer()

2006-04-20 Thread Doran, Harold
You didn't do anything wrong, lmer doesn't give them. And, for good reason. 
I've been a bit indoctrinated by D. Bates, so let me share what I've learned.

With simple analysis of variance models with simple error structures, it is 
known that the ratio of the variances follow and F distribution. However, with 
more complex error structures, the null distribution is unknown. Most other 
multilevel programs accept by analogy that the ratio of the variances do follow 
an F distribution. That is, it works well for the simple case, therefore it 
probably is also true for the more complex case.

In SAS, one can choose ddf options, such as Kenward-Roger, which hopes that 
after assuming the ratio of variances follow an F distribution, the only 
remaining challenge is to properly estimate the denominator degrees of freedom. 
These kinds of options do not currently exist in lmer and after many 
discussions on this list Doug Bates decided to remove the p-values for now.

This topic has been discussed often on this list and you can see other 
discussions on the archive which may be more insightful. 

Harold


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Amelie LESCROEL
Sent: Thursday, April 20, 2006 1:41 PM
To: r-help@stat.math.ethz.ch
Subject: [R] Missing p-values using lmer()

Hello,

 

I'm trying to perform a REML analysis using the lmer() function (lme4 package). 
Well, it seems to work well, except that I'm not getting any p-value (see 
example below). Can someone tell me what I did wrong?

 

Thanks for your help,

 

Amélie

 

 library(gdata)

 dive - read.xls(C:/Documents and Settings/Amelie/My 
 Documents/Postdoc/CE
2005-2006/divebydive.xls, perl=C:/perl/bin/perl.exe)

 library(lme4)

Loading required package: Matrix

Loading required package: lattice

 reml.res - lmer(UNDS~SUCCESSMN+(1|BIRD), dive)

 summary(reml.res)

Linear mixed-effects model fit by REML 

Formula: UNDS ~ SUCCESSMN + (1 | BIRD) 

  Data: dive 

  AIC BIClogLik MLdeviance REMLdeviance

 60032.37 60053.8 -30013.1960031.9 60026.37

Random effects:

 Groups   NameVariance Std.Dev.

 BIRD (Intercept)  4.4504  2.1096  

 Residual 36.4240  6.0352  

number of obs: 9324, groups: BIRD, 12

 

Fixed effects:

Estimate Std. Error t value

(Intercept) 13.397640.63887 20.9707

SUCCESSMN4.221974.11527  1.0259

 

Correlation of Fixed Effects:

  (Intr)

SUCCESSMN -0.276

 anova(reml.res)

Analysis of Variance Table

  Df Sum Sq Mean Sq

SUCCESSMN  1 38.337  38.337


[[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] 3D pie

2006-04-20 Thread Michael A. Miller
 COMTE == COMTE Guillaume [EMAIL PROTECTED] writes:

 I know it isn't the best way to represent data, but people
 are sometimes more interested by the look and feel than by
 the accuracy of the results...

If they aren't intersted in the results, why not just print some
random 3D pie chart and use that?  Why do you need to produce a
new one at all?

__
R-help@stat.math.ethz.ch 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] Missing p-values using lmer()

2006-04-20 Thread Spencer Graves
Hi, Harold:

  Am I correct that the tool currently preferred for estimating 
p-values for lmer is mcmcsamp?

Amélie:  My favorite tool for exploring the archives is 'RSiteSearch'. 
You can also get to it via www.r-project.org, but the last time I tried 
to copy a web address to paste in an email, the address I got from 
'RSiteSearch' worked but the one I got from the web page directly did not.

  hope this helps,
  spencer graves

Doran, Harold wrote:

 You didn't do anything wrong, lmer doesn't give them. 
And, for good reason. I've been a bit indoctrinated by
D. Bates, so let me share what I've learned.
 
 With simple analysis of variance models with simple 
error structures, it is known that the ratio of the
variances follow and F distribution. However, with more
complex error structures, the null distribution is
unknown. Most other multilevel programs accept by
analogy that the ratio of the variances do follow an F
distribution. That is, it works well for the simple
case, therefore it probably is also true for the more
complex case.
 
 In SAS, one can choose ddf options, such as Kenward-
Roger, which hopes that after assuming the ratio of
variances follow an F distribution, the only remaining
challenge is to properly estimate the denominator
degrees of freedom. These kinds of options do not
currently exist in lmer and after many discussions on
this list Doug Bates decided to remove the p-values for
now.
 
 This topic has been discussed often on this list and 
you can see other discussions on the archive which may
be more insightful.
 
 Harold
 
 
 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Amelie LESCROEL
 Sent: Thursday, April 20, 2006 1:41 PM
 To: r-help@stat.math.ethz.ch
 Subject: [R] Missing p-values using lmer()
 
 Hello,
 
  
 
 I'm trying to perform a REML analysis using the lmer() function (lme4 
 package). Well, it seems to work well, except that I'm not getting any 
 p-value (see example below). Can someone tell me what I did wrong?
 
  
 
 Thanks for your help,
 
  
 
 Amélie
 
  
 
 
library(gdata)
 
 
dive - read.xls(C:/Documents and Settings/Amelie/My 
Documents/Postdoc/CE
 
 2005-2006/divebydive.xls, perl=C:/perl/bin/perl.exe)
 
 
library(lme4)
 
 
 Loading required package: Matrix
 
 Loading required package: lattice
 
 
reml.res - lmer(UNDS~SUCCESSMN+(1|BIRD), dive)
 
 
summary(reml.res)
 
 
 Linear mixed-effects model fit by REML 
 
 Formula: UNDS ~ SUCCESSMN + (1 | BIRD) 
 
   Data: dive 
 
   AIC BIClogLik MLdeviance REMLdeviance
 
  60032.37 60053.8 -30013.1960031.9 60026.37
 
 Random effects:
 
  Groups   NameVariance Std.Dev.
 
  BIRD (Intercept)  4.4504  2.1096  
 
  Residual 36.4240  6.0352  
 
 number of obs: 9324, groups: BIRD, 12
 
  
 
 Fixed effects:
 
 Estimate Std. Error t value
 
 (Intercept) 13.397640.63887 20.9707
 
 SUCCESSMN4.221974.11527  1.0259
 
  
 
 Correlation of Fixed Effects:
 
   (Intr)
 
 SUCCESSMN -0.276
 
 
anova(reml.res)
 
 
 Analysis of Variance Table
 
   Df Sum Sq Mean Sq
 
 SUCCESSMN  1 38.337  38.337
 
 
   [[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] smooth the ecdf plots

2006-04-20 Thread Frank E Harrell Jr
Linda Lei wrote:
 Hi All,
 
  
 
 I have codes as follows to get the ecdf plots:
 
  
 
  
 day.hos2-c(6,4,6,6,4,6,5,4,7,5,6,6,8,6,17,9,8,4,6,3,5,8,7,12,5,10,6,4,6
 ,13,7,6,6,25,4,9,96,6,6,6,6,9,4,5,5,4,10,5,7,6)
 
  
 
  
 day.hos3-c(5,6,7,6,4,5,6,6,6,6,19,7,5,9,8,8,7,5,6,20,40,5,8,7,7,5,6,13,
 11,9,4,6,9,16,6,7,6)
 
  
 
   f-ecdf(day.hos2)
 
  
 
   plot(f,col.p='red',col.h='red')
 
  
 
   g-ecdf(day.hos3)
 
  
 
 
lines(g,lty=2)
 
 
  
 
 But in order to compare the two ecdf plots. I want to smooth the ecdf
 plot, make it like a continuous distribution curve. Could you please
 
 help me with it? I try to find some arguments in plot but not
 successful.
 
  
 
 Thank you!

Think about keeping them ECDFs and not distorting them.  And you can 
superimpose two of them using thin blank lines for one and thicker gray 
scale lines for the other and be able to see them clearly.  Use e.g.

library(Hmisc)
?ecdf  (look at groups argument)

Someday I may rename ecdf in Hmisc to avoid confusion with the builtin 
ecdf function.

Frank

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


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


Re: [R] Missing p-values using lmer()

2006-04-20 Thread Doran, Harold
Yes, you're exactly right. You can use the mcmcsamp() function to sample from 
the posterior of an lmer object. This returns an object of mcmc class and you 
can do all of your diagnostics using the coda package.

-Original Message-
From: Spencer Graves [mailto:[EMAIL PROTECTED] 
Sent: Thursday, April 20, 2006 2:23 PM
To: Doran, Harold
Cc: Amelie LESCROEL; r-help@stat.math.ethz.ch
Subject: Re: [R] Missing p-values using lmer()

Hi, Harold:

  Am I correct that the tool currently preferred for estimating 
p-values for lmer is mcmcsamp?

Amélie:  My favorite tool for exploring the archives is 'RSiteSearch'. 
You can also get to it via www.r-project.org, but the last time I tried to copy 
a web address to paste in an email, the address I got from 'RSiteSearch' worked 
but the one I got from the web page directly did not.

  hope this helps,
  spencer graves

Doran, Harold wrote:

 You didn't do anything wrong, lmer doesn't give them. 
And, for good reason. I've been a bit indoctrinated by D. Bates, so let me 
share what I've learned.
 
 With simple analysis of variance models with simple
error structures, it is known that the ratio of the variances follow and F 
distribution. However, with more complex error structures, the null 
distribution is unknown. Most other multilevel programs accept by analogy that 
the ratio of the variances do follow an F distribution. That is, it works well 
for the simple case, therefore it probably is also true for the more complex 
case.
 
 In SAS, one can choose ddf options, such as Kenward-
Roger, which hopes that after assuming the ratio of variances follow an F 
distribution, the only remaining challenge is to properly estimate the 
denominator degrees of freedom. These kinds of options do not currently exist 
in lmer and after many discussions on this list Doug Bates decided to remove 
the p-values for now.
 
 This topic has been discussed often on this list and
you can see other discussions on the archive which may be more insightful.
 
 Harold
 
 
 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Amelie LESCROEL
 Sent: Thursday, April 20, 2006 1:41 PM
 To: r-help@stat.math.ethz.ch
 Subject: [R] Missing p-values using lmer()
 
 Hello,
 
  
 
 I'm trying to perform a REML analysis using the lmer() function (lme4 
 package). Well, it seems to work well, except that I'm not getting any 
 p-value (see example below). Can someone tell me what I did wrong?
 
  
 
 Thanks for your help,
 
  
 
 Amélie
 
  
 
 
library(gdata)
 
 
dive - read.xls(C:/Documents and Settings/Amelie/My 
Documents/Postdoc/CE
 
 2005-2006/divebydive.xls, perl=C:/perl/bin/perl.exe)
 
 
library(lme4)
 
 
 Loading required package: Matrix
 
 Loading required package: lattice
 
 
reml.res - lmer(UNDS~SUCCESSMN+(1|BIRD), dive)
 
 
summary(reml.res)
 
 
 Linear mixed-effects model fit by REML
 
 Formula: UNDS ~ SUCCESSMN + (1 | BIRD)
 
   Data: dive
 
   AIC BIClogLik MLdeviance REMLdeviance
 
  60032.37 60053.8 -30013.1960031.9 60026.37
 
 Random effects:
 
  Groups   NameVariance Std.Dev.
 
  BIRD (Intercept)  4.4504  2.1096  
 
  Residual 36.4240  6.0352  
 
 number of obs: 9324, groups: BIRD, 12
 
  
 
 Fixed effects:
 
 Estimate Std. Error t value
 
 (Intercept) 13.397640.63887 20.9707
 
 SUCCESSMN4.221974.11527  1.0259
 
  
 
 Correlation of Fixed Effects:
 
   (Intr)
 
 SUCCESSMN -0.276
 
 
anova(reml.res)
 
 
 Analysis of Variance Table
 
   Df Sum Sq Mean Sq
 
 SUCCESSMN  1 38.337  38.337
 
 
   [[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] Conditional Row Sum

2006-04-20 Thread Sachin J
Hi,
   
  How can I accomplish this in R. Example:
   
  R1  R2
  3 101
  4 102
  3 102
  18102
  11101
   
  I want to find Sum(101) =  14 - i.e SUM(R1) where R2 = 101
  Sum(102) = 25- SUM(R2) where R2 = 102
   
  TIA
  Sachin


-

[[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] Conditional Row Sum

2006-04-20 Thread Gabor Grothendieck
Using the built in data.frame iris sum each of the first 4 columns for
each value of the 5th column.

rowsum(iris[,-5], iris[,5])


On 4/20/06, Sachin J [EMAIL PROTECTED] wrote:
 Hi,

  How can I accomplish this in R. Example:

  R1  R2
  3 101
  4 102
  3 102
  18102
  11101

  I want to find Sum(101) =  14 - i.e SUM(R1) where R2 = 101
  Sum(102) = 25- SUM(R2) where R2 = 102

  TIA
  Sachin


 -

[[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] Conditional Row Sum

2006-04-20 Thread Marc Schwartz (via MN)
On Thu, 2006-04-20 at 11:46 -0700, Sachin J wrote:
 Hi,

   How can I accomplish this in R. Example:

   R1  R2
   3 101
   4 102
   3 102
   18102
   11101

   I want to find Sum(101) =  14 - i.e SUM(R1) where R2 = 101
   Sum(102) = 25- SUM(R2) where R2 = 102

   TIA
   Sachin

Presuming that your data is in a data frame called DF:

 DF
  R1  R2
1  3 101
2  4 102
3  3 102
4 18 102
5 11 101

At least three options:

 with(DF, tapply(R1, R2, sum))
101 102
 14  25


 aggregate(DF$R1, list(R2 = DF$R2), sum)
   R2  x
1 101 14
2 102 25


 by(DF$R1, DF$R2, sum)
INDICES: 101
[1] 14
--
INDICES: 102
[1] 25


See ?by, ?aggregate and ?tapply and ?with.

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


Re: [R] Conditional Row Sum

2006-04-20 Thread Sachin J
Thanx Marc and Gabor for your help.
   
  Sachin

Marc Schwartz (via MN) [EMAIL PROTECTED] wrote:
  On Thu, 2006-04-20 at 11:46 -0700, Sachin J wrote:
 Hi,
 
 How can I accomplish this in R. Example:
 
 R1 R2
 3 101
 4 102
 3 102
 18 102
 11 101
 
 I want to find Sum(101) = 14 - i.e SUM(R1) where R2 = 101
 Sum(102) = 25 - SUM(R2) where R2 = 102
 
 TIA
 Sachin

Presuming that your data is in a data frame called DF:

 DF
R1 R2
1 3 101
2 4 102
3 3 102
4 18 102
5 11 101

At least three options:

 with(DF, tapply(R1, R2, sum))
101 102
14 25


 aggregate(DF$R1, list(R2 = DF$R2), sum)
R2 x
1 101 14
2 102 25


 by(DF$R1, DF$R2, sum)
INDICES: 101
[1] 14
--
INDICES: 102
[1] 25


See ?by, ?aggregate and ?tapply and ?with.

HTH,

Marc Schwartz





-

[[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] Randomly selecting one row for each factor level [Broadca st]

2006-04-20 Thread Kelly Hildner
This worked for my example data frame but not when I used it on my 
actual data frame because some of the levels of x have only one element. 
  However, when I replace 'sample' with 'some' (from the car package), 
it works like a charm!

Many thanks to Andy and Gabor for their help!

Kelly

Liaw, Andy wrote:
 The following should work:
 
 
dfr.samp - dfr[tapply(1:nrow(dfr), dfr$x, sample, 1),]
dfr.samp
 
x  y z
 10 a 10 J
 2  b  2 B
 9  c  9 I
 
 Andy
 
 From: Kelly Hildner
 
I don't use R much, and I have been unable to figure out how 
to get the 
subset of my data frame that I would like.

For example, if this were my data frame:

  dfr - data.frame(x=rep(letters[1:3], 4), y=(1:12), 
z=(LETTERS[1:12]))   dfr
x  y z
1  a  1 A
2  b  2 B
3  c  3 C
4  a  4 D
5  b  5 E
6  c  6 F
7  a  7 G
8  b  8 H
9  c  9 I
10 a 10 J
11 b 11 K
12 c 12 L

I would like to randomly select one row for each level of the 
factor x 
and create a new data frame with the results.  For example, 
the result 
might be:

x  y z
1  a  1 A
5  b  5 E
6  c  6 F

Any help would be greatly appreciated!

Thanks,
Kelly

-- 
K. Kelly Hildner, Ph.D.
NOAA Fisheries
Southwest Fisheries Science Center
110 Shaffer Rd.
Santa Cruz, CA 95060

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


 
 
 
 --
 Notice:  This e-mail message, together with any attachment...{{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] PCA biplot question

2006-04-20 Thread Cashorali, Tanya
Hi everyone,
I'd like to project two pcas onto one device window.  
 
I plot my first PCA:
biplot(prcomp(t(cerebdevmat)), var.axes=FALSE, cex=c(1,.1),
pc.biplot=TRUE)
 
Now I'd like to project the features of another PCA onto this graph.
 
Any suggestions?
 
I know this is easily done in MatLab but haven't figured it out in R.
 
Thanks,
Tanya

[[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 to approximate complex integral

2006-04-20 Thread Douglas Bates
On 4/19/06, Doran, Harold [EMAIL PROTECTED] wrote:

 I am writing a small function to approximate an integral that cannot be
 evaluated in closed form. I am partially successful at this point and am
 experiencing one small, albeit important problem. Here is part of my
 function below.

 This is a psychometric problem for dichotomously scored test items where
 x is a vector of 1s or 0s denoting whether the respondent answered the
 item correctly (1) or otherwise (0), b is a vector of item difficulties,
 and theta is an ability estimate for the individual.

 rasch - function(b,theta){
1 / ( 1 + exp(b - theta))
}

 The function rasch gives the probability of a correct response to item i
 conditional on theta, the individuals ability estimate

 myfun - function(x, b, theta){
sum(rasch(b, theta)^x * ( 1 - rasch(b,theta) )^(1-x) * dnorm(theta))
}

 This is the likelihood function assuming the data are Bernoulli
 distributed multiplied by a population distribution.

 Now, when x,b, and theta are of equal length the function works fine as
 below
 x - c(1,1,0)
 b -   c(-2,-1,0)
 t -   c(-2,-1.5,-1)
  myfun(x,b,t)
 [1] 0.2527884

 However, I want theta to be a vector of discrete values that will be
 larger than both x and b, something like

 t - seq(-5, 0, by = .01)

 However, this gives me the error
  myfun(x,b,t)

  Warning messages:
 1: longer object length
 is not a multiple of shorter object length in: b - theta

 So, for the problem above, I want item 1 to be evaluated at theta 1
 through theta q and then item 2 is evaluated at theta 1 and through
 theta q and so forth for each item.

 Can anyone recommend a way for me to modify my function above to
 accomplish this?

I believe (partially based on our off-list discussions of this model)
that you want to use the function outer, as in

rasch - function(b, theta) 1/(1 - exp(outer(theta, b, -)))

If length(theta) == m and length(b) == n then this returns the m by n
matrix of probabilities of subject i correctly answering question j.

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