Re: [R] Simulate phi-coefficient (correlation between dichotomous vars)

2005-09-27 Thread Bliese, Paul D LTC USAMH
Newsgroup members, 

I appreciate the help on this topic.

David Duffy provided a solution (below) that was quite helpful, and came
close to what I needed.  It did a great job creating two vectors of
dichotomous variables with a known correlation (what I referred to as a
phi-coefficient).

My situation is a bit more complicated and I'm not sure it is easily
solved.  The problem is that I must assume one of the vectors is
constant and generate one or more vectors that covary with the constant
vector.

In a continuous example I could use the following code that I got from
the S-PLUS newsgroup year ago:

sample.cor-function (x, rho) 
{
y - (rho * (x - mean(x)))/sqrt(var(x)) + sqrt(1 - rho^2) * 
rnorm(length(x))
cat(Sample corr = , cor(x, y), \n)
return(y)
}

X-rnorm(100)  #a constant vector
Y1-sample.cor(X,.30) # a new vector that correlates with X .30
Y2-sample.cor(X,.45) # a second vector that correlates with X .45

I can, of course, have X be a vector of zeros and ones, and I can
dichotomize Y1 and Y2, but the program always returns a phi-coefficient
correlation lower than the continuous correlation.  Mathematically, I
guess this is expected because the phi-coefficient is partially a
function of the percentage of positive responses.  This, in turn,
explains Pearson's (1900) interest in the whole area of tetrachoric
correlations -- a tetrachoric correlation being the Pearson product
moment correlation that would have been observed had two dichotomously
scored variables been measured on a continuous scale (Pearson, 1900).

Appreciate any additional input or possible solutions.

Paul



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of David Duffy
Sent: Monday, September 12, 2005 1:34 AM
To: r-help@stat.math.ethz.ch
Subject: [R] Simulate phi-coefficient

 From: Bliese, Paul D LTC USAMH [EMAIL PROTECTED]

 Given a sample of zeros and ones, for example:
  VECTOR1-rep(c(1,0),c(15,10))
 How would I create a new sample (VECTOR2) also containing zeros and
 ones, in which the phi-coefficient between the two sample vectors was
 drawn from a population with a known phi-coefficient value?

 I know there are ways to do this with normally distributed numbers
(for
 example the mvrnorm function in MASS), but am stumped when dealing
with
 dichotomous variables.

 Paul

One way is to sample from the 2x2 table with the specified means and
pearson
correlation (phi):

for a fourfold table, a b
  c d
with marginal proportions p1 and p2
cov - phi * sqrt(p1*(1-p1)*p2*(1-p2))
a - p1*p2 + cov
b - p1*(1-p2) - cov
c - (1-p1)*p2 - cov
d - (1-p1)*(1-p2) + cov
expand.grid(0:1,0:1)[sample(1:4, size=25, replace=TRUE,
prob=c(a,b,c,d)),]

David.

| David Duffy (MBBS PhD) ,-_|\
| email: [EMAIL PROTECTED]  ph: INT+61+7+3362-0217 fax: -0101  / *
| Epidemiology Unit, Queensland Institute of Medical Research   \_,-._/
| 300 Herston Rd, Brisbane, Queensland 4029, Australia  GPG 4D0B994A v

__
R-help@stat.math.ethz.ch 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] Make check fails on d-p-q-r-tests.R...

2005-09-27 Thread Prof Brian Ripley
You will have to show us the error!   It will be shown in 
d-p-q-r-tests.Rout.fail (unless this was a segfault or similar).

It is not OK to skip the test, but note that this test is random and does 
fail about 1 in 50 times, so you could just try rerunning it.

On Mon, 26 Sep 2005, Jeff Ross wrote:

 Hi,

 R-2.1.1
 OS:  OpenBSD-current (3.8) on i386
 Compiler:gcc version 3.3.5 (propolice)
 Thread model: single

 configure \
  --with-readline \
  --with-tcltk \
  --with-tcl-config=/usr/local/lib/tcl8.4/tclConfig.sh \
  --with-tk-config=/usr/local/lib/tk8.4/tkConfig.sh \
  --with-libpng \
  --with-jpeglib \
  --with-zlib \
  --with-bzlib \
  --with-pcre \
  --with-libiconv-prefix=/usr/local/

Please do NOT use unrecommended flags like --with-zlib, especially not on 
your first build.  None of those flags should have been needed.


 I'm brand new to R so I don't know how critical this error is.

 Here's the last bit what make check FORCE=FORCE outputs:

 running code in 'grDevices-Ex.R' ... OK
 comparing 'grDevices-Ex.Rout' to 'grDevices-Ex.Rout.prev' ... OK
 running code in 'graphics-Ex.R' ... OK
 comparing 'graphics-Ex.Rout' to 'graphics-Ex.Rout.prev' ... OK
 running code in 'stats-Ex.R' ... OK
 comparing 'stats-Ex.Rout' to 'stats-Ex.Rout.prev' ... OK
 running code in 'datasets-Ex.R' ... OK
 comparing 'datasets-Ex.Rout' to 'datasets-Ex.Rout.prev' ... OK
 running code in 'methods-Ex.R' ... OK
 comparing 'methods-Ex.Rout' to 'methods-Ex.Rout.prev' ... OK
 running code in 'grid-Ex.R' ... OK
 comparing 'grid-Ex.Rout' to 'grid-Ex.Rout.prev' ... OK
 running code in 'splines-Ex.R' ... OK
 comparing 'splines-Ex.Rout' to 'splines-Ex.Rout.prev' ... OK
 running code in 'stats4-Ex.R' ... OK
 comparing 'stats4-Ex.Rout' to 'stats4-Ex.Rout.prev' ... OK
 running code in 'tcltk-Ex.R' ... OK
 comparing 'tcltk-Ex.Rout' to 'tcltk-Ex.Rout.prev' ... OK
 updating test dependencies
 `Makedeps' is up to date.
 running strict specific tests
 running code in 'eval-etc.R' ... OK
 comparing 'eval-etc.Rout' to './eval-etc.Rout.save' ... OK
 running code in 'simple-true.R' ... OK
 comparing 'simple-true.Rout' to './simple-true.Rout.save' ... OK
 running code in 'arith-true.R' ... OK
 comparing 'arith-true.Rout' to './arith-true.Rout.save' ... OK
 running code in 'arith.R' ... OK
 comparing 'arith.Rout' to './arith.Rout.save' ... OK
 running code in 'lm-tests.R' ... OK
 comparing 'lm-tests.Rout' to './lm-tests.Rout.save' ... OK
 running code in 'primitive-funs.R' ... OK
 comparing 'primitive-funs.Rout' to './primitive-funs.Rout.save' ... OK
 running code in 'ok-errors.R' ... OK
 comparing 'ok-errors.Rout' to './ok-errors.Rout.save' ... OK
 running code in 'method-dispatch.R' ... OK
 comparing 'method-dispatch.Rout' to './method-dispatch.Rout.save' ... OK
 running code in 'd-p-q-r-tests.R' ...*** Error code 1
 Stop in /usr/local/src/R-2.1.1/tests.
 *** Error code 1

 Stop in /usr/local/src/R-2.1.1/tests (line 206 of Makefile).
 *** Error code 1

 Stop in /usr/local/src/R-2.1.1/tests (line 191 of Makefile).


 Tried finding this error in the archives to no avail.  If it is okay to
 ignore this error, how can I skip this test?

 Thanks for any input!

 Jeff Ross

 __
 R-help@stat.math.ethz.ch 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] create trend variable in a regression using R

2005-09-27 Thread Vito Ricci
Dear Giacomo,

what you mean precisely saying to create a Trend
variable in a regression? If it concerns about time
series analysis you could give a look to my
contribute:

http://cran.r-project.org/doc/contrib/Ricci-ts-italian.pdf

Best Regards

Vito 


Hi,
my name is Giacomo. 
I would like to know how to create a Trend variable in
a regression using R.
Thank you for your help.
My best regards,   
Giacomo


Diventare costruttori di soluzioni
Became solutions' constructors

The business of the statistician is to catalyze 
the scientific learning process.  
George E. P. Box

Statistical thinking will one day be as necessary for efficient citizenship as 
the ability to read and write
H. G. Wells

Top 10 reasons to become a Statistician

 1. Deviation is considered normal
 2. We feel complete and sufficient
 3. We are 'mean' lovers
 4. Statisticians do it discretely and continuously
 5. We are right 95% of the time
 6. We can legally comment on someone's posterior distribution
 7. We may not be normal, but we are transformable
 8. We never have to say we are certain
 9. We are honestly significantly different
10. No one wants our jobs


Visitate il portale http://www.modugno.it/
e in particolare la sezione su Palese  
http://www.modugno.it/archivio/palesesanto_spirito/

__
R-help@stat.math.ethz.ch 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] calculating distances using Gower's coefficient on mixed variables.

2005-09-27 Thread Martin Maechler
 nikonia == nikonia  [EMAIL PROTECTED]
 on Mon, 26 Sep 2005 12:15:55 +0200 writes:

nikonia I want to compute the distances in a mixed variable
nikonia matrix using the Gower coefficient. I understand it
nikonia is possible to calculate distances in a matrix with
nikonia mixed variables using the dudi.pco command. How
nikonia would this work?

No need for esoteric functions.  The recommended(*) package
'cluster' has  daisy() for computing dissimilarities.
One of its major features has always been the ability to work with
mixed variables (continuous, nominal, ordinal, .. (a)symmetric binary,...)
implementing a slight generalization of Gower's proposal.

Even though the help for daisy starts its 'Details' section with

  'daisy' is fully described in chapter 1 of Kaufman and Rousseeuw (1990).

I think I should add some more details to the help page when I
get time..

Martin Maechler, ETH Zurich

(*) recommended packages are always available by library(pkg) 
in a normal R installation.

__
R-help@stat.math.ethz.ch 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] hist(x, ...) with normal distribution curve

2005-09-27 Thread Peter Wolf
Knut Krueger wrote:
.
I am looking for a histogram or box plot with the adding  normal 
distribution  curve
I think that must be possible, but I am not able to find out how to do.



Regards Knut

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
  
*There are a lot of answers to add a histogram.
Here is a simple way to add a tiny boxplot to a plot / histogram

x-rexp(100)
hist(x)
boxplot(x,axes=F,add=T,horizontal=T,
 at=par()$usr[3]+diff(par()$usr[3:4])*.017,
 boxwex=0.02*diff(par()$usr[3:4]),pch=8)

Peter Wolf


*

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

2005-09-27 Thread Peter Wolf
concerning question 1:  -- labeling of outliers --

you can get the outliers by boxplot(...)$out

try:

set.seed(17)
x-rexp(99)
names(x)-paste(x,1:99)
out-boxplot(x)$out
text(rep(1.1,length(out)), out, names(out))

Peter Wolf

Stephen D. Weigand wrote:
Dear Yulei,

On Sep 26, 2005, at 6:56 PM, Yulei He wrote:

  
Hi, there.

I have two questions about using R to create boxplots.

1. The function boxplot() plots the outliers. How can I label the exact
values arount these outlier points? Does R have an option allow me to
do that?


You can use identify(). Here's a toy example

set.seed(1)
y - rt(30, 3)
boxplot(y)
identify(x = rep(1,30), y = y, label = format(y, digits = 2))
### now click on the outlier in the plot and you should see -7.398
### beside the outlier

  
2. How can I put two boxplots in one x-y axis?


x - rnorm(10)
y - rnorm(20, 3, 5)
z - runif(30)

boxplot(x, y, z, labels = c(x, y, z))
### - or -
boxplot(list(x = x, y = y, z = z))


  
Thanks.

Yulei



Stephen Weigand
Rochester, Minnesota, USA

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


__
R-help@stat.math.ethz.ch 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] hist(x, ...) with normal distribution curve

2005-09-27 Thread Romain Francois
Le 27.09.2005 10:32, Peter Wolf a écrit :

Knut Krueger wrote:
  

I am looking for a histogram or box plot with the adding  normal 
distribution  curve
I think that must be possible, but I am not able to find out how to do.

Regards Knut
 


*There are a lot of answers to add a histogram.
Here is a simple way to add a tiny boxplot to a plot / histogram

x-rexp(100)
hist(x)
boxplot(x,axes=F,add=T,horizontal=T,
 at=par()$usr[3]+diff(par()$usr[3:4])*.017,
 boxwex=0.02*diff(par()$usr[3:4]),pch=8)

Peter Wolf

  

The tufte axes, described there : 
http://www.cl.cam.ac.uk/users/sjm217/projects/graphics/
may be of interrest here.

What about making it a possibility for all plots ? For example using :
R par(xaxt='tufte')
R plot(rnorm(200), rnorm(200))
would produce a scatterplot with the tufte axes

Romain.

-- 
visit the R Graph Gallery : http://addictedtor.free.fr/graphiques
 ~ 
~~  Romain FRANCOIS - http://addictedtor.free.fr ~~
Etudiant  ISUP - CS3 - Industrie et Services   
~~http://www.isup.cicrp.jussieu.fr/  ~~
   Stagiaire INRIA Futurs - Equipe SELECT  
~~   http://www.inria.fr/recherche/equipes/select.fr.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] Wrong signature

2005-09-27 Thread Knut Krueger
I've got a comlaint about the signature in the last post.
I answered form another computer and there is the automatic signature of 
our second business.
On this place is also a part  of the equine resarch program in progress.
I did not realize that there was the siganture below.
Sorry for that.

Regards Knut

__
R-help@stat.math.ethz.ch 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] regression methods for circular(?) data.

2005-09-27 Thread Ted Harding
I retract the siggestion I proposed last night -- it was based
on a bad hunch! Sorry for wasting time.

Best wishes,
Ted.


E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 27-Sep-05   Time: 09:59:29
-- 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


[R] About Coda Package

2005-09-27 Thread Juan Pablo Sanchez Serrano
Dear R users:
I am using the package coda (the last verison in CRAN) to analyse the output 
from a  MCMC Bayesian analysis. And I get unconsitented results. I have export 
the chain using the read.table function and after I have transformed this data 
frame to an mcmc object using the mcmc function. I am interested in three 
variables, when I use the function effectiveSize I have these figures:  
403.37301854.4534 369.8643. But when I run the function codamenu to 
perform same convergence test I get this warning mensage:

Checking effective sample size ...
***
WARNING !!!  
Some variables in your chain have an 
effective sample size of less than 200   
This is too small, and may cause errors  
in the diagnostic tests  
HINT:
Look at plots first to identify variables
with slow mixing.  (Choose menu Output   
Analysis then Plots) 
Re-run your chain with a larger sample   
size and thinning interval. If possible, 
reparameterize your model to improve mixing
***
Some thing is wrong. Could someone explain to me what is happening?
Thanks, 
Juan Pablo.

===
Juan Pablo Sánchez Serrano
Dep. Ciencia Animal, UPV.
C/ Camino de Vera s/n 46022
Valencia (Spain)
Telf. 963877007 Ext.74382

__
R-help@stat.math.ethz.ch 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] plotting multiple plots on a single graph

2005-09-27 Thread Petr Pikal
Hi

***PLEASE do read the posting guide!***

see
?par
?points
?lines
?split.screen
?layout
?matplot
?lattice


HTH
Petr




On 26 Sep 2005 at 18:08, C Tate wrote:

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

Petr Pikal
[EMAIL PROTECTED]

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


Re: [R] About Coda Package

2005-09-27 Thread Martyn Plummer
Dear Juan Pablo,

It is best to send package-specific queries the package maintainer (me
in this case) which you can find out by typeing library(help=coda)

The inconsistency comes from two different ways of estimating the
spectral density at frequency 0: spectrum0() adapted from Heidelberger 
Welch, fits a generalized linear model to the periodogram. This function
is called by the effectiveSize() function.  Unfortunately it crashes
when there is very high autocorrelation.  The alternative function
spectrum0.ar does the same thing by fitting an autoregressive model to
the data, and won't crash even on highly autocorrelated data. The latter
function is called by codamenu().

The two functions are giving different results here, but to be honest,
an effective sample size of 370 isn't sufficient for serious inference
from an MCMC sample either.   I can only reiterate the advice given by
the warning message.

Martyn

On Tue, 2005-09-27 at 11:11 +0200, Juan Pablo Sanchez Serrano wrote:
 Dear R users:
 I am using the package coda (the last verison in CRAN) to analyse the
 output from a  MCMC Bayesian analysis. And I get unconsitented
 results. I have export the chain using the read.table function and
 after I have transformed this data frame to an mcmc object using the
 mcmc function. I am interested in three variables, when I use the
 function effectiveSize I have these figures:  403.37301854.4534
 369.8643. But when I run the function codamenu to perform same
 convergence test I get this warning mensage:
 
 Checking effective sample size ...
 ***
 WARNING !!!  
 Some variables in your chain have an 
 effective sample size of less than 200   
 This is too small, and may cause errors  
 in the diagnostic tests  
 HINT:
 Look at plots first to identify variables
 with slow mixing.  (Choose menu Output   
 Analysis then Plots) 
 Re-run your chain with a larger sample   
 size and thinning interval. If possible, 
 reparameterize your model to improve mixing
 ***
 Some thing is wrong. Could someone explain to me what is happening?
 Thanks, 
 Juan Pablo.

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

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


Re: [R] dates are shown as X15.Feb.03

2005-09-27 Thread roger bos
This is a good example of where you did not give us enough information to
answer your question. as.Date has a lot of formatting options for working
with dates. If you are still having problems, please provide a short example
(i.e. reproducable code).
 Thanks,
 Roger

 On 9/26/05, Chris Buddenhagen [EMAIL PROTECTED] wrote:

 Why is R recognizing dates like this?



 Chris Buddenhagen, Botany Department, Charles Darwin Research Station,
 Santa
 Cruz,Galapagos. Mail: Charles Darwin Foundation, Casilla 17-01-3891
 Avenida
 6 de Diciembre N36-109 y Pasaje California Quito, ECUADOR







 __
 EL CONTENIDO DE ESTE MENSAJE ES DE ABSOLUTA RESPONSABILIDAD DEL AUTOR.
 FUNDACION CHARLES DARWIN
 WWW.DARWINFOUNDATION.ORG http://WWW.DARWINFOUNDATION.ORG
 [[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] Producing empirical bayes estimates in disease mapping for lognormal model

2005-09-27 Thread Oarabile Molaodi
I'm trying to produce empirical bayes estimates based on the lognormal 
model  in disease mapping
Is there a way this can be done in R?

thanks
Oarabile

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

2005-09-27 Thread Samuel Bertrand
Hello,

I am using the 'regsubsets' function
(from leaps package)
to get the best linear models
to explain 1 variable
from 1 to 5 explanatory variables
(exhaustive search).

Is there anyone who can tell me
on which criterion is based
the 'regsubsets' function ?

Thank you.

samuel





Samuel BERTRAND
Doctorant
Laboratoire de Biomecanique
LBM - ENSAM - CNRS UMR 8005
http://bio-web.paris.ensam.fr
151, bd de l'Hopital
75013 PARIS
Tel. +33 (0) 1 44 24 64 53
Fax +33 (0) 1 44 24 63 66

[[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] regsubsets selection criterion

2005-09-27 Thread Ingmar Visser
 Is there anyone who can tell me
 on which criterion is based
 the 'regsubsets' function ?

the leaps help page says:

cp or adjr2 or r2 is the value of the chosen model selection statistic for
each model

so each of these can be chosen as the selection statistic using the method
argument

hth, ingmar

__
R-help@stat.math.ethz.ch 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] getting variable length numerical gradient

2005-09-27 Thread Antonio, Fabio Di Narzo
2005/9/26, Dimitris Rizopoulos [EMAIL PROTECTED]:
 AFAIK the deriv() is for symbolic derivatives, so I don't know if it
 will work in your case.

numericDeriv surely computes numerical gradient. The problem here is
its interface, which requires the vector of symbols involved in the
expression to differenziate.



 Best,
 Dimitris


 - Original Message -
 From: Antonio, Fabio Di Narzo [EMAIL PROTECTED]
 To: Dimitris Rizopoulos [EMAIL PROTECTED]
 Cc: R-help@stat.math.ethz.ch
 Sent: Monday, September 26, 2005 10:58 AM
 Subject: Re: getting variable length numerical gradient


 Tnx very much Dimitris,
 your code does what I need. I've just adapted it to my needs (e.g., I
 don't deal with scalar functions), and so solved my problem.

 Given this, is there a way to use the deriv function in the base
 package, within this context (variable length vector of indipendent
 variables)?

 Best,
 Antonio, Fabio Di Narzo.

 On 9/25/05, Dimitris Rizopoulos [EMAIL PROTECTED]
 wrote:
  maybe you can find the following function useful (any comments are
  greatly appreciated):
 
  fd - function(x, f, scalar = TRUE, ..., eps =
  sqrt(.Machine$double.neg.eps)){
  f - match.fun(f)
  out - if(scalar){
  if(length(f0 - f(x, ...)) != length(x))
  stop('f' must be vectorized)
  x. - x + eps * pmax(abs(x), 1)
  c(f(x., ...) - f0) / (x. - x)
  } else{
  n - length(x)
  res - array(0, c(n, n))
  f0 - f(x, ...)
  ex - pmax(abs(x), 1)
  for(i in 1:n){
  x. - x
  x.[i] - x[i] + eps * ex[i]
  res[, i] - c(f(x., ...) - f0) / (x.[i] - x[i])
  }
  res
  }
  out
  }
 
 
  ## Examples
 
  x - seq(-3.3, 3.3, 0.1)
  all.equal(fd(x, pnorm, mean = 0.5), dnorm(x, mean = 0.5))
 
 
  # Approximate the Hessian matrix for a logistic regression
 
  # the score vector function
  gn - function(b, y, X){
  p - as.vector(plogis(X %*% b))
  -colSums(X * (y - p))
  }
 
  # We simulate some data and fit the logistic regression
  n - 800
  x1 - runif(n,-3, 3); x2 - runif(n, -3, 3)
  pr - plogis(0.8 + 0.4 * x1 - 0.3 * x2)
  y - rbinom(n, 1, pr)
  fm - glm(y ~ x1 + x2, binomial)
 
  ## The Hessian using forward difference approximation
  fd(fm$coef, gn, scalar = FALSE, y = y, X = cbind(1, x1, x2))
 
  ## The true Hessian
  solve(summary(fm)$cov.unscaled)
 
 
  I hope it helps.
 
  Best,
  Dimitris
 
  
  Dimitris Rizopoulos
  Ph.D. Student
  Biostatistical Centre
  School of Public Health
  Catholic University of Leuven
 
  Address: Kapucijnenvoer 35, Leuven, Belgium
  Tel: +32/(0)16/336899
  Fax: +32/(0)16/337015
  Web: http://www.med.kuleuven.be/biostat/
   http://www.student.kuleuven.be/~m0390867/dimitris.htm
 
 
  - Original Message -
  From: Antonio, Fabio Di Narzo [EMAIL PROTECTED]
  To: R-help@stat.math.ethz.ch
  Sent: Sunday, September 25, 2005 11:37 AM
  Subject: [R] getting variable length numerical gradient
 
 
   Hi all.
   I have a numerical function f(x), with x being a vector of generic
   size (say k=4), and I wanna take the numerically computed
   gradient,
   using deriv or numericDeriv (or something else).
  
   My difficulties here are that in deriv and numericDeric the
   function
   is passed as an expression, and one have to pass the list of
   variables
   involved as a char vector... So, it's a pure R programming
   question.
  
  
   Have a nice sunday,
   Antonio, Fabio Di Narzo.
  
   __
   R-help@stat.math.ethz.ch mailing list
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide!
   http://www.R-project.org/posting-guide.html
  
 
 
  Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
 
 


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



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


[R] graphics guide?

2005-09-27 Thread Karin Lagesen

I am trying to create some graphs with R and it seems to be able to do
what I need. However, I have so far not been able to find any sort of
explanation of how the graphics system works. I am for instance trying
to create a multiple figure, and I seem to have to call plot.new()
before every new plot command, I have however not found any
explanation of what this actually does. ?plot.new does give an
explanation, but it is explained in R, so to speak. Where do I find
out what for instance a graphics frame is?

Thanks,

Karin
-- 
Karin Lagesen, PhD student
[EMAIL PROTECTED]
http://www.cmbn.no/rognes/

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

2005-09-27 Thread Ko-Kang Kevin Wang
Hi,

Karin Lagesen wrote:
 I am trying to create some graphs with R and it seems to be able to do
 what I need. However, I have so far not been able to find any sort of
 explanation of how the graphics system works. I am for instance trying
 to create a multiple figure, and I seem to have to call plot.new()
 before every new plot command, I have however not found any

Do you mean several graphs in the same window?

If so, you want something like, e.g.:
   par(mfrow = c(2, 2))

Take a look at ?par and the mfrow or mfcol options.

Cheers and HTH,

Kev

-- 
Ko-Kang Kevin Wang
PhD Student
Centre for Bioinformation Science
Building 27, Room 1004
Mathematical Sciences Institute (MSI)
Australian National University
Canberra, ACT 2601
Australia

Homepage: http://wwwmaths.anu.edu.au/~wangk/
Ph (W): +61-2-6125-2431
Ph (H): +61-2-6125-7488
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] graphics guide?

2005-09-27 Thread Peter Flom
 Karin Lagesen [EMAIL PROTECTED] 9/27/2005 9:27:29 AM


I am trying to create some graphs with R and it seems to be able to do
what I need. However, I have so far not been able to find any sort of
explanation of how the graphics system works. I am for instance trying
to create a multiple figure, and I seem to have to call plot.new()
before every new plot command, I have however not found any
explanation of what this actually does. ?plot.new does give an
explanation, but it is explained in R, so to speak. Where do I find
out what for instance a graphics frame is?

If you'd like a more comprehensive reference in book form, I recommend
Paul Murrell's book R Graphics.

HTH

Peter

Peter L. Flom, PhD
Assistant Director, Statistics and Data Analysis Core
Center for Drug Use and HIV Research
National Development and Research Institutes
71 W. 23rd St
http://cduhr.ndri.org
www.peterflom.com
New York, NY 10010
(212) 845-4485 (voice)
(917) 438-0894 (fax)

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


[R] multiple plots on same x axis

2005-09-27 Thread IAIN GALLAGHER
Hi.

I have two vectors of gene expression for each of
several days. I want to plot both vectors on the same
plot for a visual representation of up versus down
regulation. I've tried using add=T but that doesn't
work. 

eg

plot(Day, gene1)
plot(Day, gene2, add=T)

Any help would be appreciated.

Iain

__
R-help@stat.math.ethz.ch 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] Make check fails on d-p-q-r-tests.R...

2005-09-27 Thread Jeff Ross
On 1:03:39 am 09/27/05 Prof Brian Ripley [EMAIL PROTECTED] wrote:

 You will have to show us the error!   It will be shown in
 d-p-q-r-tests.Rout.fail (unless this was a segfault or similar).

 It is not OK to skip the test, but note that this test is random and
 does fail about 1 in 50 times, so you could just try rerunning it.

I am so sorry.  I didn't even think to look for a .fail file.

Here is the last bit of it:

 ## for PR#7902:
 ex - -c(rev(1/x), ex)
 All.eq(-x, qcauchy(pcauchy(-x)))
[1] TRUE
 All.eq(+x, qcauchy(pcauchy(+x, log=TRUE), log=TRUE))
[1] TRUE
 All.eq(1/x, pcauchy(qcauchy(1/x)))
[1] TRUE
 All.eq(ex,  pcauchy(qcauchy(ex, log=TRUE), log=TRUE))
[1] `is.NA' value mismatches: 1 in current, 0  in target
Warning message:
NaNs produced in: qcauchy(p, location, scale, lower.tail, log.p)
 II - c(-Inf,Inf)
 stopifnot(pcauchy(II) == 0:1, ## qcauchy(0:1) == II,
+   pcauchy(II, log=TRUE) == c(-Inf,0),
+   qcauchy(c(-Inf,0), log=TRUE) == II)
Error in if (!(is.logical(r - eval(ll[[i]]))  all(r)))
stop(paste(deparse(mc[[i +  :
  missing value where TRUE/FALSE needed
In addition: Warning message:
NaNs produced in: qcauchy(p, location, scale, lower.tail, log.p)
Execution halted

This is from the latest R-patched source tar ball, and it is the identical
error as R-2.1.1.  I've consistently gotten the same error, even with
configuration file tweaks and making clean between runs.

Thanks!

Jeff Ross

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

2005-09-27 Thread Richard Nixon
Hi
Just one of those niggles...

I've just been trying to plot a filled circle.
I thought that this would do it

plot(1,1,type=n)
points(1,1,pch=1,bg=blue,cex=5)
#bg: background (fill) color for open plot symbols

But I need to do this instead
points(1.2,1,pch=19,col=blue,cex=5)

Am I misunderstanding the bg option in the points function?

Richard

-- 
Dr. Richard Nixon, MRC Biostatistics Unit, Cambridge, UK
http://www.mrc-bsu.cam.ac.uk/personal/richard

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

2005-09-27 Thread Uwe Ligges
Richard Nixon wrote:

 Hi
 Just one of those niggles...
 
 I've just been trying to plot a filled circle.
 I thought that this would do it
 
 plot(1,1,type=n)
 points(1,1,pch=1,bg=blue,cex=5)
 #bg: background (fill) color for open plot symbols
 
 But I need to do this instead
 points(1.2,1,pch=19,col=blue,cex=5)
 
 Am I misunderstanding the bg option in the points function?
 
 Richard
 

Please read ?points and it's paragraph on te argument pch with quite 
some information regarding filled symbols...

Uwe Ligges

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

2005-09-27 Thread Peter Dalgaard
Richard Nixon [EMAIL PROTECTED] writes:

 Hi
 Just one of those niggles...
 
 I've just been trying to plot a filled circle.
 I thought that this would do it
 
 plot(1,1,type=n)
 points(1,1,pch=1,bg=blue,cex=5)
 #bg: background (fill) color for open plot symbols
 
 But I need to do this instead
 points(1.2,1,pch=19,col=blue,cex=5)
 
 Am I misunderstanding the bg option in the points function?

Sort of. The quick answer is: example(points). I think you'll get the
point.
 

-- 
   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] negative binomial in GEE

2005-09-27 Thread Simon.Bond
Dear R-help,


I was recently wanting to use GEE with the negative binomial family. It
seems that this is lacking in the otherwise excellent implementations of
the GEE methodology ( packages: gee, yags, geepack).

I would have thought it a simple step to allow the creation of a family,
i.e providing the link function (log mu) and the variance function (mu +
mu^2/theta) , assuming theta is specified; and then to let the gee code
do the business in a similar fashion to glm.

However the gee codes all seem to rely a set of C routines with either the
normal, poisson, or binomial, hardwired in.

Does anyone have any suggestions for a way round this problem for the
future (I had to resort to using Stata), or maybe more realistically, how
much work it would take to build an extendible version of the gee
algorithm?


thanks Simon Bond.

__
R-help@stat.math.ethz.ch 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] time series: smooth and aggregate?

2005-09-27 Thread jfontain
I am working on automatic optimization of ARIMA parameters.
That takes a lot of computing power, which I would like to reduce by aggregating
and smoothing.

Any thoughts on the subject?
Suggested algorithms?
What is the best order? aggregate then smooth or smooth then aggregate?

Many thanks in advance,

--
Jean-Luc

__
R-help@stat.math.ethz.ch 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] Error in make check-all

2005-09-27 Thread Fernando Mayer
Dear R-users,

i'm a very newbie in linux, but decided to build R from source. 
Following the R Installation and Administration manual, i did this:

./configure --enable-R-shlib # this option is here because i intend to 
build the GNOME console after...
make
make check

no problems in make check, but:

make check-devel #and also
make check-all

indicated some WARNINGs in the log file:

/usr/local/R-2.1.1/tests/tcltk.Rcheck/00check.Rcheck

Right below is the content of this log file (I translated some words):

[start log file]

* using log directory '/usr/local/R-2.1.1/tests/tcltk.Rcheck'
* using R version 2.1.1, 2005-06-20
* looks like 'tcltk' is a base package
* skipping installation test
* checking package directory ... OK
* checking for portable file names ... OK
* checking for sufficient/correct file permissions ... OK
* checking DESCRIPTION meta-information ... OK
* checking package dependencies ... OK
* checking index information ... OK
* checking package subdirectories ... OK
* checking S3 generic/method consistency ... WARNING
Erro: .First.lib failed for 'tcltk'
Call sequence:
2: stop(gettextf(.First.lib failed for '%s', libraryPkgName(package)),
   domain = NA)
1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose = 
FALSE)
Interrupted execution
See section 'Generic functions and methods' of the 'Writing R Extensions'
manual.
* checking replacement functions ... WARNING
Error: .First.lib failed for 'tcltk'
Call sequence:
2: stop(gettextf(.First.lib failed for '%s', libraryPkgName(package)),
   domain = NA)
1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose = 
FALSE)
Interrupted execution
In R, the argument of a replacement function which corresponds to the right
hand side must be named 'value'.
* checking foreign function calls ... WARNING
Error: .First.lib failed for 'tcltk'
Call sequence:
2: stop(gettextf(.First.lib failed for '%s', libraryPkgName(package)),
   domain = NA)
1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose = 
FALSE)
Interrupted execution
See section 'System and foreign language interfaces' of the 'Writing R
Extensions' manual.
* checking Rd files ... OK
* checking for missing documentation entries ... WARNING
Error: .First.lib failed for 'tcltk'
Call sequence:
2: stop(gettextf(.First.lib failed for '%s', libraryPkgName(package)),
   domain = NA)
1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose = 
FALSE)
Interrupted execution
All user-level objects in a package should have documentation entries.
See chapter 'Writing R documentation files' in manual 'Writing R
Extensions'.
* checking for code/documentation mismatches ... WARNING
Error: .First.lib failed for 'tcltk'
Call sequence:
2: stop(gettextf(.First.lib failed for '%s', libraryPkgName(package)),
   domain = NA)
1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose = 
FALSE)
Interrupted execution
Error: .First.lib failed for 'tcltk'
Call sequence:
2: stop(gettextf(.First.lib failed for '%s', libraryPkgName(package)),
   domain = NA)
1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose = 
FALSE)
Interrupted execution
Error: .First.lib failed for 'tcltk'
Call sequence:
2: stop(gettextf(.First.lib failed for '%s', libraryPkgName(package)),
   domain = NA)
1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose = 
FALSE)
Interrupted execution
* checking Rd \usage sections ... OK
* checking DVI version of manual ... OK

[end log file]

The problem is in the tcltk package. I have searched in the archives, 
but didin't find anything similar to this problem (maybe there is, but i 
was not able to identify it). I really don't know what all the warnings 
means. What i need to know is what am i missing, and if there is 
something i can fix it. Also, are there any problems if i continue the 
installation without fix something?

P.S.: actually R is running already from where it was buit, but i want 
to install it. So i want to avoid future problems, if this warnings 
really make some.

Any help is appreciated. Thanks!

Fernando Mayer.

version
 _
platform i686-pc-linux-gnu
arch i686
os   linux-gnu [SuSE 9.3]
system   i686, linux-gnu
status
major2
minor1.1
year 2005
month06
day  20
language R


[[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] Error in make check-all

2005-09-27 Thread Prof Brian Ripley
This is what happens if you don't have a usable X11 display.  Did you 
perhaps use a root account on a console owned by a normal user?

On Tue, 27 Sep 2005, Fernando Mayer wrote:

 Dear R-users,

 i'm a very newbie in linux, but decided to build R from source.
 Following the R Installation and Administration manual, i did this:

 ./configure --enable-R-shlib # this option is here because i intend to
 build the GNOME console after...
 make
 make check

 no problems in make check, but:

 make check-devel #and also
 make check-all

 indicated some WARNINGs in the log file:

 /usr/local/R-2.1.1/tests/tcltk.Rcheck/00check.Rcheck

 Right below is the content of this log file (I translated some words):

 [start log file]

 * using log directory '/usr/local/R-2.1.1/tests/tcltk.Rcheck'
 * using R version 2.1.1, 2005-06-20
 * looks like 'tcltk' is a base package
 * skipping installation test
 * checking package directory ... OK
 * checking for portable file names ... OK
 * checking for sufficient/correct file permissions ... OK
 * checking DESCRIPTION meta-information ... OK
 * checking package dependencies ... OK
 * checking index information ... OK
 * checking package subdirectories ... OK
 * checking S3 generic/method consistency ... WARNING
 Erro: .First.lib failed for 'tcltk'
 Call sequence:
 2: stop(gettextf(.First.lib failed for '%s', libraryPkgName(package)),
   domain = NA)
 1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose =
 FALSE)
 Interrupted execution
 See section 'Generic functions and methods' of the 'Writing R Extensions'
 manual.
 * checking replacement functions ... WARNING
 Error: .First.lib failed for 'tcltk'
 Call sequence:
 2: stop(gettextf(.First.lib failed for '%s', libraryPkgName(package)),
   domain = NA)
 1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose =
 FALSE)
 Interrupted execution
 In R, the argument of a replacement function which corresponds to the right
 hand side must be named 'value'.
 * checking foreign function calls ... WARNING
 Error: .First.lib failed for 'tcltk'
 Call sequence:
 2: stop(gettextf(.First.lib failed for '%s', libraryPkgName(package)),
   domain = NA)
 1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose =
 FALSE)
 Interrupted execution
 See section 'System and foreign language interfaces' of the 'Writing R
 Extensions' manual.
 * checking Rd files ... OK
 * checking for missing documentation entries ... WARNING
 Error: .First.lib failed for 'tcltk'
 Call sequence:
 2: stop(gettextf(.First.lib failed for '%s', libraryPkgName(package)),
   domain = NA)
 1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose =
 FALSE)
 Interrupted execution
 All user-level objects in a package should have documentation entries.
 See chapter 'Writing R documentation files' in manual 'Writing R
 Extensions'.
 * checking for code/documentation mismatches ... WARNING
 Error: .First.lib failed for 'tcltk'
 Call sequence:
 2: stop(gettextf(.First.lib failed for '%s', libraryPkgName(package)),
   domain = NA)
 1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose =
 FALSE)
 Interrupted execution
 Error: .First.lib failed for 'tcltk'
 Call sequence:
 2: stop(gettextf(.First.lib failed for '%s', libraryPkgName(package)),
   domain = NA)
 1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose =
 FALSE)
 Interrupted execution
 Error: .First.lib failed for 'tcltk'
 Call sequence:
 2: stop(gettextf(.First.lib failed for '%s', libraryPkgName(package)),
   domain = NA)
 1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose =
 FALSE)
 Interrupted execution
 * checking Rd \usage sections ... OK
 * checking DVI version of manual ... OK

 [end log file]

 The problem is in the tcltk package. I have searched in the archives,
 but didin't find anything similar to this problem (maybe there is, but i
 was not able to identify it). I really don't know what all the warnings
 means. What i need to know is what am i missing, and if there is
 something i can fix it. Also, are there any problems if i continue the
 installation without fix something?

 P.S.: actually R is running already from where it was buit, but i want
 to install it. So i want to avoid future problems, if this warnings
 really make some.

 Any help is appreciated. Thanks!

 Fernando Mayer.

 version
 _
 platform i686-pc-linux-gnu
 arch i686
 os   linux-gnu [SuSE 9.3]
 system   i686, linux-gnu
 status
 major2
 minor1.1
 year 2005
 month06
 day  20
 language R


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

Re: [R] Error in make check-all

2005-09-27 Thread Peter Dalgaard
Fernando Mayer [EMAIL PROTECTED] writes:

 Dear R-users,
..
 Erro: .First.lib failed for 'tcltk'
...
 The problem is in the tcltk package. I have searched in the archives, 
 but didin't find anything similar to this problem (maybe there is, but i 
 was not able to identify it). I really don't know what all the warnings 
 means. What i need to know is what am i missing, and if there is 
 something i can fix it. Also, are there any problems if i continue the 
 installation without fix something?

Well, tcl/tk isn't working...
 
 P.S.: actually R is running already from where it was buit, but i want 
 to install it. So i want to avoid future problems, if this warnings 
 really make some.
 
 Any help is appreciated. Thanks!
 
 Fernando Mayer.
 
 version
  _
 platform i686-pc-linux-gnu
 arch i686
 os   linux-gnu [SuSE 9.3]

Installing the tk-devel and tcl-devel packages should help.

 system   i686, linux-gnu
 status
 major2
 minor1.1
 year 2005
 month06
 day  20
 language R
 
 
   [[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
 

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

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


Re: [R] quick points question

2005-09-27 Thread Prof Brian Ripley
On Tue, 27 Sep 2005, Richard Nixon wrote:

 Hi
 Just one of those niggles...

 I've just been trying to plot a filled circle.
 I thought that this would do it

 plot(1,1,type=n)
 points(1,1,pch=1,bg=blue,cex=5)
 #bg: background (fill) color for open plot symbols

 But I need to do this instead
 points(1.2,1,pch=19,col=blue,cex=5)

 Am I misunderstanding the bg option in the points function?

Yes. See the examples.   pch=1 is not an `open plot symbol': 21-25 are.
So in your case

points(1.3, 1, pch=21, col=blue, bg=red, cex=5)

may be illuminating.

-- 
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] make check in ~/fem outputs only 1 test, huh ?

2005-09-27 Thread Courtney Thomas
fem-4.0.1 [and all the other modules, except post] compiles OK, AFAIK,
but when I do a 

make check 

only 1 test is reported, as follows:


making checksrc
making checkview3d
making checkviewaxis
making checktests

make check-TESTS
$ELMER_HOME undefined, setting it to ../src
CC: no input files specified
test: unexpected operator
Tests completed, passed: 0 out of total 0 tests 
PASS: runtests
===
All 1 tests passed
===
 

As I understand it, about 50 tests should have been run. What's wrong
and how do I fix it, please ?

Gratefully,
Courtney

__
R-help@stat.math.ethz.ch 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] Error in make check-all

2005-09-27 Thread Peter Dalgaard
Prof Brian Ripley [EMAIL PROTECTED] writes:

 This is what happens if you don't have a usable X11 display.  Did you 
 perhaps use a root account on a console owned by a normal user?

More likely on SUSE is to get done in by a lack of -devel packages.
I've already mentioned tcl-devel and tk-devel but you also need 
xorg-x11-devel, readline-devel, and libjpeg-devel. The latter two are
not going to cause that particular error though. 
 
 On Tue, 27 Sep 2005, Fernando Mayer wrote:
 
  Dear R-users,
 
  i'm a very newbie in linux, but decided to build R from source.
  Following the R Installation and Administration manual, i did this:
 
  ./configure --enable-R-shlib # this option is here because i intend to
  build the GNOME console after...
  make
  make check
 
  no problems in make check, but:
 
  make check-devel #and also
  make check-all
 
  indicated some WARNINGs in the log file:
 
  /usr/local/R-2.1.1/tests/tcltk.Rcheck/00check.Rcheck
 
  Right below is the content of this log file (I translated some words):
 
  [start log file]
 
  * using log directory '/usr/local/R-2.1.1/tests/tcltk.Rcheck'
  * using R version 2.1.1, 2005-06-20
  * looks like 'tcltk' is a base package
  * skipping installation test
  * checking package directory ... OK
  * checking for portable file names ... OK
  * checking for sufficient/correct file permissions ... OK
  * checking DESCRIPTION meta-information ... OK
  * checking package dependencies ... OK
  * checking index information ... OK
  * checking package subdirectories ... OK
  * checking S3 generic/method consistency ... WARNING
  Erro: .First.lib failed for 'tcltk'
  Call sequence:
  2: stop(gettextf(.First.lib failed for '%s', libraryPkgName(package)),
domain = NA)
  1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose =
  FALSE)
  Interrupted execution
  See section 'Generic functions and methods' of the 'Writing R Extensions'
  manual.
  * checking replacement functions ... WARNING
  Error: .First.lib failed for 'tcltk'
  Call sequence:
  2: stop(gettextf(.First.lib failed for '%s', libraryPkgName(package)),
domain = NA)
  1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose =
  FALSE)
  Interrupted execution
  In R, the argument of a replacement function which corresponds to the right
  hand side must be named 'value'.
  * checking foreign function calls ... WARNING
  Error: .First.lib failed for 'tcltk'
  Call sequence:
  2: stop(gettextf(.First.lib failed for '%s', libraryPkgName(package)),
domain = NA)
  1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose =
  FALSE)
  Interrupted execution
  See section 'System and foreign language interfaces' of the 'Writing R
  Extensions' manual.
  * checking Rd files ... OK
  * checking for missing documentation entries ... WARNING
  Error: .First.lib failed for 'tcltk'
  Call sequence:
  2: stop(gettextf(.First.lib failed for '%s', libraryPkgName(package)),
domain = NA)
  1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose =
  FALSE)
  Interrupted execution
  All user-level objects in a package should have documentation entries.
  See chapter 'Writing R documentation files' in manual 'Writing R
  Extensions'.
  * checking for code/documentation mismatches ... WARNING
  Error: .First.lib failed for 'tcltk'
  Call sequence:
  2: stop(gettextf(.First.lib failed for '%s', libraryPkgName(package)),
domain = NA)
  1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose =
  FALSE)
  Interrupted execution
  Error: .First.lib failed for 'tcltk'
  Call sequence:
  2: stop(gettextf(.First.lib failed for '%s', libraryPkgName(package)),
domain = NA)
  1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose =
  FALSE)
  Interrupted execution
  Error: .First.lib failed for 'tcltk'
  Call sequence:
  2: stop(gettextf(.First.lib failed for '%s', libraryPkgName(package)),
domain = NA)
  1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose =
  FALSE)
  Interrupted execution
  * checking Rd \usage sections ... OK
  * checking DVI version of manual ... OK
 
  [end log file]
 
  The problem is in the tcltk package. I have searched in the archives,
  but didin't find anything similar to this problem (maybe there is, but i
  was not able to identify it). I really don't know what all the warnings
  means. What i need to know is what am i missing, and if there is
  something i can fix it. Also, are there any problems if i continue the
  installation without fix something?
 
  P.S.: actually R is running already from where it was buit, but i want
  to install it. So i want to avoid future problems, if this warnings
  really make some.
 
  Any help is appreciated. Thanks!
 
  Fernando Mayer.
 
  version
  _
  platform i686-pc-linux-gnu
  arch i686
  os   linux-gnu [SuSE 9.3]
  system   i686, linux-gnu
  status
  major2
  minor1.1
  year 2005
  month

Re: [R] Error in make check-all

2005-09-27 Thread Fernando Mayer
Dear Prof. Ripley, that was exactly what i did. Should i login on the 
system as root, instead of login as user and became root via console? 
What should i do to have X11 usable?

Thanks,
Fernando Mayer.


Prof Brian Ripley escreveu:

This is what happens if you don't have a usable X11 display.  Did you 
perhaps use a root account on a console owned by a normal user?

On Tue, 27 Sep 2005, Fernando Mayer wrote:

  

Dear R-users,

i'm a very newbie in linux, but decided to build R from source.
Following the R Installation and Administration manual, i did this:

./configure --enable-R-shlib # this option is here because i intend to
build the GNOME console after...
make
make check

no problems in make check, but:

make check-devel #and also
make check-all

indicated some WARNINGs in the log file:

/usr/local/R-2.1.1/tests/tcltk.Rcheck/00check.Rcheck

Right below is the content of this log file (I translated some words):

[start log file]

* using log directory '/usr/local/R-2.1.1/tests/tcltk.Rcheck'
* using R version 2.1.1, 2005-06-20
* looks like 'tcltk' is a base package
* skipping installation test
* checking package directory ... OK
* checking for portable file names ... OK
* checking for sufficient/correct file permissions ... OK
* checking DESCRIPTION meta-information ... OK
* checking package dependencies ... OK
* checking index information ... OK
* checking package subdirectories ... OK
* checking S3 generic/method consistency ... WARNING
Erro: .First.lib failed for 'tcltk'
Call sequence:
2: stop(gettextf(.First.lib failed for '%s', libraryPkgName(package)),
  domain = NA)
1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose =
FALSE)
Interrupted execution
See section 'Generic functions and methods' of the 'Writing R Extensions'
manual.
* checking replacement functions ... WARNING
Error: .First.lib failed for 'tcltk'
Call sequence:
2: stop(gettextf(.First.lib failed for '%s', libraryPkgName(package)),
  domain = NA)
1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose =
FALSE)
Interrupted execution
In R, the argument of a replacement function which corresponds to the right
hand side must be named 'value'.
* checking foreign function calls ... WARNING
Error: .First.lib failed for 'tcltk'
Call sequence:
2: stop(gettextf(.First.lib failed for '%s', libraryPkgName(package)),
  domain = NA)
1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose =
FALSE)
Interrupted execution
See section 'System and foreign language interfaces' of the 'Writing R
Extensions' manual.
* checking Rd files ... OK
* checking for missing documentation entries ... WARNING
Error: .First.lib failed for 'tcltk'
Call sequence:
2: stop(gettextf(.First.lib failed for '%s', libraryPkgName(package)),
  domain = NA)
1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose =
FALSE)
Interrupted execution
All user-level objects in a package should have documentation entries.
See chapter 'Writing R documentation files' in manual 'Writing R
Extensions'.
* checking for code/documentation mismatches ... WARNING
Error: .First.lib failed for 'tcltk'
Call sequence:
2: stop(gettextf(.First.lib failed for '%s', libraryPkgName(package)),
  domain = NA)
1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose =
FALSE)
Interrupted execution
Error: .First.lib failed for 'tcltk'
Call sequence:
2: stop(gettextf(.First.lib failed for '%s', libraryPkgName(package)),
  domain = NA)
1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose =
FALSE)
Interrupted execution
Error: .First.lib failed for 'tcltk'
Call sequence:
2: stop(gettextf(.First.lib failed for '%s', libraryPkgName(package)),
  domain = NA)
1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose =
FALSE)
Interrupted execution
* checking Rd \usage sections ... OK
* checking DVI version of manual ... OK

[end log file]

The problem is in the tcltk package. I have searched in the archives,
but didin't find anything similar to this problem (maybe there is, but i
was not able to identify it). I really don't know what all the warnings
means. What i need to know is what am i missing, and if there is
something i can fix it. Also, are there any problems if i continue the
installation without fix something?

P.S.: actually R is running already from where it was buit, but i want
to install it. So i want to avoid future problems, if this warnings
really make some.

Any help is appreciated. Thanks!

Fernando Mayer.

version
_
platform i686-pc-linux-gnu
arch i686
os   linux-gnu [SuSE 9.3]
system   i686, linux-gnu
status
major2
minor1.1
year 2005
month06
day  20
language R


  [[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] Error in make check-all

2005-09-27 Thread Prof Brian Ripley
On Tue, 27 Sep 2005, Fernando Mayer wrote:

 Dear Prof. Ripley, that was exactly what i did. Should i login on the system 
 as root, instead of login as user and became root via console? What should i 
 do to have X11 usable?

Well, I don't worry about this, but it you want to do a complete test you 
need the console running the user that is going to be running R.

(I see this when running tests remotely, as then I have no X11 display set 
to save bandwidth.  I just ignore it.)


 Thanks,
 Fernando Mayer.


 Prof Brian Ripley escreveu:

 This is what happens if you don't have a usable X11 display.  Did you 
 perhaps use a root account on a console owned by a normal user?
 
 On Tue, 27 Sep 2005, Fernando Mayer wrote:
 
 
 Dear R-users,
 
 i'm a very newbie in linux, but decided to build R from source.
 Following the R Installation and Administration manual, i did this:
 
 ./configure --enable-R-shlib # this option is here because i intend to
 build the GNOME console after...
 make
 make check
 
 no problems in make check, but:
 
 make check-devel #and also
 make check-all
 
 indicated some WARNINGs in the log file:
 
 /usr/local/R-2.1.1/tests/tcltk.Rcheck/00check.Rcheck
 
 Right below is the content of this log file (I translated some words):
 
 [start log file]
 
 * using log directory '/usr/local/R-2.1.1/tests/tcltk.Rcheck'
 * using R version 2.1.1, 2005-06-20
 * looks like 'tcltk' is a base package
 * skipping installation test
 * checking package directory ... OK
 * checking for portable file names ... OK
 * checking for sufficient/correct file permissions ... OK
 * checking DESCRIPTION meta-information ... OK
 * checking package dependencies ... OK
 * checking index information ... OK
 * checking package subdirectories ... OK
 * checking S3 generic/method consistency ... WARNING
 Erro: .First.lib failed for 'tcltk'
 Call sequence:
 2: stop(gettextf(.First.lib failed for '%s', libraryPkgName(package)),
  domain = NA)
 1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose =
 FALSE)
 Interrupted execution
 See section 'Generic functions and methods' of the 'Writing R Extensions'
 manual.
 * checking replacement functions ... WARNING
 Error: .First.lib failed for 'tcltk'
 Call sequence:
 2: stop(gettextf(.First.lib failed for '%s', libraryPkgName(package)),
  domain = NA)
 1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose =
 FALSE)
 Interrupted execution
 In R, the argument of a replacement function which corresponds to the 
 right
 hand side must be named 'value'.
 * checking foreign function calls ... WARNING
 Error: .First.lib failed for 'tcltk'
 Call sequence:
 2: stop(gettextf(.First.lib failed for '%s', libraryPkgName(package)),
  domain = NA)
 1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose =
 FALSE)
 Interrupted execution
 See section 'System and foreign language interfaces' of the 'Writing R
 Extensions' manual.
 * checking Rd files ... OK
 * checking for missing documentation entries ... WARNING
 Error: .First.lib failed for 'tcltk'
 Call sequence:
 2: stop(gettextf(.First.lib failed for '%s', libraryPkgName(package)),
  domain = NA)
 1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose =
 FALSE)
 Interrupted execution
 All user-level objects in a package should have documentation entries.
 See chapter 'Writing R documentation files' in manual 'Writing R
 Extensions'.
 * checking for code/documentation mismatches ... WARNING
 Error: .First.lib failed for 'tcltk'
 Call sequence:
 2: stop(gettextf(.First.lib failed for '%s', libraryPkgName(package)),
  domain = NA)
 1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose =
 FALSE)
 Interrupted execution
 Error: .First.lib failed for 'tcltk'
 Call sequence:
 2: stop(gettextf(.First.lib failed for '%s', libraryPkgName(package)),
  domain = NA)
 1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose =
 FALSE)
 Interrupted execution
 Error: .First.lib failed for 'tcltk'
 Call sequence:
 2: stop(gettextf(.First.lib failed for '%s', libraryPkgName(package)),
  domain = NA)
 1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose =
 FALSE)
 Interrupted execution
 * checking Rd \usage sections ... OK
 * checking DVI version of manual ... OK
 
 [end log file]
 
 The problem is in the tcltk package. I have searched in the archives,
 but didin't find anything similar to this problem (maybe there is, but i
 was not able to identify it). I really don't know what all the warnings
 means. What i need to know is what am i missing, and if there is
 something i can fix it. Also, are there any problems if i continue the
 installation without fix something?
 
 P.S.: actually R is running already from where it was buit, but i want
 to install it. So i want to avoid future problems, if this warnings
 really make some.
 
 Any help is appreciated. Thanks!
 
 Fernando Mayer.
 
 version
_
 platform i686-pc-linux-gnu
 arch 

[R] Weighting factor

2005-09-27 Thread Ferran Carrascosa
Hi everyone,

I would like some package of R or any help to solve the next problem
with a weighting fatcors:

Giving a data matrix with dichotomous (2 or more) variables in columns
and individuals in rows, and also a theorical distribution of the
dichotomous variables I would like a row weight (one per individual)
that transform the real distribution of variables to the theorical
distribution.

Thanks in advance and best regards,

--
Ferran Carrascosa

__
R-help@stat.math.ethz.ch 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] negative binomial in GEE

2005-09-27 Thread Thomas Lumley
On Tue, 27 Sep 2005, Simon.Bond wrote:


 Does anyone have any suggestions for a way round this problem for the
 future (I had to resort to using Stata), or maybe more realistically, how
 much work it would take to build an extendible version of the gee
 algorithm?


I don't think it would take that much work [and I've done it a couple of 
times, once in XLISP-Stat and once in SPIDA].  An entirely interpreted 
implementation will be relatively slow, though it might be possible to 
improve that quite a bit with sparse matrix techniques.

-thomas

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


Re: [R] dates are shown as X15.Feb.03

2005-09-27 Thread Duncan Murdoch
On 9/27/2005 12:13 PM, Chris Buddenhagen wrote:
 Dear Duncan Murdoch
 
 Thanks for responding. I will provide more complete info with future
 questions. The data for a small pilot study are below. 
 
 The values for each month are the percentage cover of an invasive plant here
 in the Galapagos (TT=treatment) type = immediately herbicide applied or
 applied to regrowth later. I called the data glyphosate.txt.
 
 
 The code is
 
 glyp-read.delim(C:\\Chris\\active projects\\Aristolochia\\glyphosate.txt,
 header=T)
 list(names(glyp))
 
 This is the output that mystified me:
 
 [1] TT type   CUADRANTES X15dec02   X15jan03  
  [6] X15feb03   X15apr03   X15jun03   X15aug03   X15oct03

It looks as though you have column headings like 15dec02.  That's not 
a legal R variable name, so it prepends the X to make it into one.  That 
way you can do things like glyp$X15dec02 to extract that column. 
glyp$15dec02 would give a syntax error.


 
 While I have an expert on hand I have another question, how do I produce a
 graph of time against percentage cover with error bars. I wanted to only
 present months on the x axis. I start by reorganizing the data using this:

Various functions implement error bars, but I haven't used them in a 
long  time, so I'll leave this question for someone else to answer.

Duncan Murdoch

 
 glyp2-reshape(glyp, direction=long, idvar=c(TT, type,
 CUADRANTES),varying=list(names(glyp)[4:10]),v.names=cover) but couldn't
 get month names to appear in the column time.
 
 
 
 TTtypeCUADRANTES  15dec02   15jan03   15feb03
 15apr03 15jun03   15aug03   15oct03
 T1immediate   1   63  59  60  55  4.5 1
 2
 T1immediate   2   75  75  75  75  6.5 1
 2
 T1immediate   22  72  70  70  65  35  2
 3.5
 T1immediate   26  90  80  80  75  17.52
 4
 T1immediate   33  75  80  85  85  40  1
 2
 T2immediate   18  85  80  80  22.52.5 2
 5
 T2immediate   21  90  85  85  60  16.50
 1
 T2immediate   23  85  80  80  75  17.51
 2
 T2immediate   28  90  85  85  27.527.50
 1
 T2immediate   31  90  85  85  9   12.51
 2
 T3immediate   3   50  58  60  65  35  1
 2
 T3immediate   10  63  60  60  15  2.5 0
 10
 T3immediate   12  90  85  85  17.515  0
 5
 T3immediate   16  85  82  80  78  9   1
 1.5
 T3immediate   34  75  80  85  85  35  1.5
 2.5
 T4wait4   75  75  75  7.5 2.5 0   0
 T4wait11  63  60  60  12.52.5 1   2
 T4wait24  90  85  80  3.5 5.5 1   2
 T4wait29  85  80  80  1.5 4.5 1   2
 T4wait32  85  80  80  3.5 4.5 2   3.5
 T5wait6   50  50  50  1   1   0.5 2
 T5wait14  80  75  75  15  5.5 1   2
 T5wait15  90  80  80  1   5.5 1   3
 T5wait20  85  80  80  22.58.5 0   0
 T5wait25  85  80  80  22.58.5 1   1.5
 T6wait8   75  75  75  1.5 4.5 0   1.5
 T6wait9   90  85  85  1.5 3.5 1   2
 T6wait13  80  75  75  1   3.5 1   1.5
 T6wait19  90  85  80  1   2.5 1   2
 T6wait27  85  80  75  1   3.5 1   2
 Tccontrol 5   50  45  45  40  23  20  25
 Tccontrol 7   50  53  54  55  55  50  55
 Tccontrol 17  90  80  70  22.59   15  20
 Tccontrol 30  75  75  70  75  45  60  70
 Tccontrol 35  90  85  80  85  65  60  70
 
 Chris Buddenhagen, Botany Department, Charles Darwin Research Station, Santa
 Cruz,Galapagos. Mail: Charles Darwin Foundation, Casilla 17-01-3891 Avenida
 6 de Diciembre N36-109 y Pasaje California Quito, ECUADOR
  
 
 
 
 
 
 __
 EL CONTENIDO DE ESTE MENSAJE ES DE ABSOLUTA RESPONSABILIDAD DEL AUTOR.
 FUNDACION CHARLES DARWIN
 WWW.DARWINFOUNDATION.ORG

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


[R] Using unsplit - unsplit does not seem to reverse the effect of split

2005-09-27 Thread Søren Højsgaard
In data OME in MASS I would like to extract the first 5 observations per 
subject (=ID). So I do
 
library(MASS)
OMEsub - split(OME, OME$ID)
OMEsub - lapply(OMEsub,function(x)x[1:5,])
unsplit(OMEsub, OME$ID)

- which results in 
 
[[1]]
[1] 1 1 1 1 1
[[2]]
[1] 30 30 30 30 30
[[3]]
[1] low low low low low
Levels: N/A high low
[[4]]
[1] 35 35 40 40 45
[[5]]
[1] coherent   incoherent coherent   incoherent coherent  
Levels: coherent incoherent
[[6]]
[1] 1 4 0 1 2


 
[[1094]]
[1] 4 5 5 5 2
[[1095]]
[1] 100 100 100 100 100
[[1096]]
[1] 18 18 18 18 18
[[1097]]
[1] N/A N/A N/A N/A N/A
Levels: N/A high low
There were 50 or more warnings (use warnings() to see the first 50)

warnings()
Warning messages:
1: number of items to replace is not a multiple of replacement length
2: number of items to replace is not a multiple of replacement length
3: number of items to replace is not a multiple of replacement length

 
According to documentation unsplit is the reverse of split, but I must be 
missing a point somewhere... Can anyone help? Thanks in advance. Søren

__
R-help@stat.math.ethz.ch 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] multiple plots on same x axis

2005-09-27 Thread Charles Annis, P.E.
Try 

plot(Day, gene1)
lines(Day, gene2)


see 

?lines
 
for more details.


Charles Annis, P.E.

[EMAIL PROTECTED]
phone: 561-352-9699
eFax:  614-455-3265
http://www.StatisticalEngineering.com
 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of IAIN GALLAGHER
Sent: Tuesday, September 27, 2005 10:35 AM
To: r-help@stat.math.ethz.ch
Subject: [R] multiple plots on same x axis

Hi.

I have two vectors of gene expression for each of
several days. I want to plot both vectors on the same
plot for a visual representation of up versus down
regulation. I've tried using add=T but that doesn't
work. 

eg

plot(Day, gene1)
plot(Day, gene2, add=T)

Any help would be appreciated.

Iain

__
R-help@stat.math.ethz.ch 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] Using unsplit - unsplit does not seem to reverse the effect of split

2005-09-27 Thread Peter Dalgaard
Søren Højsgaard [EMAIL PROTECTED] writes:

 In data OME in MASS I would like to extract the first 5 observations per 
 subject (=ID). So I do
  
 library(MASS)
 OMEsub - split(OME, OME$ID)
 OMEsub - lapply(OMEsub,function(x)x[1:5,])
 unsplit(OMEsub, OME$ID)
 
 - which results in 
  
 [[1]]
 [1] 1 1 1 1 1
 [[2]]
 [1] 30 30 30 30 30
 [[3]]
 [1] low low low low low
 Levels: N/A high low
 [[4]]
 [1] 35 35 40 40 45
 [[5]]
 [1] coherent   incoherent coherent   incoherent coherent  
 Levels: coherent incoherent
 [[6]]
 [1] 1 4 0 1 2
 
 
  
 [[1094]]
 [1] 4 5 5 5 2
 [[1095]]
 [1] 100 100 100 100 100
 [[1096]]
 [1] 18 18 18 18 18
 [[1097]]
 [1] N/A N/A N/A N/A N/A
 Levels: N/A high low
 There were 50 or more warnings (use warnings() to see the first 50)
 
 warnings()
 Warning messages:
 1: number of items to replace is not a multiple of replacement length
 2: number of items to replace is not a multiple of replacement length
 3: number of items to replace is not a multiple of replacement length
 
  
 According to documentation unsplit is the reverse of split, but I must be 
 missing a point somewhere... Can anyone help? Thanks in advance. Søren

It only works if the first argument is or could have resulted from a
split on the second argument. That is clearly not the case when you
are creating subvectors. 

I have on occasion wanted an unsplit that worked without the 2nd
argument as in

unsplit(l, rep(seq(along=l), sapply(l,length)) )

but if you think about it, it's not really doing anything that
do.call(c,l) or do.call(rbind,l) won't do.

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

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


Re: [R] Using unsplit - unsplit does not seem to reverse the effect of split

2005-09-27 Thread Marc Schwartz (via MN)
On Tue, 2005-09-27 at 19:12 +0200, Søren Højsgaard wrote:
 In data OME in MASS I would like to extract the first 5 observations
 per subject (=ID). So I do
  
 library(MASS)
 OMEsub - split(OME, OME$ID)
 OMEsub - lapply(OMEsub,function(x)x[1:5,])
 unsplit(OMEsub, OME$ID)
 
 - which results in 
  
 [[1]]
 [1] 1 1 1 1 1
 [[2]]
 [1] 30 30 30 30 30
 [[3]]
 [1] low low low low low
 Levels: N/A high low
 [[4]]
 [1] 35 35 40 40 45
 [[5]]
 [1] coherent   incoherent coherent   incoherent coherent  
 Levels: coherent incoherent
 [[6]]
 [1] 1 4 0 1 2
 
 
  
 [[1094]]
 [1] 4 5 5 5 2
 [[1095]]
 [1] 100 100 100 100 100
 [[1096]]
 [1] 18 18 18 18 18
 [[1097]]
 [1] N/A N/A N/A N/A N/A
 Levels: N/A high low
 There were 50 or more warnings (use warnings() to see the first 50)
 
 warnings()
 Warning messages:
 1: number of items to replace is not a multiple of replacement length
 2: number of items to replace is not a multiple of replacement length
 3: number of items to replace is not a multiple of replacement length
 
  
 According to documentation unsplit is the reverse of split, but I must
 be missing a point somewhere... Can anyone help? Thanks in advance.
 Søren


If you read the documentation for split/unsplit, you will also note that
in the Details section it says:

 'unsplit' works only with lists of vectors

as opposed to lists of data frames, which is the result of your split()
operation.

Also note that in the Value section, it indicates:

'unsplit' returns a vector for which 'split(x, f)' equals 'value'

as opposed to unsplit returning a data frame.


Thus, use:

  OME1 - do.call(rbind, OMEsub)

where OME1 will be the result of rbind()'ing the data frames in the
OMEsub list.

See ?do.call for more information.

HTH,

Marc Schwartz

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

Re: [R] Weighting factor

2005-09-27 Thread Thomas Lumley
On Tue, 27 Sep 2005, Ferran Carrascosa wrote:

 Hi everyone,

 I would like some package of R or any help to solve the next problem
 with a weighting fatcors:

 Giving a data matrix with dichotomous (2 or more) variables in columns
 and individuals in rows, and also a theorical distribution of the
 dichotomous variables I would like a row weight (one per individual)
 that transform the real distribution of variables to the theorical
 distribution.


You should be able to do this with postStratify() in the survey package 
(if you have joint distributions for the variables) or calibrate() if you 
have only marginal distributions.

You would need to create a survey design object, use postStratify() or 
calibrate() on it, then use weights() to extract the weights.

-thomas

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


[R] missing handling

2005-09-27 Thread Weiwei Shi
Hi,
I have the following codes to replace missing using median, assuming missing
only occurs on continuous variables:

trn1-read.table('trn1.fv', header=F, na.string='.', sep='|')

# median
m.trn1-sapply(1:ncol(trn1), function(i) median(trn1[,i], na.rm=T))

#replace
trn2-trn1
for (each in 1:nrow(trn1)){
index.missing=which(is.na(trn1[each,]))
trn2[each,]-replace(trn1[each,], index.missing, m.trn1[index.missing])
}


Anyone can suggest some ways to improve it since replacing 10 takes 1.5 sec:
 system.time(for (each in 1:10){index.missing=which(is.na(trn1[each,]));
trn2[each,]-replace(trn1[each,], index.missing, m.trn1[index.missing]);})
[1] 1.53 0.00 1.53 0.00 0.00


Another general question is
are there some packages in R doing missing handling?

Thanks,

--
Weiwei Shi, Ph.D

Did you always know?
No, I did not. But I believed...
---Matrix III

[[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] dynamic lists (data frames?)

2005-09-27 Thread tom wright
Can someone please show me what I need to get something like this to
work

for(a in c(1:5)){
data$a-c(a:10)
}

so that i end up with a structure
data$1-[1,2,3,4,5,6,7,8,9,10]
data$2-[2,3,4,5,67,8,9,10]
data$3-[3,4,5,67,8,9,10]
data$4-[4,5,67,8,9,10]
data$5-[5,67,8,9,10]

thanks loads
Tom

__
R-help@stat.math.ethz.ch 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] Listing object sizes without RODBC objects: contributed function

2005-09-27 Thread Leif Kirschenbaum
I include my workaround for object.size failing on RODBC objects.
Code adapted from Petr Pikal's code 
(http://tolstoy.newcastle.edu.au/R/help/04/06/1228.html).

ls.objects-function (pos = 1, order.by,...)
{
napply - function(names, fn) sapply(names, function(x) fn(get(x,pos=pos)))
names - ls(pos = pos,...)
obj.class - napply(names, function(x) as.character(class(x))[1])
obj.drop - match(RODBC,obj.class)
obj.class - obj.class[-obj.drop]
names - names[-obj.drop]
obj.mode - napply(names, mode)
obj.type - ifelse(is.na(obj.class), obj.mode, obj.class)
obj.size - napply(names, object.size)
obj.dim - t(napply(names, function(x) as.numeric(dim(x))[1:2]))
vec - is.na(obj.dim)[, 1]  (obj.type != function)
obj.dim[vec, 1] - napply(names, length)[vec]
out - data.frame(obj.type, obj.size, obj.dim)
names(out) - c(Type, Size, Rows, Columns)
if (!missing(order.by)) out - out[order(out[[order.by]]), ]
out
} 


Leif S. Kirschenbaum, Ph.D.
Senior Yield Engineer
Reflectivity, Inc.

__
R-help@stat.math.ethz.ch 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] dynamic lists (data frames?)

2005-09-27 Thread Vincent Goulet
Le 27 Septembre 2005 10:39, tom wright a écrit :
 Can someone please show me what I need to get something like this to
 work

 for(a in c(1:5)){
   data$a-c(a:10)
 }

 so that i end up with a structure
 data$1-[1,2,3,4,5,6,7,8,9,10]
 data$2-[2,3,4,5,67,8,9,10]
 data$3-[3,4,5,67,8,9,10]
 data$4-[4,5,67,8,9,10]
 data$5-[5,67,8,9,10]

 thanks loads
 Tom

That's an exercise I give to my students! This will create the sequences:

 data - lapply(1:5, seq, 10)

You can then assign the names with

 names(data) - as.character(1:5)

but 'data$1' will not work. You will need either 'data$1' or 'data[[1]]'. 
I'd use different names...

HTH.

-- 
  Vincent Goulet, Associate Professor
  École d'actuariat
  Université Laval, Québec 
  [EMAIL PROTECTED]   http://vgoulet.act.ulaval.ca

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

2005-09-27 Thread jim holtman
Use 'which(...arr.ind=T)'
  x.1
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] 6 10 3 4 10 7 9 8 4 10
[2,] 8 7 4 7 4 8 3 NA 3 4
[3,] 7 7 10 10 3 5 3 2 2 2
[4,] 3 4 5 10 10 2 6 9 4 5
[5,] 3 5 9 5 6 NA 3 NA 6 7
[6,] 9 6 10 5 10 4 2 10 NA 5
[7,] 5 2 5 10 3 7 6 4 6 8
[8,] 2 6 1 8 9 2 7 8 3 8
[9,] 9 1 4 9 8 10 2 NA 1 7
[10,] 2 4 8 7 NA 4 3 NA 5 5
 x.4
[1] 5.5 5.5 5.0 7.5 8.0 5.0 3.0 8.0 4.0 6.0
 Med - apply(x.1, 2, median, na.rm=T) # get median
 Ind - which(is.na(x.1), arr.ind=T) # determine which are NA
 x.1[Ind] - Med[Ind[,'col']] # replace with median
 x.1
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] 6 10 3 4 10 7 9 8 4 10
[2,] 8 7 4 7 4 8 3 8 3 4
[3,] 7 7 10 10 3 5 3 2 2 2
[4,] 3 4 5 10 10 2 6 9 4 5
[5,] 3 5 9 5 6 5 3 8 6 7
[6,] 9 6 10 5 10 4 2 10 4 5
[7,] 5 2 5 10 3 7 6 4 6 8
[8,] 2 6 1 8 9 2 7 8 3 8
[9,] 9 1 4 9 8 10 2 8 1 7
[10,] 2 4 8 7 8 4 3 8 5 5



 On 9/27/05, Weiwei Shi [EMAIL PROTECTED] wrote:

 Hi,
 I have the following codes to replace missing using median, assuming
 missing
 only occurs on continuous variables:

 trn1-read.table('trn1.fv', header=F, na.string='.', sep='|')

 # median
 m.trn1-sapply(1:ncol(trn1), function(i) median(trn1[,i], na.rm=T))

 #replace
 trn2-trn1
 for (each in 1:nrow(trn1)){
 index.missing=which(is.na(trn1[each,]))
 trn2[each,]-replace(trn1[each,], index.missing, m.trn1[index.missing])
 }


 Anyone can suggest some ways to improve it since replacing 10 takes 1.5sec:
  system.time(for (each in 1:10){index.missing=which(is.na(trn1[each,]));
 trn2[each,]-replace(trn1[each,], index.missing, m.trn1[index.missing]);})
 [1] 1.53 0.00 1.53 0.00 0.00


 Another general question is
 are there some packages in R doing missing handling?

 Thanks,

 --
 Weiwei Shi, Ph.D

 Did you always know?
 No, I did not. But I believed...
 ---Matrix III

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




--
Jim Holtman
Cincinnati, OH
+1 513 247 0281

What the problem you are trying to solve?

[[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] dynamic lists (data frames?)

2005-09-27 Thread Gabor Grothendieck
When sapply is used on a character vector it will use those
as the names so:

data - sapply(as.character(1:5), function(x) seq(as.numeric(x),10))

will give data with the required names.

On 9/27/05, tom wright [EMAIL PROTECTED] wrote:
 Can someone please show me what I need to get something like this to
 work

 for(a in c(1:5)){
data$a-c(a:10)
 }

 so that i end up with a structure
 data$1-[1,2,3,4,5,6,7,8,9,10]
 data$2-[2,3,4,5,67,8,9,10]
 data$3-[3,4,5,67,8,9,10]
 data$4-[4,5,67,8,9,10]
 data$5-[5,67,8,9,10]

 thanks loads
 Tom

 __
 R-help@stat.math.ethz.ch 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] Binding dataframe with different length in rows and columns

2005-09-27 Thread Jérôme Lemaître
Dear all,

I'm trying to combine in R the two following datasets. 
I'm would be very grateful if someone could help me with this problem.

Dataset 1:
X   Y   Z
1   27  48
2   25  50
3   27  40
4   28  56

Where X is a unique number and Y and Z some variables 

Dataset 2:
X   I   J
1   10  12
1   12  12
1   23  30
1   40  46
2   7   8
2   8   9
2   9   8
3   2   0
4   98  87
4   78  89
Where X IS NOT this time a unique number. I and J are some variables.

Thank you by advance


Jérôme Lemaître
Étudiant au doctorat
Université Laval
Québec, QC

__
R-help@stat.math.ethz.ch 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] Binding dataframe with different length in rows and columns

2005-09-27 Thread Nolwenn LeMeur
Hi Jerome,

look at the merge() function

Nolwenn

On Tue, 27 Sep 2005, Jérôme Lemaître wrote:

 Dear all,
 
 I'm trying to combine in R the two following datasets. 
 I'm would be very grateful if someone could help me with this problem.
 
 Dataset 1:
 X Y   Z
 1 27  48
 2 25  50
 3 27  40
 4 28  56
 
 Where X is a unique number and Y and Z some variables 
 
 Dataset 2:
 X I   J
 1 10  12
 1 12  12
 1 23  30
 1 40  46
 2 7   8
 2 8   9
 2 9   8
 3 2   0
 4 98  87
 4 78  89
 Where X IS NOT this time a unique number. I and J are some variables.
 
 Thank you by advance
 
 
 Jérôme Lemaître
 Étudiant au doctorat
 Université Laval
 Québec, QC
 
 __
 R-help@stat.math.ethz.ch 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] dynamic lists (data frames?)

2005-09-27 Thread tom wright
Hmm my bad,
Thanks for your replies but I think my example was a little to simple
the actual code I'm using is:


f_haardisolve-function(v_dataset){
#pad data to make length a power of 2
v_dataset-f_paddata(v_dataset)

l_cooef-list() #holder for cooefficents
i_count-1  #identity counter

while(length(v_dataset)0){
#seperate odd and even points
v_dataset-f_splitpoints(v_dataset)

v_dataset-f_haarpredict(v_dataset)
v_dataset-f_haaruplift(v_dataset)

str_idx-paste('c',i_count,sep='')
l_cooef
$str_idx-v_dataset[c((length(v_dataset)/2)+1:(length(v_dataset)/2))]
#should be no wrap on the previous line 

   v_dataset-v_dataset[c(1:length(v_dataset)/2)]

i_count-i_count+1
}
l_cooef
}

In this particular case I could probably calculate the number of
iterations and use l_cooef-names() but more is there a more generic
method for adding another column of data?



On Tue, 2005-27-09 at 10:39 -0400, tom wright wrote:
 Can someone please show me what I need to get something like this to
 work
 
 for(a in c(1:5)){
   data$a-c(a:10)
 }
 
 so that i end up with a structure
 data$1-[1,2,3,4,5,6,7,8,9,10]
 data$2-[2,3,4,5,67,8,9,10]
 data$3-[3,4,5,67,8,9,10]
 data$4-[4,5,67,8,9,10]
 data$5-[5,67,8,9,10]
 
 thanks loads
 Tom
 
 __
 R-help@stat.math.ethz.ch 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] [ESS] Indentation in R code

2005-09-27 Thread Göran Broström
On Mon, Sep 26, 2005 at 07:05:33PM +0200, Göran Broström wrote:
 On Mon, Sep 26, 2005 at 09:27:56AM +0200, Martin Maechler wrote:
  I'm crossposting to the ESS-help mailing list which is slightly
  more appropriate here.  [This may be a rare case where
  crossposting seems to make much sense.]
  
   PD == Peter Dalgaard [EMAIL PROTECTED]
   on 25 Sep 2005 19:40:45 +0200 writes:
  
  PD Seth Falcon [EMAIL PROTECTED] writes:
  
   On 24 Sep 2005, [EMAIL PROTECTED] wrote:
   
I am using emacs-21.3 when writing R functions on Linux debian, and
I am trying to follow the advice i R-exts.pdf (2.1.1) regarding
indentation. That is, I set 'c-default-style' to bsd and
'c-basic-offset' to 4. However, while this gives me the intended
indentation in C code, it doesn't change the behavior in R code; I
still get an indentation of size 2. This is my .emacs file after
customization:
   
(require 'ess-site)
(custom-set-variables
 ;; custom-set-variables was added by Custom -- don't edit or
 ;; cut/paste it!  Your init file should contain only one such
 ;; instance.
 '(c-basic-offset 4)
 '(c-default-style bsd))
 (custom-set-faces
 ;; custom-set-faces was added by Custom -- don't edit or 
  cut/paste it!
 ;; Your init file should contain only one such instance.
)
   
   Not sure if this is the best way, but I have the following after
   loading ess-site:
   
   (setq ess-indent-level 4)
  
  
  
  PD I have (I believe it stems from Martin M. originally):
  
  yes, most probably  {IIRC, Kurt Hornik was involved too}.
  
  PD  (add-hook 'c-mode-hook '(lambda()
  PD(c-set-style stroustrup)))
  
  the above is not quite what I have or did recommend, 
  which is rather  bsd + offset 4  as Göran has above
  
  In fact, Göran mentions the R-exts manual and that has
  the following  *before* giving the emacs-lisp statements:
  
   (For GNU Emacs 20: for GNU Emacs 21 use
   customization to set the `c-default-style' to `bsd' and
   `c-basic-offset' to `4'.)
  
  and indeed, that's what Göran did and you should do with a
  current emacs, either customize via GUI or,
  in your ~/.emacs file, find the section '(custom-set-variables ...)' and 
  add 
   '(c-basic-offset 4)
   '(c-default-style bsd)
  
  to the lines already there, or if there's no such section, add
  
  (custom-set-variables
;; custom-set-variables was added by Custom -- don't edit or cut/paste it!
;; Your init file should contain only one such instance.
   '(c-basic-offset 4)
   '(c-default-style bsd)


  to the end of your ~/.emacs file
 [...]
 
 but this is not sufficient to get correct (4) indentation (ess) in R 
 functions. We need some reference to ess as well, right? Maybe another
 reference to the ESS manual is in order in 'R-exts'?

Martin, I realize that it was stupid of me to cut here; I only refer to C
indentation, and forget that the lines of lisp code referring to ESS of 
course is necessary to get indentation working in R functions.

Once again, thanks for your good help.

Göran

__
R-help@stat.math.ethz.ch 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] dynamic lists (data frames?)

2005-09-27 Thread tom wright
Got it thanks
the trick was to create a variable with the new name
str_idx-paste('c',i,sep='')
then use double square brackets
l_cooef[str_idx]]-whatever()


f_haardisolve-function(v_dataset){
#pad data to make length a power of 2
v_dataset-f_paddata(v_dataset)

l_cooef-list() #holder for cooefficents
i_count-1  #identity counter

while(length(v_dataset)0){
#seperate odd and even points
v_dataset-f_splitpoints(v_dataset)

v_dataset-f_haarpredict(v_dataset)
v_dataset-f_haaruplift(v_dataset)

str_idx-paste('c',i_count,sep='')
l_cooef[[str_idx]]-list()

l_cooef[[str_idx]]-v_dataset[c((length(v_dataset)/2)+1:(length(v_dataset)/2))]
v_dataset-v_dataset[c(1:length(v_dataset)/2)]

i_count-i_count+1
}
l_cooef
}


On Tue, 2005-27-09 at 10:39 -0400, tom wright wrote:
 Can someone please show me what I need to get something like this to
 work
 
 for(a in c(1:5)){
   data$a-c(a:10)
 }
 
 so that i end up with a structure
 data$1-[1,2,3,4,5,6,7,8,9,10]
 data$2-[2,3,4,5,67,8,9,10]
 data$3-[3,4,5,67,8,9,10]
 data$4-[4,5,67,8,9,10]
 data$5-[5,67,8,9,10]
 
 thanks loads
 Tom
 
 __
 R-help@stat.math.ethz.ch 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] Binding dataframe with different length in rows and columns

2005-09-27 Thread venomousanimal
Hello ,
How about cbind or rbind?
You could create a new data frame and push yours into it.
Greetz

Jérôme Lemaître schrieb:

Dear all,

I'm trying to combine in R the two following datasets. 
I'm would be very grateful if someone could help me with this problem.

Dataset 1:
X  Y   Z
1  27  48
2  25  50
3  27  40
4  28  56

Where X is a unique number and Y and Z some variables 

Dataset 2:
X  I   J
1  10  12
1  12  12
1  23  30
1  40  46
2  7   8
2  8   9
2  9   8
3  2   0
4  98  87
4  78  89
Where X IS NOT this time a unique number. I and J are some variables.

Thank you by advance


Jérôme Lemaître
Étudiant au doctorat
Université Laval
Québec, QC

__
R-help@stat.math.ethz.ch 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] suggest some books or materials for matrices basics , its partitions, iterations, clusturing

2005-09-27 Thread Spencer Graves
  Your question seems almost too broad, but I will attempt a brief 
response.

  Have you reviewed the material on matrices in An Introduction to R, 
avaliable via, e.g., help.start()?  Also, have you reviewed LAPACK 
(http://www.netlib.org/lapack/)?

  If the answer to both is yes, submit another post (after reading 
the posting guide, www.R-project.org/posting-guide.html, which should 
increase the chances that you will get a quick, useful reply).

  spencer graves

booop booop wrote:

 Dear sir,
 Could anybody kindly suggest me some good
 e-books(which are available in the internet),or other
 materials in the web
 sites to refer examples ...
 in the following area
 
 matrices  its basics
 partitioning of matrices...
 iterations of matrices
 Clusturing in matrices...
 
 thank you sir..
 
 with kind regards,
 boopathy.
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

-- 
Spencer Graves, PhD
Senior Development Engineer
PDF Solutions, Inc.
333 West San Carlos Street Suite 700
San Jose, CA 95110, USA

[EMAIL PROTECTED]
www.pdf.com http://www.pdf.com
Tel:  408-938-4420
Fax: 408-280-7915

__
R-help@stat.math.ethz.ch 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] Dummy quesion about environment

2005-09-27 Thread Ron Ophir
Hi,
I'm trying to understand environment object in R.
I used the example:
  f - function(x) {
 y - 10
 g - function(x) x + y
 return(g)
 }
 h - f()
 h(3)
then i saw that f return an environment
 h
function(x) x + y
environment: 01B28570
but I coudn't access to x and y object in that environment:
I tried 
get(x,env=h)
I tried
h$y
can I access y and x?
how can I see an environment tree? oes search does it?
Thanks,
Ron

__
R-help@stat.math.ethz.ch 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] Dummy quesion about environment

2005-09-27 Thread Roger D. Peng
Try 'get(x, env = environment(h))'

-roger

Ron Ophir wrote:
 Hi,
 I'm trying to understand environment object in R.
 I used the example:
   f - function(x) {
  y - 10
  g - function(x) x + y
  return(g)
  }
  h - f()
  h(3)
 then i saw that f return an environment
 
h
 
 function(x) x + y
 environment: 01B28570
 but I coudn't access to x and y object in that environment:
 I tried 
 get(x,env=h)
 I tried
 h$y
 can I access y and x?
 how can I see an environment tree? oes search does it?
 Thanks,
 Ron
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
 

-- 
Roger D. Peng
http://www.biostat.jhsph.edu/~rpeng/

__
R-help@stat.math.ethz.ch 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] Dummy quesion about environment

2005-09-27 Thread Peter Dalgaard
Ron Ophir [EMAIL PROTECTED] writes:

 Hi,
 I'm trying to understand environment object in R.
 I used the example:
   f - function(x) {
  y - 10
  g - function(x) x + y
  return(g)
  }
  h - f()
  h(3)
 then i saw that f return an environment
  h
 function(x) x + y
 environment: 01B28570
 but I coudn't access to x and y object in that environment:
 I tried 
 get(x,env=h)
 I tried
 h$y
 can I access y and x?

Well, there are special issues with x above, but the basic thing is to
take environment(h). Notice that h _is_ a function that _has_ an
associated environment. 

 get(y,env=environment(h))
[1] 10

As I said, x is stranger, which is because you used f() in the call:

 get(x,env=environment(h))

 str(get(x,env=environment(h)))
 symbol
 a - get(x,env=environment(h))
 missing(a)
[1] TRUE
 evalq(x,environment(h))
Error in eval(expr, envir, enclos) : argument x is missing, with no
 default
 evalq(missing(x),environment(h))
[1] TRUE

You'll get the point if you look long and hard enough...

 how can I see an environment tree? 

You can't. You can see the parent of an environment, the grandparent,
etc., but there is no way to see which children a given environment
has. 

 oes search does it?

Huh?

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

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

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


Re: [R] Dummy quesion about environment

2005-09-27 Thread venomousanimal
Hej,

but in your function you add x and y to 10 and 3, so your values are 
merged to one value available in g variable.
And now you want to see what was your y and your x?
I guess I do not get the idea of your question.
Well, then you could return y and x as well as g.

Greetz n god luck.


Roger D. Peng schrieb:

Try 'get(x, env = environment(h))'

-roger

Ron Ophir wrote:
  

Hi,
I'm trying to understand environment object in R.
I used the example:
  f - function(x) {
 y - 10
 g - function(x) x + y
 return(g)
 }
 h - f()
 h(3)
then i saw that f return an environment



h
  

function(x) x + y
environment: 01B28570
but I coudn't access to x and y object in that environment:
I tried 
get(x,env=h)
I tried
h$y
can I access y and x?
how can I see an environment tree? oes search does it?
Thanks,
Ron

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

2005-09-27 Thread Ferran Carrascosa
Uau!
This package is very interesting, very thank you Thomas.

Thanks to all!

2005/9/27, Thomas Lumley [EMAIL PROTECTED]:
 On Tue, 27 Sep 2005, Ferran Carrascosa wrote:

  Hi everyone,
 
  I would like some package of R or any help to solve the next problem
  with a weighting fatcors:
 
  Giving a data matrix with dichotomous (2 or more) variables in columns
  and individuals in rows, and also a theorical distribution of the
  dichotomous variables I would like a row weight (one per individual)
  that transform the real distribution of variables to the theorical
  distribution.
 

 You should be able to do this with postStratify() in the survey package
 (if you have joint distributions for the variables) or calibrate() if you
 have only marginal distributions.

 You would need to create a survey design object, use postStratify() or
 calibrate() on it, then use weights() to extract the weights.

-thomas



--
Ferran Carrascosa

__
R-help@stat.math.ethz.ch 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] Make check fails on d-p-q-r-tests.R...

2005-09-27 Thread Prof Brian Ripley
I am afraid this does look like a real problem, if a minor one. We have 
for the first problem

x - 10^(ex - c(1,2,5*(1:5),50,100,200,300,Inf))
ex - -c(rev(1/x), ex)
qcauchy(ex, log=TRUE)

The first entry of the result should be Inf and the last -Inf.  From the 
output you have shown us I would guess the last is NaN.

If this is what is going on, it is a problem but a somewhat esoteric one 
that probably reflects a lack of IEC60559 (aka IEEE754) conformance.  It 
needs more hands-on debugging than we can provide on a help list.


On Tue, 27 Sep 2005, Jeff Ross wrote:

 On 1:03:39 am 09/27/05 Prof Brian Ripley [EMAIL PROTECTED] wrote:

 You will have to show us the error!   It will be shown in
 d-p-q-r-tests.Rout.fail (unless this was a segfault or similar).

 It is not OK to skip the test, but note that this test is random and
 does fail about 1 in 50 times, so you could just try rerunning it.

 I am so sorry.  I didn't even think to look for a .fail file.

 Here is the last bit of it:

 ## for PR#7902:
 ex - -c(rev(1/x), ex)
 All.eq(-x, qcauchy(pcauchy(-x)))
 [1] TRUE
 All.eq(+x, qcauchy(pcauchy(+x, log=TRUE), log=TRUE))
 [1] TRUE
 All.eq(1/x, pcauchy(qcauchy(1/x)))
 [1] TRUE
 All.eq(ex,  pcauchy(qcauchy(ex, log=TRUE), log=TRUE))
 [1] `is.NA' value mismatches: 1 in current, 0  in target
 Warning message:
 NaNs produced in: qcauchy(p, location, scale, lower.tail, log.p)
 II - c(-Inf,Inf)
 stopifnot(pcauchy(II) == 0:1, ## qcauchy(0:1) == II,
 +   pcauchy(II, log=TRUE) == c(-Inf,0),
 +   qcauchy(c(-Inf,0), log=TRUE) == II)
 Error in if (!(is.logical(r - eval(ll[[i]]))  all(r)))
 stop(paste(deparse(mc[[i +  :
  missing value where TRUE/FALSE needed
 In addition: Warning message:
 NaNs produced in: qcauchy(p, location, scale, lower.tail, log.p)
 Execution halted

 This is from the latest R-patched source tar ball, and it is the identical
 error as R-2.1.1.  I've consistently gotten the same error, even with
 configuration file tweaks and making clean between runs.

 Thanks!

 Jeff Ross

-- 
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] Simulate phi-coefficient (correlation between dichotomous vars)

2005-09-27 Thread David Duffy
On Tue, 27 Sep 2005, Bliese, Paul D LTC USAMH wrote:
 My situation is a bit more complicated and I'm not sure it is easily
 solved.  The problem is that I must assume one of the vectors is
 constant and generate one or more vectors that covary with the constant
 vector.

 One way is to sample from the 2x2 table with the specified means and
 pearson correlation (phi):

 for a fourfold table, a b
   c d
 with marginal proportions p1 and p2
 cov - phi * sqrt(p1*(1-p1)*p2*(1-p2))
 a - p1*p2 + cov
 b - p1*(1-p2) - cov
 c - (1-p1)*p2 - cov
 d - (1-p1)*(1-p2) + cov


Calculate the conditional probabilities from the above

P(X2=1|X1=1)= a/(a+b) = p2 + cov/p1
P(X2=1|X1=0)= c/(c+d) = p2 - cov/(1-p1)


condsim - function(X, phi, p2, p1=NULL) {
  if (!all(X %in% c(0,1))) stop(expecting 1's and 0's)
  if (is.null(p1)) p1 - mean(X)
  covar - phi  * sqrt(p1*(1-p1)*p2*(1-p2))
  if (covar0  covar(min(p1,p2)-p1*p2)) {
warning(Specified correlation too large for given marginal proportions)
covar - min(p1,p2)-p1*p2
  }else if (covar0  covar  -min(p1*p2,(1-p1)*(1-p2))) {
warning(Specified correlation too small for given marginal proportions)
covar - -min(p1*p2,(1-p1)*(1-p2))
  }
  Y - X
  i1 - X==1
  i0 - X==0
  Y[i1] - rbinom(sum(i1),1, p2 + covar/p1)
  Y[i0] - rbinom(sum(i0),1, p2 - covar/(1-p1))
  data.frame(X,Y)
}

David Duffy.

__
R-help@stat.math.ethz.ch 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 CMD build produces tar error under FreeBSD 5.4

2005-09-27 Thread Eric van Gyzen
On Sun, Sep 25, 2005 at 12:07:02PM +0100, Prof Brian Ripley wrote:
 On Sun, 25 Sep 2005, Andrew Robinson wrote:
 
  Hi R-helpers,
 
  I am trying to build a package under FreeBSD 5.4-RELEASE #0 using R
  Version 2.1.1.
 
  I have constructed a package using package.skeleton(), when I try
 
  $ R CMD build foo
  * checking for file 'foo/DESCRIPTION' ... OK
  * preparing 'foo':
  * checking DESCRIPTION meta-information ... OK
  * cleaning src
  * removing junk files
  tar: Option -L is not permitted in mode -x
  Error: cannot open file 'foo/DESCRIPTION' for reading
 
  foo/DESCRIPTION exists and the permissions are correct. The same
  command works under Linux Fedora 2.  The man pages on each OS imply
  that tar differs across the two platforms.  Does anyone have any
  thoughts on a work-around?
 
 No, because R does not use tar -L (which is to do with tape lengths on GNU
 tar).
 
 It does use tar chf and tar xhf.  The h modifier would appear to be
 applicable only to dumps, so at a wild guess the error message means -h is
 not permitted.  Try replacing xhf by xf.

FreeBSD = 5.3 uses bsdtar.  Previous versions used GNU tar.

In bsdtar, -h is a synonym for -L, and -L means:

 -L  (c and r mode only) All symbolic links will be followed.  Nor-
 mally, symbolic links are archived as such.  With this option,
 the target of the link will be archived instead.

The man page for bsdtar doesn't indicate an option to dereference
symlinks during extraction.  :(

Eric

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

2005-09-27 Thread Stephen Choularton
Hi 
 
I have a largish dataset (26 columns 35000 rows) which I have been
subjecting to logistic regression and support vector machine analysis.
I have noticed that R easily copes with using the data in either
technique.  Now I have to try and see what the best modeling technique
to use is. 
 
I only have limited time (who doesn’t) so I thought it would be best to
try the data with any other techniques on R that can handle that data
set and then use predict()  and so on.  I have identified the following
techniques (you may know of more) and think the packages indicated will
support them:
 
Neural networks - AMORE
Genetic/evolutionary   - ?
Bayes   - deal
Decision trees   - knnTree
Gaussian processes  - predict
 
Are these the right packages where I can go model = etc,
predict(model,etc using my dataset?
 
Have I missed some techniques?
 
Does anyone know the package I couldn’t find for genetic.
 
All help/comments welcome.
 
Thanks
 
Stephen
 
 

-- 



27/09/2005
 

[[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] Help: x11 position in the Unix environment

2005-09-27 Thread Brahm, David
Shengzhe Wu [EMAIL PROTECTED] wrote:

 In the Unix environment, I open a window by x11(). May I specify the
 position of this window by specifying the position of the top left of
 the window as in Windows environment?

I use xwit (version 3.4), a system command which manipulates existing
X windows.  My R code for initiating a graphics window contains:

  system(paste(xwit -move 2045 0 -names 'R Graphics: Device ,
   dev.cur(), ', sep=), ignore.stderr=TRUE)

See, e.g, http://www.x.org/contrib/utilities/xwit-3.4.tar.gz.
(I'm pretty sure I got the idea from another kind soul on R-help.)

-- David Brahm ([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] Make check fails on d-p-q-r-tests.R...

2005-09-27 Thread Jeff Ross


On Tue, 27 Sep 2005, Prof Brian Ripley wrote:

 I am afraid this does look like a real problem, if a minor one. We have for 
 the first problem

 x - 10^(ex - c(1,2,5*(1:5),50,100,200,300,Inf))
 ex - -c(rev(1/x), ex)
 qcauchy(ex, log=TRUE)

 The first entry of the result should be Inf and the last -Inf.  From the 
 output you have shown us I would guess the last is NaN.

 If this is what is going on, it is a problem but a somewhat esoteric one that 
 probably reflects a lack of IEC60559 (aka IEEE754) conformance.  It needs 
 more hands-on debugging than we can provide on a help list.


Thanks for the analysis.  I'll move this over to r-devel.

Jeff

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


[R] Plot Data Points in boxplots

2005-09-27 Thread Aric Gregson
Hello,

I would like to plot my data in a fashion similar to a boxplot, but 
plot the true data points without a box, just overlay lines of the 
summary generated by the boxplot. I have less than 10 observations 
within each group, so I think showing the actual data would be more 
effective than the box of the boxplot. I have been unable to find a way 
to do this.

Here is example data:
 d168teni
  d168dh10i d168hb10i d168icc10i d168rcs10i d168t410i d168tb410i
17252 29 8039 68
27647 28 6849 21
3   12385 87 71   164137
45847 50 7018  1

 boxplot(d168teni)

works to describe the data (each column a column in the plot). However, 
instead of the boxes, I want the data plotted (in a column) with the 5 
summary lines drawn over the points.

I have tried using functions from Design and have been unable to find a 
solution. I think I am missing the point.

Any suggestions on where to look or how to approach this differently?

thanks,

aric

__
R-help@stat.math.ethz.ch 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] Plot Data Points in boxplots

2005-09-27 Thread Gabor Grothendieck
Try this:

boxplot(Sepal.Length ~ Species, iris)
with(iris, stripchart(Sepal.Length ~ Species, vertical = TRUE, add = TRUE))

On 9/27/05, Aric Gregson [EMAIL PROTECTED] wrote:
 Hello,

 I would like to plot my data in a fashion similar to a boxplot, but
 plot the true data points without a box, just overlay lines of the
 summary generated by the boxplot. I have less than 10 observations
 within each group, so I think showing the actual data would be more
 effective than the box of the boxplot. I have been unable to find a way
 to do this.

 Here is example data:
  d168teni
  d168dh10i d168hb10i d168icc10i d168rcs10i d168t410i d168tb410i
 17252 29 8039 68
 27647 28 6849 21
 3   12385 87 71   164137
 45847 50 7018  1

  boxplot(d168teni)

 works to describe the data (each column a column in the plot). However,
 instead of the boxes, I want the data plotted (in a column) with the 5
 summary lines drawn over the points.

 I have tried using functions from Design and have been unable to find a
 solution. I think I am missing the point.

 Any suggestions on where to look or how to approach this differently?

 thanks,

 aric

 __
 R-help@stat.math.ethz.ch 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] scatterplot3d + density() + polygon(color)

2005-09-27 Thread klebyn

Hi R Users,

How to use the function polygon()
together with the package scatterplot3d?

I am trying to color below of the curves
defined for the function density().

I tried to use the site: R GRAPH GALLERY
as tutorial.

I tried to adapt the example of this page:
[figure]:
http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=30

[code]:
http://addictedtor.free.fr/graphiques/sources/source_30.R

to my case but I do not obtain success.

Somebody could give a tip to me, please?

I am thankful anticipatedly.

Cleber Borges



#My code test
##
library(scatterplot3d)
x=c(0.4, -1.2, .8, -.7, 0)

d1 = density(x[1],bw=1.2, from=-3.0,  to=3.0  )
d2 = density(x[2],bw=0.8, from=-3.0,  to=3.0  )
d3 = density(x[3],bw=0.6, from=-2.5,  to=2.5  )
d4 = density(x[4],bw=0.5, from=-2.0,  to=2.0  )
d5 = density(x[5],bw=0.3, from=-1.5,  to=1.5  )

sx = c(d1$x,d2$x,d3$x,d4$x,d5$x)
sy = c(d1$y,d2$y,d3$y,d4$y,d5$y)
sz = c(rep(0.1,512),rep(0.2,512),rep(0.3,512),rep(0.4,512),rep(0.5,512))

scatterplot3d(x=sx,y=sz,z=sy,type='l')
##

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