Re: [R] biplot label size

2006-09-06 Thread Prof Brian Ripley
cex works for me.

On Tue, 5 Sep 2006, Nair, Murlidharan T wrote:

 Which is the parameter that is used to decrease the size of ylabs
 plotted in biplot? I tried playing with cex and cex.lab I am not getting
 it right
 
 pc - princomp(USArrests) 
 
 biplot(pc, xlabs = rep(, nrow(USArrests)),ylabs=(colnames(USArrests)))
 
  Thanks../Murli


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

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


[R] Question on AffyBatch

2006-09-06 Thread Gunther Höning
Dear list,

I'm trying to find out the following in an AffyBatch.

To get the indices from a loction on a chip I use the function xy2i() for
the hgu133plus2 by Affymetrix.
But now I want to know the name of the probe located at this spot. How can
this be done?
And what about the locations used as QC?

Gunther

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


Re: [R] Quick question about lm()

2006-09-06 Thread Tong Wang
Thanks a lot for your help. 

tong

- Original Message -
From: Christos Hatzis [EMAIL PROTECTED]
Date: Monday, September 4, 2006 10:54 pm
Subject: RE: [R] Quick question about lm()
To: 'Tong Wang' [EMAIL PROTECTED], r-help@stat.math.ethz.ch

 Say,
 
 my.lm - lm(y ~ x, data=my.data)
 
 Then if you try:
 
 names(summary(my.lm)) 
 
 you will see the components of the summary.lm object.  The 
 coefficients and
 t-statistics can be extracted by
 
 summary(my.lm)$coefficients
 
 and similarly for the r-squared and other statistics provided in 
 the summary
 report.
 
 -Christos
 
 
 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Tong Wang
 Sent: Tuesday, September 05, 2006 1:35 AM
 To: r-help@stat.math.ethz.ch
 Subject: [R] Quick question about lm()
 
 Hi, 
 Feel awkward to ask , but really couldn't find a answer 
 anywhere,   How
 could I extract the R^2 and t-stat. from the 
 result of lm()?
 Thanks a lot. 
 
 best
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.htmland provide commented, minimal, self-contained, 
 reproducible code.
 
 
 


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


Re: [R] A question about gc()

2006-09-06 Thread Tong Wang
Yes, I am using R in windows, sorry for not being specific. 
You are right, I have stored too much stuff, and I need to trash some data in 
the process. 
Problem solved for me, Thank you very much. 

tong

- Original Message -
From: Prof Brian Ripley [EMAIL PROTECTED]
Date: Tuesday, September 5, 2006 3:42 am
Subject: Re: [R] A question about gc()
To: Tong Wang [EMAIL PROTECTED]
Cc: R help r-help@stat.math.ethz.ch

 On Tue, 5 Sep 2006, Tong Wang wrote:
 
  Hi everyone, 
 
  I am doing some intensive computation:  5 regressions of 
 the 
  form Y~X with each y of size (1,1000) , even if I break invoke 
 gc() for 
  a few time in the loop, it still breaks down at some point with 
 the 
  error message:
 
 gc() does not reclaim memory for you beyond what R has already done.
 
  Error in .signalSimpleWarning(Reached total allocation of 
 1024Mb: see help(memory.size),  : 
  recursive default argument reference
 
   After getting this, even if I call gc() and resume the 
 computation, it 
  won't move at all. May I get some suggestions what should I do to 
 get 
  around this problem ?
 
 Consult the rw-FAQ (since you seem to be using Windows without 
 telling us) 
 and the help page the message mentions.
 
 It looks as if you are trying to store too many objects.  If you 
 have lots 
 of RAM you can increase that limit (see the previous para), but you 
 are 
 getting uncomfortably close to the address space limit of your OS.
 
 Perhaps you can only save the part of the fit you need, or save() 
 the 
 objects to separate files and rm() them, and postprocess them in a 
 later 
 session?
 
 -- 
 Brian D. Ripley,  [EMAIL PROTECTED]
 Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
 University of Oxford, Tel:  +44 1865 272861 (self)
 1 South Parks Road, +44 1865 272866 (PA)
 Oxford OX1 3TG, UKFax:  +44 1865 272595


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


[R] What is the matrix version of min()

2006-09-06 Thread Tong Wang
Hi, 
Is there a function which operates on a matrix and return a vector of 
min/max of each rol/col ?
say,  X=  2,  1
3,  4 
min.col(X)=c(2,1)

thanks a lot.

tong

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


Re: [R] Fitting generalized additive models with constraints?

2006-09-06 Thread Simon Wood
On Tuesday 05 September 2006 20:32, David Reiss wrote:
  I am trying to fit a GAM for a simple model, a simple model, y ~ s(x0) +
  s(x1) ; with a constraint that the fitted smooth functions s(x0) and
  s(x1) have to each always be 0.
 
  From the library documentation and a search of the R-site and R-help
  archives I have not been able to decipher whether the following is
  possible using this, or other GAM libraries, or whether I will have to
  try to roll my own. I see from the mgcv docs that GAMs need to be
  constrained such that the smooth functions have zero mean. Is there a
  way around this?
 
  Is such a constraint possible?
 
  It is possible to estimate a GAM subject to this constraint, but be aware
  that the mean levels of your component smooths are not identifiable, so
  there is an unavoidable abitrariness in the estimate
 
  You have to have some sort of constraint on the smooths in a GAM to
  ensure identifiability, and a convenient way to set the model up is to
  write it as e.g.
 
  E(y) = a + f0(x0) + f1(x1)
 
  where `a' is the intercept and f0 and f1 are smooth functions which sum
  to zero over their respective covariate values. In this parameterization
  your constraint implies that
 
  a + f0(x0) + f1(x1)   0
 
  for all x0, x1. If this constraint is met then you can find constants b
  and c such that b+c=a such that f0(x0)+b0 and f1(x1)+c0 for all x0,x1.
  i.e. you redefine f0 as f0+b and f1 as f1+c, and you have a fitted model
  meeting the constraints.
 
  To fit the GAM subject to the constraints you can use mgcv:::pcls...
  ?pcls has some examples, but it does involve moderately low level
  programming. It's hard to impose the constraint exactly, so the usual
  approach would be to impose the constraint over a fairly fine grid of x0,
  x1 values. Also, you'll need to figure out how to select smoothing
  parameters. For many problems it suffices to estimate smoothing
  parameters on the unconstrained fit, and then use these to fit subject to
  constraints, but it depends on the problem
 
  Hope that's some use.
 
  Simon

 Hi Simon,
 thanks very much for the advice. I will try to parse your response and
 the pcls docs and see if I can get this to work. In the meantime, I
 found a paper that tries to achieve a similar thing with the same
 constraints as I am working with, using quadprog:
 http://www.esajournals.org/esaonline/?request=get-abstractissn=0012-9658v
olume=083issue=08page=2256 -David

- The additional wrinkle in gradient matching is that you have the equality 
constraints that the functions pass through zero at zero (a zero population 
can't produce offspring or corpses! ), which you don't have do you? If you do 
then it removes the ambiguity in the model, and makes everything a bit 
easier.
best,
Simon

-- 
 Simon Wood, Mathematical Sciences, University of Bath, Bath, BA2 7AY UK
 +44 1225 386603  www.maths.bath.ac.uk/~sw283

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


Re: [R] What is the matrix version of min()

2006-09-06 Thread Robin Hankin
Tong

you need to use apply().  The second argument specifies whether
you want to work with rows or columns.  The point of this is that
min() and max() operate on vectors and give a single value,
and you want to apply this function to all rows or all columns:

  a - matrix(rnorm(30),5,6)
  apply(a,2,max)
[1] 2.6413241 0.9842076 1.7989560 0.6999855 2.0542201 0.1162821
  apply(a,1,max)
[1] 1.1771370 0.9811693 2.6413241 0.9842076 2.0542201
 

HTH

rksh


On 6 Sep 2006, at 09:37, Tong Wang wrote:

 Hi,
 Is there a function which operates on a matrix and return a  
 vector of min/max of each rol/col ?
 say,  X=  2,  1
 3,  4
 min.col(X)=c(2,1)

 thanks a lot.

 tong

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

--
Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743

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


Re: [R] What is the matrix version of min()

2006-09-06 Thread Dimitris Rizopoulos
you could use something like:

# for row min and max
apply(X, 1, min)
apply(X, 1, max)

# for column min and max
apply(X, 2, min)
apply(X, 2, max)


I hope it helps.

Best,
Dimitris


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

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


- Original Message - 
From: Tong Wang [EMAIL PROTECTED]
To: R help r-help@stat.math.ethz.ch
Sent: Wednesday, September 06, 2006 10:37 AM
Subject: [R] What is the matrix version of min()


 Hi,
Is there a function which operates on a matrix and return a 
 vector of min/max of each rol/col ?
 say,  X=  2,  1
3,  4
 min.col(X)=c(2,1)

 thanks a lot.

 tong

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


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

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


Re: [R] What is the matrix version of min()

2006-09-06 Thread mel
Tong Wang a écrit :

 Hi, 
 Is there a function which operates on a matrix and return a vector of 
 min/max of each rol/col ?
 say,  X=  2,  1
 3,  4 
 min.col(X)=c(2,1)
 thanks a lot.
 tong

see ?pmin, which.min, which.max, max.col
hih

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


[R] [R-pkgs] package ltm -- version 0.6-0

2006-09-06 Thread Dimitris Rizopoulos
Dear R-users,

I'd like to announce the release of the new version of package 'ltm' 
for analyzing multivariate dichotomous and polytomous data under the 
Item Response Theory approach.

New features:

* function tpm() (along with supporting methods, i.e., anova, plot, 
margins, factor.scores, etc.) has been added for fitting Birnbaum's 
Three Parameter Model.

* grm() can now handle mix of dichotomous and polytomous items.

* descript() returns more output, especially for dichotomous manifest 
variables.

For more details check the CHANGES file. Future plans include 
development of functions for goodness-of-fit, and the Partial Credit 
Model.

Any kind of feedback (questions, suggestions, bug-reports, etc.) is 
more than welcome.


Best,
Dimitris


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

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



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

___
R-packages mailing list
R-packages@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-packages

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


Re: [R] What is the matrix version of min()

2006-09-06 Thread JeeBee

see ?apply

min.row - apply(X, 1, min)
min.col - apply(X, 2, min)

JeeBee

On Wed, 06 Sep 2006 01:37:22 -0700, Tong Wang wrote:

 Hi,
 Is there a function which operates on a matrix and return a vector of
 min/max of each rol/col ?
 say,  X=  2,  1
 3,  4
 min.col(X)=c(2,1)
 
 thanks a lot.
 
 tong
 
 __ R-help@stat.math.ethz.ch
 mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read
 the posting guide http://www.R-project.org/posting-guide.html and provide
 commented, minimal, self-contained, reproducible code.

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


Re: [R] What is the matrix version of min()

2006-09-06 Thread David Scott
On Wed, 6 Sep 2006, Robin Hankin wrote:

 Tong

 you need to use apply().  The second argument specifies whether
 you want to work with rows or columns.  The point of this is that
 min() and max() operate on vectors and give a single value,
 and you want to apply this function to all rows or all columns:

  a - matrix(rnorm(30),5,6)
  apply(a,2,max)
 [1] 2.6413241 0.9842076 1.7989560 0.6999855 2.0542201 0.1162821
  apply(a,1,max)
 [1] 1.1771370 0.9811693 2.6413241 0.9842076 2.0542201
 

 HTH

 rksh


Or in some circumstances you can use pmin (or pmax):

 a-matrix(rnorm(15),5,3)
 a
[,1]   [,2][,3]
[1,]  1.5175319 -0.4428964 -0.55473327
[2,] -0.2235937  1.0157411  0.08653748
[3,]  0.3240530 -0.4251498 -0.28565732
[4,]  0.4663556  1.1933213  0.60395935
[5,]  0.4078475  0.1739074  1.85645664
 pmin(a[,1],a[,2],a[,3])
[1] -0.5547333 -0.2235937 -0.4251498  0.4663556  0.1739074


David Scott
_
David Scott Visiting (July 06 to January 07)
Department of Probability and Statistics
The University of Sheffield
The Hicks Building
Hounsfield Road
Sheffield S3 7RH
United Kingdom
Phone:  +44 114 222 3908
Email:  [EMAIL PROTECTED]

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


Re: [R] What is the matrix version of min()

2006-09-06 Thread Tong Wang
Hi, 
   THANK YOU ALL for the prompt reply. 

cheers.

- Original Message -
From: Robin Hankin [EMAIL PROTECTED]
Date: Wednesday, September 6, 2006 1:42 am
Subject: Re: [R] What is the matrix version of min()
To: Tong Wang [EMAIL PROTECTED]
Cc: R help r-help@stat.math.ethz.ch

 Tong
 
 you need to use apply().  The second argument specifies whether
 you want to work with rows or columns.  The point of this is that
 min() and max() operate on vectors and give a single value,
 and you want to apply this function to all rows or all columns:
 
  a - matrix(rnorm(30),5,6)
  apply(a,2,max)
 [1] 2.6413241 0.9842076 1.7989560 0.6999855 2.0542201 0.1162821
  apply(a,1,max)
 [1] 1.1771370 0.9811693 2.6413241 0.9842076 2.0542201
 
 
 HTH
 
 rksh
 
 
 On 6 Sep 2006, at 09:37, Tong Wang wrote:
 
  Hi,
  Is there a function which operates on a matrix and return a  
  vector of min/max of each rol/col ?
  say,  X=  2,  1
  3,  4
  min.col(X)=c(2,1)
 
  thanks a lot.
 
  tong
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-
 
  guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 --
 Robin Hankin
 Uncertainty Analyst
 National Oceanography Centre, Southampton
 European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743
 
 
 
 


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


[R] plot axises on both sides of a graph

2006-09-06 Thread gallon li
Usually the y-axis is shown on the left-hand-side of a graph, is it possible
to artifically creat one more y-axis on the right-hand-side in R? What is
the main reference? Thank you in advance.

[[alternative HTML version deleted]]

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


[R] histogram in the background?

2006-09-06 Thread gallon li
I intend to draw a plot of y against x. In the background of this graph I
wish to creat a histogram of the horizontal variable x. Does any expert know
how to produce such a plot?

[[alternative HTML version deleted]]

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


Re: [R] winDialog UNIX equivalent?

2006-09-06 Thread JeeBee

Yes, there are many.
To give one example, you could consider using tcltk.

library(tcltk)
tkmessageBox(title=This is terrible, 
  message=What did you do?\nPromise not to do this again!, 
  icon=error, type=ok)

On Tue, 05 Sep 2006 23:10:41 +0200, Richard Müller wrote:

 Hi all,
 I'm using winDialog and winDialogString in scripts running on a
 XP-machine. Since we're using some Linux-machines (Suse 10.0 and 10.1 on
 x86) I'm interested in equivalents of the above functions usable under
 Linux-OS. Are there any? Thanks, 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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] histogram in the background?

2006-09-06 Thread JeeBee

How about this?

http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=78

JeeBee

On Wed, 06 Sep 2006 18:19:28 +0800, gallon li wrote:

 I intend to draw a plot of y against x. In the background of this graph I
 wish to creat a histogram of the horizontal variable x. Does any expert
 know how to produce such a plot?
 
   [[alternative HTML version deleted]]
 
 __ R-help@stat.math.ethz.ch
 mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read
 the posting guide http://www.R-project.org/posting-guide.html and provide
 commented, minimal, self-contained, reproducible code.

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


Re: [R] plot axises on both sides of a graph

2006-09-06 Thread JeeBee

Look at:
?axis (try the examples)

Further, a nice example I found on this mailing lists archive,
from somebody who says this has been asked many times already :)

x - 1:10
y1 - 1:10
y2 - rev(seq(1,1000, length=10))
plot(x,y1,ann=FALSE)
axis(2, at=c(2,4,6,8), labels=as.character(c(2,4,6,8)))

points(x,y2/100,col=red)
axis(4, at=c(2,4,6,8), labels=as.character(c(200, 400, 600, 800))) 


On Wed, 06 Sep 2006 18:10:33 +0800, gallon li wrote:

 Usually the y-axis is shown on the left-hand-side of a graph, is it
 possible to artifically creat one more y-axis on the right-hand-side in R?
 What is the main reference? Thank you in advance.
 
   [[alternative HTML version deleted]]
 
 __ R-help@stat.math.ethz.ch
 mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read
 the posting guide http://www.R-project.org/posting-guide.html and provide
 commented, minimal, self-contained, reproducible code.

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


Re: [R] histogram in the background?

2006-09-06 Thread JeeBee
gallon li wrote:

I have found this one before. However, my intension is slightly differing
from this plot: I wish to plot the histogram in the backgroun instead of
in the margin. Thanks anyway!

On Wed, 06 Sep 2006 12:29:51 +0200, JeeBee wrote:

 
 How about this?
 
 http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=78
 
 JeeBee


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


[R] Fwd: plot axises on both sides of a graph

2006-09-06 Thread gallon li
-- Forwarded message --
From: gallon li [EMAIL PROTECTED]
Date: Sep 6, 2006 7:48 PM
Subject: Re: [R] plot axises on both sides of a graph
To: Jim Lemon [EMAIL PROTECTED]

Both of your suggestions are so helpful. By combining what you told me, now
I am able to produce a second y-axis on the right-hand-side. Still one
problem remains: how can I put a definition of this y-axis in the space
left? Clearly there is enough room and I have to check some functions for
defining the margin of a plot. Moreoever, it seems not straight forward to
put some vertical text directly on the plot for this second ylab.


On 9/7/06, Jim Lemon [EMAIL PROTECTED] wrote:

 gallon li wrote:
  Usually the y-axis is shown on the left-hand-side of a graph, is it
 possible
  to artifically creat one more y-axis on the right-hand-side in R? What
 is
  the main reference? Thank you in advance.
 
 Have a look at:

 http://cran.r-project.org/doc/contrib/Lemon-kickstart/kr_addat.html

 Jim


[[alternative HTML version deleted]]

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


Re: [R] winDialog UNIX equivalent?

2006-09-06 Thread Richard Müller
 I'm using winDialog and winDialogString in scripts running on a XP-machine.
 Since we're using some Linux-machines (Suse 10.0 and 10.1 on x86) I'm
Thanks to the respondents. Use of TCl/Tk is a fine idea, because you can use 
the same scripts on Win and Linux OS.
Richard
-- 
Richard Müller - Am Spring 9 - D-58802 Balve-Eisborn
www.oeko-sorpe.de

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


[R] problem with putting objects in list

2006-09-06 Thread Rainer M Krug
Hi

I use the following code and it stores the results of density() in the
list dr:

dens - function(run) { density( positions$X[positions$run==run], bw=3,
cut=-2 ) }
dr - lapply(1:5, dens)

but the results are stored in dr[[i]] and not dr[i], i.e. plot(dr[[1]])
works, but plot([1]) doesn't.

Is there any way that I can store them in dr[i]?

Thanks a lot,

Rainer



-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[EMAIL PROTECTED]

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


Re: [R] Fwd: plot axises on both sides of a graph

2006-09-06 Thread JeeBee
See these two examples.

plot(1:2)
axis(4)
mtext(right y axis, side=4, line=-1.5)

par(mar=c(5,4,4,5)+.1)
plot(1:2)
axis(4)
mtext(right y axis, side=4, line=3) 

Good luck finding the right combination again ;)


On Wed, 06 Sep 2006 20:08:43 +0800, gallon li wrote:

 -- Forwarded message -- From: gallon li
 [EMAIL PROTECTED] Date: Sep 6, 2006 7:48 PM
 Subject: Re: [R] plot axises on both sides of a graph To: Jim Lemon
 [EMAIL PROTECTED]
 
 Both of your suggestions are so helpful. By combining what you told me,
 now I am able to produce a second y-axis on the right-hand-side. Still one
 problem remains: how can I put a definition of this y-axis in the space
 left? Clearly there is enough room and I have to check some functions for
 defining the margin of a plot. Moreoever, it seems not straight forward to
 put some vertical text directly on the plot for this second ylab.

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


Re: [R] histogram in the background?

2006-09-06 Thread John Kane

--- JeeBee [EMAIL PROTECTED] wrote:

 gallon li wrote:
 
 I have found this one before. However, my intension
 is slightly differing
 from this plot: I wish to plot the histogram in the
 backgroun instead of
 in the margin. Thanks anyway!
 
 On Wed, 06 Sep 2006 12:29:51 +0200, JeeBee wrote:
 
  
  How about this?
  
 

http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=78
  
  JeeBee

Can you not just plot the histogram and then the main
plot?  

Something like this, although it is a barplot rather
than a histogram.

Hours - c(0,1,2,3,4,5)
Nam - c( alf, bet, cet, det, NA , fet)
 En - c(5, 7, 8, 9, NA, 9)
 L1 - c(10, 9, 7, 5, 3 ,6)
 L2 - c(7, 4, 3, 2, 5, 7)
 
 
  MyLabels - seq(200, 500, length=13)
 
 mp -barplot(En)
 
# adjust margins to accommodate titles and labels
especially the 4 axis label.
par(mar=c(5,5,5,5))
 
 barplot(En, ylim=c(0, 12),axes =FALSE, ann=FALSE,
xlab=Hours, ylab=Volume, col.lab=blue)
 points (mp,L1, type=p, pch=19, col = red)
 points (mp,L2, type = l, col=blue)
 axis ( 2, 0:12, las=1, font=2) 
 axis (3, at=1:6, tick =F,  labels =c( alf, bet,
cet, det, NA , fet))
 axis (4, at = 0:12, labels = MyLabels, font=2)
 mtext(Number of Units Detected, 4,
line=3,col=blue)
 title ( main=A combined line and bar chart \n with
different x-axis labels, line=3, 
   font=3, col.main=blue)
 box()

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


Re: [R] Question on AffyBatch

2006-09-06 Thread James W. MacDonald
Hi Gunther,

Gunther Höning wrote:
 Dear list,
 
 I'm trying to find out the following in an AffyBatch.

This question is related specifically to a Bioconductor package, so 
should be asked on the bioconductor listserv rather than R-help.

Best,

Jim


 
 To get the indices from a loction on a chip I use the function xy2i() for
 the hgu133plus2 by Affymetrix.
 But now I want to know the name of the probe located at this spot. How can
 this be done?
 And what about the locations used as QC?
 
 Gunther
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


-- 
James W. MacDonald, M.S.
Biostatistician
Affymetrix and cDNA Microarray Core
University of Michigan Cancer Center
1500 E. Medical Center Drive
7410 CCGC
Ann Arbor MI 48109
734-647-5623


**
Electronic Mail is not secure, may not be read every day, and should not be 
used for urgent or sensitive issues.

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


Re: [R] histogram in the background?

2006-09-06 Thread hadley wickham
 I intend to draw a plot of y against x. In the background of this graph I
 wish to creat a histogram of the horizontal variable x. Does any expert know
 how to produce such a plot?

When constructing such a plot, you need to be careful that you don't
end up constructing a pretty picture instead of a statistical graphic.
 In this case you need to ask yourself, what would the y-axis
represent?  What scale would it have?

Hadley

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


Re: [R] problem with putting objects in list

2006-09-06 Thread Antonio, Fabio Di Narzo
Use 'sapply' instead of 'lapply'. Type
?lapply
for details

Antonio, Fabio Di Narzo.
University of Bologna, Italy

2006/9/6, Rainer M Krug [EMAIL PROTECTED]:
 Hi

 I use the following code and it stores the results of density() in the
 list dr:

 dens - function(run) { density( positions$X[positions$run==run], bw=3,
 cut=-2 ) }
 dr - lapply(1:5, dens)

 but the results are stored in dr[[i]] and not dr[i], i.e. plot(dr[[1]])
 works, but plot([1]) doesn't.

 Is there any way that I can store them in dr[i]?

 Thanks a lot,

 Rainer



 --
 Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
 Biology (UCT)

 Department of Conservation Ecology and Entomology
 University of Stellenbosch
 Matieland 7602
 South Africa

 Tel:+27 - (0)72 808 2975 (w)
 Fax:+27 - (0)21 808 3304
 Cell:   +27 - (0)83 9479 042

 email:  [EMAIL PROTECTED]
 [EMAIL PROTECTED]

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


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


Re: [R] problem with putting objects in list

2006-09-06 Thread Rainer M Krug
Antonio, Fabio Di Narzo wrote:
 Use 'sapply' instead of 'lapply'. Type
If I use sapply it seems to simplify / collapse to much.

 ?lapply
 for details


 
 Antonio, Fabio Di Narzo.
 University of Bologna, Italy
 
 2006/9/6, Rainer M Krug [EMAIL PROTECTED]:
 Hi

 I use the following code and it stores the results of density() in the
 list dr:

 dens - function(run) { density( positions$X[positions$run==run], bw=3,
 cut=-2 ) }
 dr - lapply(1:5, dens)

 but the results are stored in dr[[i]] and not dr[i], i.e. plot(dr[[1]])
 works, but plot([1]) doesn't.

 Is there any way that I can store them in dr[i]?

 Thanks a lot,

 Rainer



 -- 
 Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
 Biology (UCT)

 Department of Conservation Ecology and Entomology
 University of Stellenbosch
 Matieland 7602
 South Africa

 Tel:+27 - (0)72 808 2975 (w)
 Fax:+27 - (0)21 808 3304
 Cell:   +27 - (0)83 9479 042

 email:  [EMAIL PROTECTED]
 [EMAIL PROTECTED]

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



-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[EMAIL PROTECTED]

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


[R] how to loop through 2 lists with different indexes

2006-09-06 Thread Tania Oh
Dear all,

I am a newbie in R and need some help please.  (I do apologise if my  
email is not as informative as it should be, I've tried to include  
the relevant details without overcrowding it with the rest of the code)

I would like to sample (without replacement) Y objects based on the  
number of objects in X in 5 different bins. I'm having trouble  
because the list object in which the number of objects of X is stored  
in doesn't start its index from 0.

# number of X objects in each of the 5 bins
   x.bin.size - lapply(x.by.bins, nrow)

x.bin.size
$`3`
[1] 1

$`4`
[1] 3

$`5`
[1] 10


# no. of objects in each of the 5 bins of Y
  y.bin.size - lapply(y.by.bins, nrow)

y.bin.size
$`2`
[1] 4

$`3`
[1] 42

$`4`
[1] 253

$`5`
[1] 945

how do I loop through Y and sample from X when the index of Y starts  
from 2 and that of X starts from 3? in X, the missing index $`2` is  
assumed to have 0 objects in it. hence, I would only sample from Y  
and X starting from index 3.

sample (y.bin.size$`3`, x.bin.size$`3`, replace=FALSE)

but how should I do this in an R command without knowing which  
indexes (of X ) are empty? Any pointers would be greatly appreciated.


Many thanks in advance,
tania

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


[R] how to loop through 2 lists with different indexes

2006-09-06 Thread Tania Oh
Very sorry if this mail is sent out twice to the list, I wasn't sure  
if the email address I used in the first go was correct.



From: [EMAIL PROTECTED]
Subject:how to loop through 2 lists with different indexes
Date:   6 September 2006 15:16:21 BDT
To:   [EMAIL PROTECTED]

Dear all,

I am a newbie in R and need some help please.  (I do apologise if my  
email is not as informative as it should be, I've tried to include  
the relevant details without overcrowding it with the rest of the code)

I would like to sample (without replacement) Y objects based on the  
number of objects in X in 5 different bins. I'm having trouble  
because the list object in which the number of objects of X is stored  
in doesn't start its index from 0.

# number of X objects in each of the 5 bins
   x.bin.size - lapply(x.by.bins, nrow)

x.bin.size
$`3`
[1] 1

$`4`
[1] 3

$`5`
[1] 10


# no. of objects in each of the 5 bins of Y
  y.bin.size - lapply(y.by.bins, nrow)

y.bin.size
$`2`
[1] 4

$`3`
[1] 42

$`4`
[1] 253

$`5`
[1] 945

how do I loop through Y and sample from X when the index of Y starts  
from 2 and that of X starts from 3? in X, the missing index $`2` is  
assumed to have 0 objects in it. hence, I would only sample from Y  
and X starting from index 3.

sample (y.bin.size$`3`, x.bin.size$`3`, replace=FALSE)

but how should I do this in an R command without knowing which  
indexes (of X ) are empty? Any pointers would be greatly appreciated.


Many thanks in advance,
tania

  ---
Tania Oh
D.Phil student
Department of Physiology, Anatomy and Genetics
University of Oxford
OX1 3TU

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


Re: [R] how to loop through 2 lists with different indexes

2006-09-06 Thread jim holtman
To find what names are common to both, use 'intersect'

 x.bin.size - list('3'=1, '4'=4, '5'=10)
 y.bin.size - list('2'=4, '3'=42, '4'=253, '5'=954)
 sameNames - intersect(names(x.bin.size), names(y.bin.size))
 sameNames
[1] 3 4 5
 lapply(sameNames, function(x) sample(seq(y.bin.size[[x]]), x.bin.size[[x]]))
[[1]]
[1] 12

[[2]]
[1]  95 145 228  51

[[3]]
 [1] 858 901 630 599  59 196 168 651 364 728




On 9/6/06, Tania Oh [EMAIL PROTECTED] wrote:
 Dear all,

 I am a newbie in R and need some help please.  (I do apologise if my
 email is not as informative as it should be, I've tried to include
 the relevant details without overcrowding it with the rest of the code)

 I would like to sample (without replacement) Y objects based on the
 number of objects in X in 5 different bins. I'm having trouble
 because the list object in which the number of objects of X is stored
 in doesn't start its index from 0.

 # number of X objects in each of the 5 bins
   x.bin.size - lapply(x.by.bins, nrow)

 x.bin.size
 $`3`
 [1] 1

 $`4`
 [1] 3

 $`5`
 [1] 10


 # no. of objects in each of the 5 bins of Y
  y.bin.size - lapply(y.by.bins, nrow)

 y.bin.size
 $`2`
 [1] 4

 $`3`
 [1] 42

 $`4`
 [1] 253

 $`5`
 [1] 945

 how do I loop through Y and sample from X when the index of Y starts
 from 2 and that of X starts from 3? in X, the missing index $`2` is
 assumed to have 0 objects in it. hence, I would only sample from Y
 and X starting from index 3.

 sample (y.bin.size$`3`, x.bin.size$`3`, replace=FALSE)

 but how should I do this in an R command without knowing which
 indexes (of X ) are empty? Any pointers would be greatly appreciated.


 Many thanks in advance,
 tania

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



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

What is the problem you are trying to solve?

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


[R] About the Skew Student distribution

2006-09-06 Thread pierre clauss
Hello everybody,
I need your help about the package SN and the skew student distribution. Il 
will be very grateful if I have the solution.
 
I construct a stochastic model with a white noise not gaussian but following a 
skew student distribution. I fit the noise on monthly data to obtain the four 
parameters. The question is : how to annualize the parameters to use my model 
for simulate daily data for example ? 
 
If the volatility is estimated to 3 for example, I need to multiply this by 
sqrt(12) to have for the parameter of volatility of the skew student : 
3*sqrt(12)*sqrt(dt) with dt the time increment parameter (1/12 for monthly 
data, 1/261 for daily data, and so on). Do I do the same thing (and what is the 
multiplicative factor ?) for the parameters of asymmetry and the degree of 
freedom ?
 
Thanks a lot !
Best regards
 
Pierre.
[[alternative HTML version deleted]]

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


[R] Matrix multiplication using apply() or lappy() ?

2006-09-06 Thread toby_marks
I am trying to divide the columns of a matrix by the first row in the 
matrix.

I have tried to get this using apply and I seem to be missing a concept 
regarding the apply w/o calling a function but rather command args %*% / 
etc.  Would using apply be more efficient than this approach? 

I have observed examples in the archives using this type of approach. Does 
anybody have a snippet of a call to apply() that would accomplish this as 
well?

Thanks!


seed=50
$a = array(rnorm(20),dim=c(4,5))
$b = matrix(a[1,],dim(a)[1],dim(a)[2],byrow=T)
$a
   [,1]   [,2]   [,3][,4]   [,5]
[1,] -1.3682810 -0.4314462 1.57572752  0.67928882 -0.3672346
[2,]  0.4328180  0.6556479 0.64289931  0.08983289  0.1852306
[3,] -0.8113932  0.3219253 0.08976065 -2.99309008  0.5818237
[4,]  1.4441013 -0.7838389 0.27655075  0.28488295  1.3997368

$a/b
   [,1]   [,2]   [,3]   [,4]  [,5]
[1,]  1.000  1.000 1.  1.000  1.00
[2,] -0.3163225 -1.5196515 0.40800157  0.1322455 -0.504393
[3,]  0.5930018 -0.7461539 0.05696457 -4.4062113 -1.584338
[4,] -1.0554128  1.8167710 0.17550671  0.4193841 -3.811560




CONFIDENTIALITY NOTICE: This electronic mail transmission (i...{{dropped}}

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


[R] density plots????

2006-09-06 Thread Luis Barreiro
Dear all,

I arrive to do density plots using the function kde2d , and from this do 
a countour plot. My problem is that I do not really understand what the 
labels for the different levels mean??? What I would like to obtain is a 
surface encompassing the 95 percentile of my values. In other words I would 
like the levels to represent, for example, the 90th, 95th and 99th 
percentiles of my values. I hope I have been clear.
Do you think you can help me??? I would be VERY grateful.


Thanks in advance

Luis Barreiro

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


Re: [R] Matrix multiplication using apply() or lappy() ?

2006-09-06 Thread Christos Hatzis
See ?sweep

sweep(a, 2, a[1,],/)

-Christos  

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: Wednesday, September 06, 2006 11:49 AM
To: r-help@stat.math.ethz.ch
Subject: [R] Matrix multiplication using apply() or lappy() ?

I am trying to divide the columns of a matrix by the first row in the
matrix.

I have tried to get this using apply and I seem to be missing a concept
regarding the apply w/o calling a function but rather command args %*% /
etc.  Would using apply be more efficient than this approach? 

I have observed examples in the archives using this type of approach. Does
anybody have a snippet of a call to apply() that would accomplish this as
well?

Thanks!


seed=50
$a = array(rnorm(20),dim=c(4,5))
$b = matrix(a[1,],dim(a)[1],dim(a)[2],byrow=T)
$a
   [,1]   [,2]   [,3][,4]   [,5]
[1,] -1.3682810 -0.4314462 1.57572752  0.67928882 -0.3672346 [2,]  0.4328180
0.6556479 0.64289931  0.08983289  0.1852306 [3,] -0.8113932  0.3219253
0.08976065 -2.99309008  0.5818237 [4,]  1.4441013 -0.7838389 0.27655075
0.28488295  1.3997368

$a/b
   [,1]   [,2]   [,3]   [,4]  [,5]
[1,]  1.000  1.000 1.  1.000  1.00 [2,] -0.3163225
-1.5196515 0.40800157  0.1322455 -0.504393 [3,]  0.5930018 -0.7461539
0.05696457 -4.4062113 -1.584338 [4,] -1.0554128  1.8167710 0.17550671
0.4193841 -3.811560




CONFIDENTIALITY NOTICE: This electronic mail transmission (i...{{dropped}}

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

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


[R] Covariance/Correlation matrix for repeated measures data frame

2006-09-06 Thread Afshartous, David
All,
 
I have a repeated measures data frame and was wondering if the
covariance matrix can be 
calculated via some created indexing or built-in R function.
 
Specifically, say there are 3 variables, where potassium concentration
is measured 6 times on each patient.
Patient number (discrete)
Time (1 to 6, discrete)
Potassium (continuous variable)
 
I want the covariance/correlation matrix for the cov/corr between
Potassium at time i and time j.
 
Is this possible in the current dataframe format?  Or do I have to
define new varialbes, say Time i and Time j, 
and then compute the cov/corr between Time i and Time j for all
combinations?   
 
Cheers,
Dave
 
 
 
 
David Afshartous, PhD
University of Miami
School of Business
Rm KE-408
Coral Gables, FL 33124
 

[[alternative HTML version deleted]]

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


Re: [R] Matrix multiplication using apply() or lappy() ?

2006-09-06 Thread Gabor Grothendieck
Here are a few possibilities:

a - matrix(1:24, 4) # test data

a / rep(a[1,], each = 4)

a / outer(rep(1, nrow(a)), a[1,])

a %*% diag(1/a[1,])

sweep(a, 2, a[1,], /)


On 9/6/06, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
 I am trying to divide the columns of a matrix by the first row in the
 matrix.

 I have tried to get this using apply and I seem to be missing a concept
 regarding the apply w/o calling a function but rather command args %*% /
 etc.  Would using apply be more efficient than this approach?

 I have observed examples in the archives using this type of approach. Does
 anybody have a snippet of a call to apply() that would accomplish this as
 well?

 Thanks!


 seed=50
 $a = array(rnorm(20),dim=c(4,5))
 $b = matrix(a[1,],dim(a)[1],dim(a)[2],byrow=T)
 $a
   [,1]   [,2]   [,3][,4]   [,5]
 [1,] -1.3682810 -0.4314462 1.57572752  0.67928882 -0.3672346
 [2,]  0.4328180  0.6556479 0.64289931  0.08983289  0.1852306
 [3,] -0.8113932  0.3219253 0.08976065 -2.99309008  0.5818237
 [4,]  1.4441013 -0.7838389 0.27655075  0.28488295  1.3997368

 $a/b
   [,1]   [,2]   [,3]   [,4]  [,5]
 [1,]  1.000  1.000 1.  1.000  1.00
 [2,] -0.3163225 -1.5196515 0.40800157  0.1322455 -0.504393
 [3,]  0.5930018 -0.7461539 0.05696457 -4.4062113 -1.584338
 [4,] -1.0554128  1.8167710 0.17550671  0.4193841 -3.811560



 
 CONFIDENTIALITY NOTICE: This electronic mail transmission (i...{{dropped}}

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


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


Re: [R] Covariance/Correlation matrix for repeated measures data frame

2006-09-06 Thread Dimitris Rizopoulos
try the following:

dat - data.frame(id = rep(1:100, each = 6), time = rep(1:6, 100), pot 
= rnorm(600))

# for a balanced data-set
mat - matrix(dat$pot, ncol = 6, byrow = TRUE)
cor(mat)

# for a unbalanced data-set
dat - dat[-sample(600, 100), ]
mat - t(sapply(split(dat, dat$id), function(x){
out - rep(NA, 6)
out[x$time] - x$pot
out
}))

cor(mat, use = pairwise.complete.obs)


I hope it helps.

Best,
Dimitris


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

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


- Original Message - 
From: Afshartous, David [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Sent: Wednesday, September 06, 2006 5:59 PM
Subject: [R] Covariance/Correlation matrix for repeated measures data 
frame


 All,

 I have a repeated measures data frame and was wondering if the
 covariance matrix can be
 calculated via some created indexing or built-in R function.

 Specifically, say there are 3 variables, where potassium 
 concentration
 is measured 6 times on each patient.
 Patient number (discrete)
 Time (1 to 6, discrete)
 Potassium (continuous variable)

 I want the covariance/correlation matrix for the cov/corr between
 Potassium at time i and time j.

 Is this possible in the current dataframe format?  Or do I have to
 define new varialbes, say Time i and Time j,
 and then compute the cov/corr between Time i and Time j for all
 combinations?

 Cheers,
 Dave




 David Afshartous, PhD
 University of Miami
 School of Business
 Rm KE-408
 Coral Gables, FL 33124


 [[alternative HTML version deleted]]

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


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

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


Re: [R] Matrix multiplication using apply() or lappy() ?

2006-09-06 Thread Gabor Grothendieck
And here is one more:

t(apply(a, 1, function(x) x/a[1,]))

On 9/6/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
 Here are a few possibilities:

 a - matrix(1:24, 4) # test data

 a / rep(a[1,], each = 4)

 a / outer(rep(1, nrow(a)), a[1,])

 a %*% diag(1/a[1,])

 sweep(a, 2, a[1,], /)


 On 9/6/06, [EMAIL PROTECTED]
 [EMAIL PROTECTED] wrote:
  I am trying to divide the columns of a matrix by the first row in the
  matrix.
 
  I have tried to get this using apply and I seem to be missing a concept
  regarding the apply w/o calling a function but rather command args %*% /
  etc.  Would using apply be more efficient than this approach?
 
  I have observed examples in the archives using this type of approach. Does
  anybody have a snippet of a call to apply() that would accomplish this as
  well?
 
  Thanks!
 
 
  seed=50
  $a = array(rnorm(20),dim=c(4,5))
  $b = matrix(a[1,],dim(a)[1],dim(a)[2],byrow=T)
  $a
[,1]   [,2]   [,3][,4]   [,5]
  [1,] -1.3682810 -0.4314462 1.57572752  0.67928882 -0.3672346
  [2,]  0.4328180  0.6556479 0.64289931  0.08983289  0.1852306
  [3,] -0.8113932  0.3219253 0.08976065 -2.99309008  0.5818237
  [4,]  1.4441013 -0.7838389 0.27655075  0.28488295  1.3997368
 
  $a/b
[,1]   [,2]   [,3]   [,4]  [,5]
  [1,]  1.000  1.000 1.  1.000  1.00
  [2,] -0.3163225 -1.5196515 0.40800157  0.1322455 -0.504393
  [3,]  0.5930018 -0.7461539 0.05696457 -4.4062113 -1.584338
  [4,] -1.0554128  1.8167710 0.17550671  0.4193841 -3.811560
 
 
 
  
  CONFIDENTIALITY NOTICE: This electronic mail transmission (i...{{dropped}}
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 


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


Re: [R] Matrix multiplication using apply() or lappy() ?

2006-09-06 Thread Prof Brian Ripley
On Wed, 6 Sep 2006, Christos Hatzis wrote:

 See ?sweep
 
 sweep(a, 2, a[1,],/)

That is less efficient than

a/rep(a[1,], each=nrow(a))


 
 -Christos  
 
 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of
 [EMAIL PROTECTED]
 Sent: Wednesday, September 06, 2006 11:49 AM
 To: r-help@stat.math.ethz.ch
 Subject: [R] Matrix multiplication using apply() or lappy() ?
 
 I am trying to divide the columns of a matrix by the first row in the
 matrix.
 
 I have tried to get this using apply and I seem to be missing a concept
 regarding the apply w/o calling a function but rather command args %*% /
 etc.  Would using apply be more efficient than this approach? 
 
 I have observed examples in the archives using this type of approach. Does
 anybody have a snippet of a call to apply() that would accomplish this as
 well?
 
 Thanks!
 
 
 seed=50
 $a = array(rnorm(20),dim=c(4,5))
 $b = matrix(a[1,],dim(a)[1],dim(a)[2],byrow=T)
 $a
[,1]   [,2]   [,3][,4]   [,5]
 [1,] -1.3682810 -0.4314462 1.57572752  0.67928882 -0.3672346 [2,]  0.4328180
 0.6556479 0.64289931  0.08983289  0.1852306 [3,] -0.8113932  0.3219253
 0.08976065 -2.99309008  0.5818237 [4,]  1.4441013 -0.7838389 0.27655075
 0.28488295  1.3997368
 
 $a/b
[,1]   [,2]   [,3]   [,4]  [,5]
 [1,]  1.000  1.000 1.  1.000  1.00 [2,] -0.3163225
 -1.5196515 0.40800157  0.1322455 -0.504393 [3,]  0.5930018 -0.7461539
 0.05696457 -4.4062113 -1.584338 [4,] -1.0554128  1.8167710 0.17550671
 0.4193841 -3.811560
 
 
 
 
 CONFIDENTIALITY NOTICE: This electronic mail transmission (i...{{dropped}}
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

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

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


Re: [R] Matrix multiplication using apply() or lappy() ?

2006-09-06 Thread Gabor Grothendieck
This last one could also be written slightly shorter as:

t(apply(a, 1, /, a[1,]))

On 9/6/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
 And here is one more:

 t(apply(a, 1, function(x) x/a[1,]))

 On 9/6/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
  Here are a few possibilities:
 
  a - matrix(1:24, 4) # test data
 
  a / rep(a[1,], each = 4)
 
  a / outer(rep(1, nrow(a)), a[1,])
 
  a %*% diag(1/a[1,])
 
  sweep(a, 2, a[1,], /)
 
 
  On 9/6/06, [EMAIL PROTECTED]
  [EMAIL PROTECTED] wrote:
   I am trying to divide the columns of a matrix by the first row in the
   matrix.
  
   I have tried to get this using apply and I seem to be missing a concept
   regarding the apply w/o calling a function but rather command args %*% /
   etc.  Would using apply be more efficient than this approach?
  
   I have observed examples in the archives using this type of approach. Does
   anybody have a snippet of a call to apply() that would accomplish this as
   well?
  
   Thanks!
  
  
   seed=50
   $a = array(rnorm(20),dim=c(4,5))
   $b = matrix(a[1,],dim(a)[1],dim(a)[2],byrow=T)
   $a
 [,1]   [,2]   [,3][,4]   [,5]
   [1,] -1.3682810 -0.4314462 1.57572752  0.67928882 -0.3672346
   [2,]  0.4328180  0.6556479 0.64289931  0.08983289  0.1852306
   [3,] -0.8113932  0.3219253 0.08976065 -2.99309008  0.5818237
   [4,]  1.4441013 -0.7838389 0.27655075  0.28488295  1.3997368
  
   $a/b
 [,1]   [,2]   [,3]   [,4]  [,5]
   [1,]  1.000  1.000 1.  1.000  1.00
   [2,] -0.3163225 -1.5196515 0.40800157  0.1322455 -0.504393
   [3,]  0.5930018 -0.7461539 0.05696457 -4.4062113 -1.584338
   [4,] -1.0554128  1.8167710 0.17550671  0.4193841 -3.811560
  
  
  
   
   CONFIDENTIALITY NOTICE: This electronic mail transmission (i...{{dropped}}
  
   __
   R-help@stat.math.ethz.ch mailing list
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide 
   http://www.R-project.org/posting-guide.html
   and provide commented, minimal, self-contained, reproducible code.
  
 


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


Re: [R] Matrix multiplication using apply() or lappy() ?

2006-09-06 Thread Gabor Grothendieck
Yet another one using the idempotent apply in reshape package
that eliminates the transpose:

library(reshape)
iapply(a, 1, /, a[1,])

On 9/6/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
 This last one could also be written slightly shorter as:

 t(apply(a, 1, /, a[1,]))

 On 9/6/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
  And here is one more:
 
  t(apply(a, 1, function(x) x/a[1,]))
 
  On 9/6/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
   Here are a few possibilities:
  
   a - matrix(1:24, 4) # test data
  
   a / rep(a[1,], each = 4)
  
   a / outer(rep(1, nrow(a)), a[1,])
  
   a %*% diag(1/a[1,])
  
   sweep(a, 2, a[1,], /)
  
  
   On 9/6/06, [EMAIL PROTECTED]
   [EMAIL PROTECTED] wrote:
I am trying to divide the columns of a matrix by the first row in the
matrix.
   
I have tried to get this using apply and I seem to be missing a concept
regarding the apply w/o calling a function but rather command args %*% /
etc.  Would using apply be more efficient than this approach?
   
I have observed examples in the archives using this type of approach. 
Does
anybody have a snippet of a call to apply() that would accomplish this 
as
well?
   
Thanks!
   
   
seed=50
$a = array(rnorm(20),dim=c(4,5))
$b = matrix(a[1,],dim(a)[1],dim(a)[2],byrow=T)
$a
  [,1]   [,2]   [,3][,4]   [,5]
[1,] -1.3682810 -0.4314462 1.57572752  0.67928882 -0.3672346
[2,]  0.4328180  0.6556479 0.64289931  0.08983289  0.1852306
[3,] -0.8113932  0.3219253 0.08976065 -2.99309008  0.5818237
[4,]  1.4441013 -0.7838389 0.27655075  0.28488295  1.3997368
   
$a/b
  [,1]   [,2]   [,3]   [,4]  [,5]
[1,]  1.000  1.000 1.  1.000  1.00
[2,] -0.3163225 -1.5196515 0.40800157  0.1322455 -0.504393
[3,]  0.5930018 -0.7461539 0.05696457 -4.4062113 -1.584338
[4,] -1.0554128  1.8167710 0.17550671  0.4193841 -3.811560
   
   
   

CONFIDENTIALITY NOTICE: This electronic mail transmission 
(i...{{dropped}}
   
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
   
  
 


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


[R] Help on estimated variance in lme4

2006-09-06 Thread jerome lemaitre
Dear all,

I get an error message when I run my model and I am not sure what to do
about it.

I try to determine what factors influence the survival of voles. I use a
mixed-model because I have several voles per site (varying from 2 to 19
voles).

Here is the model:
###
fm5 -lmer(data=cdrgsaou2,
alive~factor(pacut)+factor(agecamp)+factor(sex)+ResCondCorp+(1|factor(cdrgsa
ou2$ids)),
family=binomial,
method=Laplace,
)
###
Description of variables
Alive: 0 or 1; dead or alive
pacut: 0 or 1; presence of parasites
agecamp: a or j; adult or juvenile
sex: m or f; male or female
ResCondCorp: body condition, continuous;
cdrgsaou2$ids: name of the site.


Here is the output:

###
Generalized linear mixed model fit using Laplace 
Formula: alive ~ factor(pacut) + factor(agecamp) + factor(sex) + ResCondCorp
+  (1 | factor(cdrgsaou2$ids)) 
   Data: cdrgsaou2 
 Family: binomial(logit link)
  AIC  BIClogLik deviance
 305.7418 328.7331 -146.8709 293.7418
Random effects:
 GroupsNameVariance Std.Dev.
 factor(cdrgsaou2$ids) (Intercept) 0.034382 0.18542 
number of obs: 341, groups: factor(cdrgsaou2$ids), 36

Estimated scale (compare to 1)  2.174681 

Fixed effects:
  Estimate Std. Error z value  Pr(|z|)
(Intercept)   0.971458   0.250951  3.8711 0.0001083 ***
factor(pacut)1   -0.831888   0.358583 -2.3199 0.0203447 *  
factor(agecamp)j -1.294236   0.330638 -3.9144 9.065e-05 ***
factor(sex)m  0.581713   0.296229  1.9637 0.0495616 *  
ResCondCorp  -0.176251   0.020263 -8.6982  2.2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 

Correlation of Fixed Effects:
(Intr) fct()1 fctr(g) fctr(s)
factr(pct)1 -0.334   
fctr(gcmp)j -0.417  0.066
factor(sx)m -0.505 -0.002 -0.173 
ResCondCorp -0.309 -0.010  0.302  -0.032 
###

Here is the error message:

###
Warning message:
Estimated variance for factor 'factor(cdrgsaou2$ids)' is effectively zero
 in: LMEopt(x = mer, value = cv)
###

Thank you very much by advance for any help.



Jérôme Lemaître


Ph.D. student
Silviculture-wildlife research chair in irregular boreal forests
 Départment of biology,
Faculty of Sciences and Engineering
Alexandre-Vachon building
University Laval
Quebec, QC  G1K 7P4
Phone : (418) 656-2131 poste 2917
Office : VCH-2044
Email: [EMAIL PROTECTED]

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


Re: [R] Matrix multiplication using apply() or lappy() ?

2006-09-06 Thread Rolf Turner
Prof. Brian Ripley wrote:

 On Wed, 6 Sep 2006, Christos Hatzis wrote:
 
  See ?sweep
  
  sweep(a, 2, a[1,],/)
 
 That is less efficient than
 
 a/rep(a[1,], each=nrow(a))

*My* first instinct was to use

t(t(a)/a[1,])

(which has not heretofore been suggested).

This seems to be more efficient still (at least in respect of Prof.
Grothendieck's toy example) by between 20 and 25 percent:

 a - matrix(1:24,4)
 system.time(for(i in 1:1000) junk - a / rep(a[1,], each = 4))
[1] 0.690 0.080 1.051 0.000 0.000
 system.time(for(i in 1:1000) junk - t(t(a)/a[1,]))
[1] 0.520 0.120 0.647 0.000 0.000
 system.time(for(i in 1:1) junk - a / rep(a[1,], each = 4))
[1]  7.08  0.99 10.08  0.00  0.00
 system.time(for(i in 1:1) junk - t(t(a)/a[1,]))
[1] 5.530 0.940 7.856 0.000 0.000

cheers,

Rolf Turner

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


Re: [R] Matrix multiplication using apply() or lappy() ?

2006-09-06 Thread toby_marks
The apply was exactly what I was after.  And, I will check out the others 
as well.  great tips!




Gabor Grothendieck [EMAIL PROTECTED] 
09/06/2006 11:11 AM





To
[EMAIL PROTECTED] [EMAIL PROTECTED]
cc
r-help@stat.math.ethz.ch
Subject
Re: [R] Matrix multiplication using apply() or lappy() ?






This last one could also be written slightly shorter as:

t(apply(a, 1, /, a[1,]))

On 9/6/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
 And here is one more:

 t(apply(a, 1, function(x) x/a[1,]))

 On 9/6/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
  Here are a few possibilities:
 
  a - matrix(1:24, 4) # test data
 
  a / rep(a[1,], each = 4)
 
  a / outer(rep(1, nrow(a)), a[1,])
 
  a %*% diag(1/a[1,])
 
  sweep(a, 2, a[1,], /)
 
 
  On 9/6/06, [EMAIL PROTECTED]
  [EMAIL PROTECTED] wrote:
   I am trying to divide the columns of a matrix by the first row in 
the
   matrix.
  
   I have tried to get this using apply and I seem to be missing a 
concept
   regarding the apply w/o calling a function but rather command args 
%*% /
   etc.  Would using apply be more efficient than this approach?
  
   I have observed examples in the archives using this type of 
approach. Does
   anybody have a snippet of a call to apply() that would accomplish 
this as
   well?
  
   Thanks!
  
  
   seed=50
   $a = array(rnorm(20),dim=c(4,5))
   $b = matrix(a[1,],dim(a)[1],dim(a)[2],byrow=T)
   $a
 [,1]   [,2]   [,3][,4]   [,5]
   [1,] -1.3682810 -0.4314462 1.57572752  0.67928882 -0.3672346
   [2,]  0.4328180  0.6556479 0.64289931  0.08983289  0.1852306
   [3,] -0.8113932  0.3219253 0.08976065 -2.99309008  0.5818237
   [4,]  1.4441013 -0.7838389 0.27655075  0.28488295  1.3997368
  
   $a/b
 [,1]   [,2]   [,3]   [,4]  [,5]
   [1,]  1.000  1.000 1.  1.000  1.00
   [2,] -0.3163225 -1.5196515 0.40800157  0.1322455 -0.504393
   [3,]  0.5930018 -0.7461539 0.05696457 -4.4062113 -1.584338
   [4,] -1.0554128  1.8167710 0.17550671  0.4193841 -3.811560
  
  
  
   
   CONFIDENTIALITY NOTICE: This electronic mail transmission 
(i...{{dropped}}
  
   __
   R-help@stat.math.ethz.ch mailing list
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
   and provide commented, minimal, self-contained, reproducible code.
  
 




CONFIDENTIALITY NOTICE: This electronic mail transmission (i...{{dropped}}

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


Re: [R] Matrix multiplication using apply() or lappy() ?

2006-09-06 Thread Gabor Grothendieck
In terms of speed Toby's original idea was actually the fastest.
Here they are decreasing order of the largest timing in each
row of system.time.  I also tried it with a 100x10 matrix and
got almost the same order:

 library(reshape)
 system.time(for(i in 1:1000) iapply(a, 1, /, a[1,]))
[1] 11.51  0.01 18.65NANA
 system.time(for(i in 1:1000) t(apply(a, 1, /, a[1,])))
[1] 0.83 0.00 1.36   NA   NA
 system.time(for(i in 1:1000) sweep(a, 2, a[1,], /))
[1] 0.27 0.00 0.39   NA   NA
 system.time(for(i in 1:1000) a/outer(rep(1, nrow(a)), a[1,]))
[1] 0.23 0.00 0.39   NA   NA
 system.time(for(i in 1:1000) a %*% diag(1/a[1,]))
[1] 0.25 0.00 0.38   NA   NA
 system.time(for(i in 1:1000) a/rep(a[1,], each = nrow(a)))
[1] 0.09 0.00 0.16   NA   NA
 system.time(for(i in 1:1000) t(t(a)/a[1,]))
[1] 0.10 0.00 0.13   NA   NA
 system.time(for(i in 1:1000) a/matrix(a[1,], nrow(a), ncol(a), byrow = TRUE))
[1] 0.05 0.00 0.12   NA   NA


 On 9/6/06, Rolf Turner [EMAIL PROTECTED] wrote:
 Prof. Brian Ripley wrote:

  On Wed, 6 Sep 2006, Christos Hatzis wrote:
 
   See ?sweep
  
   sweep(a, 2, a[1,],/)
 
  That is less efficient than
 
  a/rep(a[1,], each=nrow(a))

 *My* first instinct was to use

t(t(a)/a[1,])

 (which has not heretofore been suggested).

 This seems to be more efficient still (at least in respect of Prof.
 Grothendieck's toy example) by between 20 and 25 percent:

 a - matrix(1:24,4)
 system.time(for(i in 1:1000) junk - a / rep(a[1,], each = 4))
[1] 0.690 0.080 1.051 0.000 0.000
 system.time(for(i in 1:1000) junk - t(t(a)/a[1,]))
[1] 0.520 0.120 0.647 0.000 0.000
 system.time(for(i in 1:1) junk - a / rep(a[1,], each = 4))
[1]  7.08  0.99 10.08  0.00  0.00
 system.time(for(i in 1:1) junk - t(t(a)/a[1,]))
[1] 5.530 0.940 7.856 0.000 0.000

cheers,

Rolf Turner

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


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


Re: [R] Matrix multiplication using apply() or lappy() ?

2006-09-06 Thread Prof Brian Ripley
What version of R was this?

In 2.4.0 alpha

 a - matrix(1:24,4)
 system.time(for(i in 1:1000) junk - a / rep(a[1,], each = 4))
[1] 0.014 0.000 0.014 0.000 0.000
 system.time(for(i in 1:1000) junk - t(t(a)/a[1,]))
[1] 0.057 0.000 0.058 0.000 0.000

shows a large margin the other way, which increases with bigger matrices

 a - matrix(pi*1:100, 100, 1000)
 system.time(for(i in 1:1000) junk - t(t(a)/a[1,]))
[1] 18.329  2.238 20.595  0.000  0.000
 system.time(for(i in 1:1000) junk - a / rep(a[1,], each = 4))
[1] 2.589 1.021 3.610 0.000 0.000


On Wed, 6 Sep 2006, Rolf Turner wrote:

 Prof. Brian Ripley wrote:
 
  On Wed, 6 Sep 2006, Christos Hatzis wrote:
  
   See ?sweep
   
   sweep(a, 2, a[1,],/)
  
  That is less efficient than
  
  a/rep(a[1,], each=nrow(a))
 
 *My* first instinct was to use
 
   t(t(a)/a[1,])
 
 (which has not heretofore been suggested).
 
 This seems to be more efficient still (at least in respect of Prof.
 Grothendieck's toy example) by between 20 and 25 percent:
 
a - matrix(1:24,4)
system.time(for(i in 1:1000) junk - a / rep(a[1,], each = 4))
   [1] 0.690 0.080 1.051 0.000 0.000
system.time(for(i in 1:1000) junk - t(t(a)/a[1,]))
   [1] 0.520 0.120 0.647 0.000 0.000
system.time(for(i in 1:1) junk - a / rep(a[1,], each = 4))
   [1]  7.08  0.99 10.08  0.00  0.00
system.time(for(i in 1:1) junk - t(t(a)/a[1,]))
   [1] 5.530 0.940 7.856 0.000 0.000
 
   cheers,
 
   Rolf Turner
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

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

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


[R] singular factor analysis

2006-09-06 Thread Spencer Graves
  Are there any functions available to do a factor analysis with 
fewer observations than variables?  As long as you have more than 3 
observations, my computations suggest you have enough data to estimate a 
factor analysis covariance matrix, even though the sample covariance 
matrix is singular.  I tried the naive thing and got an error: 

  set.seed(1)
  X - array(rnorm(50), dim=c(5, 10))
  factanal(X, factors=1)
Error in solve.default(cv) : system is computationally singular: 
reciprocal condition number = 4.8982e-018

  I can write a likelihood for a multivariate normal and solve it, 
but I wondered if there is anything else available that could do this? 

  Thanks,
  Spencer Graves

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


Re: [R] problem with putting objects in list

2006-09-06 Thread Tony Plate
I suspect you are not thinking about the list and the 
subsetting/extraction operators in the right way.

A list contains a number of components.

To get a subset of the list, use the '[' operator.  The subset can 
contain zero or more components of the list, and it is a list itself. 
So, if x is a list, then x[2] is a list containing a single component.

To extract a component from the list, use the '[[' operator.  You can 
only extract one component at a time.  If you supply a vector index with 
more than one element, it will index recursively.

  x - list(1,2:3,letters[1:3])
  x
[[1]]
[1] 1

[[2]]
[1] 2 3

[[3]]
[1] a b c

  # a subset of the list
  x[2:3]
[[1]]
[1] 2 3

[[2]]
[1] a b c

  # a list with one component:
  x[2]
[[1]]
[1] 2 3

  # the second component itself
  x[[2]]
[1] 2 3
  # recursive indexing
  x[[c(2,1)]]
[1] 2
  x[[c(3,2)]]
[1] b
 

Rainer M Krug wrote:
 Hi
 
 I use the following code and it stores the results of density() in the
 list dr:
 
 dens - function(run) { density( positions$X[positions$run==run], bw=3,
 cut=-2 ) }
 dr - lapply(1:5, dens)
 
 but the results are stored in dr[[i]] and not dr[i], i.e. plot(dr[[1]])
 works, but plot([1]) doesn't.
 
 Is there any way that I can store them in dr[i]?
 
 Thanks a lot,
 
 Rainer
 
 


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


[R] deleting an arow added to a graphic

2006-09-06 Thread Graham Smith
I know this has got to be simple, but I have a added  an arrow to a graph
with:

arrows(5,8,8, predict(lmfit,data.frame(x=8)), length=0.1)

but its in the wrong position, correcting it and running again adds an new
arrow (which is what you would expect) so how do I

a) edit the existing arrow, and
b) delete it all together

As so often seems to be the case, some of the simplist things seem also to
be the most difficult to find the answer to.

Many thanks,

Graham

[[alternative HTML version deleted]]

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


Re: [R] deleting an arow added to a graphic

2006-09-06 Thread Duncan Murdoch
On 9/6/2006 3:04 PM, Graham Smith wrote:
 I know this has got to be simple, but I have a added  an arrow to a graph
 with:
 
 arrows(5,8,8, predict(lmfit,data.frame(x=8)), length=0.1)
 
 but its in the wrong position, correcting it and running again adds an new
 arrow (which is what you would expect) so how do I
 
 a) edit the existing arrow, and
 b) delete it all together
 
 As so often seems to be the case, some of the simplist things seem also to
 be the most difficult to find the answer to.
 

Generally classic graphics in R are like drawing in ink on paper:  you 
can't remove items that you've drawn there.

So the way to do what you want is to save the commands that produced the 
  entire graph, and edit them until you get them right.  Then you can 
run them and produce a new graph that's just right.

grid allows items to be removed from an existing graph, so lattice and 
ggplot inherit this nice property.  rgl (for 3d graphics) also allows 
items to be removed in a fairly inflexible way (only in the reverse 
order of the order drawn); the next release will make this more flexible.

Duncan Murdoch

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


Re: [R] deleting an arow added to a graphic

2006-09-06 Thread Gabor Grothendieck
This does not actually remove it but you could overwrite it with
an arrow the same color as the background and then plot a
new arrow:

x - 1:10
plot(x ~ x)
arrows(1, 1, 2, 2)

# revise it
arrows(1, 1, 2, 2, col = white)
arrows(2, 2, 3, 3)


On 9/6/06, Graham Smith [EMAIL PROTECTED] wrote:
 I know this has got to be simple, but I have a added  an arrow to a graph
 with:

 arrows(5,8,8, predict(lmfit,data.frame(x=8)), length=0.1)

 but its in the wrong position, correcting it and running again adds an new
 arrow (which is what you would expect) so how do I

 a) edit the existing arrow, and
 b) delete it all together

 As so often seems to be the case, some of the simplist things seem also to
 be the most difficult to find the answer to.

 Many thanks,

 Graham

[[alternative HTML version deleted]]

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


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


Re: [R] continuation lines in R script files

2006-09-06 Thread Mike Meyer
I literally copy/pasted your second version (without the + signs) in a file
and the sourced that file.  It loaded without error and the a matrix was
as I expected.

On 9/6/06, Evan Cooch [EMAIL PROTECTED] wrote:

 When I have to enter a very large matrix into the R console, I can make
 use of the continuation feature in the console to enter the matrix in
 pieces (e.g.,  on a row by row basis). So, for example, the console
 would show the + sign for continuation lines - something like what
 I've written below:

 a=matrix(c(0,20,50,
 +  0.05,0,0,
 + 0,0.1,0),
 + 3,3,byrow=T)

 (obviously, for a matrix this small - 3x3 - I could enter it all on a
 single line, this is just to demonstrate)

 My question is - how do you accomplish the same thing in an R script
 file? I've tried literally copying the preceding - syntax error at the
 second line. I've also tried


 a=matrix(c(0,20,50,
 0.05,0,0,
 0,0.1,0),
 3,3,byrow=T)

 Again, syntax error, at the second line...

 After multiple searches for 'continuation line', with no luck
 (everything I found refers to the R console, no a script file), I'll ask
 here. Basically, I want to know how to get an R script to handle a
 structure entered over multiple lines (e.g., a matrix). This is default
 behaviour in .m files in Matlab, and most other environments I've ever
 worked in (e.g., SAS looks for the ; to indicate end of a line).

 Thanks in advance...

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




-- 

Mike Meyer, Seattle WA

[[alternative HTML version deleted]]

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


Re: [R] continuation lines in R script files

2006-09-06 Thread Joris De Wolf
Are your sure your second solution does not work? Try again...

Evan Cooch wrote:
 When I have to enter a very large matrix into the R console, I can make 
 use of the continuation feature in the console to enter the matrix in 
 pieces (e.g.,  on a row by row basis). So, for example, the console 
 would show the + sign for continuation lines - something like what 
 I've written below:
 
 a=matrix(c(0,20,50,
 +  0.05,0,0,
 + 0,0.1,0),
 + 3,3,byrow=T)
 
 (obviously, for a matrix this small - 3x3 - I could enter it all on a 
 single line, this is just to demonstrate)
 
 My question is - how do you accomplish the same thing in an R script 
 file? I've tried literally copying the preceding - syntax error at the 
 second line. I've also tried
 
 
 a=matrix(c(0,20,50,
 0.05,0,0,
 0,0.1,0),
 3,3,byrow=T)
 
 Again, syntax error, at the second line...
 
 After multiple searches for 'continuation line', with no luck 
 (everything I found refers to the R console, no a script file), I'll ask 
 here. Basically, I want to know how to get an R script to handle a 
 structure entered over multiple lines (e.g., a matrix). This is default 
 behaviour in .m files in Matlab, and most other environments I've ever 
 worked in (e.g., SAS looks for the ; to indicate end of a line).
 
 Thanks in advance...
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


confidentiality notice:
The information contained in this e-mail is confidential and...{{dropped}}

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


Re: [R] About the Skew Student distribution

2006-09-06 Thread Ben Bolker
pierre clauss pierreclauss at yahoo.fr writes:

 
 Hello everybody,
 I need your help about the package SN and the skew student distribution. Il
will be very grateful if I have the solution.
 
 I construct a stochastic model with a white noise not gaussian but following a
skew student distribution. I
 fit the noise on monthly data to obtain the four parameters. The question is :
how to annualize the
 parameters to use my model for simulate daily data for example ? 
 
 If the volatility is estimated to 3 for example, I need to multiply this by
sqrt(12) to have for the parameter
 of volatility of the skew student : 3*sqrt(12)*sqrt(dt) with dt the time
increment parameter (1/12 for
 monthly data, 1/261 for daily data, and so on). Do I do the same thing (and
what is the multiplicative factor
 ?) for the parameters of asymmetry and the degree of freedom ?
 

  I'm not sure about your application, but I'll take a crack at it.
It sounds like you've got a continuous-time stochastic process (you
don't say explicitly).  For a Brownian motion, you would just do what
you suggest -- scale the variance by sqrt(dt) (I don't see exactly
why daily data have dt=1/261 -- although 365*5/7 = 261, so I guess
you're counting weekdays (trading days??) only).  Unfortunately, it's
not nearly as transparent (to me) what stochastic differential equation
would lead to aggregated data that were skew-Student.  The review
paper on Azzalini (SN's author)'s web site (
http://azzalini.stat.unipd.it/SN/review-web.ps ) cites some papers in
computational finance, which I'm guessing is your area -- your best
bet is probably to go back to those papers and see if they deal
with the effects of temporal aggregation.

  VERY crudely, you can just experiment with this yourself
by simulating values from a particular skew-Student distribution,
aggregating them, and then looking at the properties of the
resulting distribution -- *do* the asymmetry and df change?
(I bet they do -- in some sense temporal aggregation must lead
to a distribution that is more normal, larger df and smaller
skew -- but reversing this could be quite ugly).

  good luck
   Ben Bolker
finance

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


[R] How to get multiple partial matches?

2006-09-06 Thread Sarah Tucker
Hi, 

I'm very new to R, and am not at all a software
programmer of any sort.I appreciate any help you
may have.  I have figured out how to get my data into
a dataframe and order it alphabetically according to a
particular column.  Now, I would like to seperate out
certain rows based on partial character matches.  Here
is an (extremely) abreviated example of my data set

Probe Ch1 Median - B Ch1 Mean - B
72 5S_F_1501  567
7700   5S_F_2338  611
7517   5S_F_3412  467
10687  5S_F_4380  428
4870   5S_F_5315  368
6035   5S_F_6300  359
3826   5S_F_7350  386
8754   5S_F_8450  473
6399   5S_F_9439  494
749   5S_F_10334  384

I would like to be able to select out all rows with,
for example, 5S_F_ in the Probe column (there are
non-5S_F_ containing values in the real, larger data
set).

I think pmatch does this for instances where there is
only 1 match, but I would like to recover all the
matches.  I have tried to use charmatch, match,
pmatch, agrep and grep for this purpose, but with no
luck.

When I grep for 5S_F_ with value = T, I get
character(0)
Adding wildcards (either * or .) does not change
this outcome.

I thought maybe the underscores were messing it up, so
I tried to grep 5S* with value = T, and I get a long
list of numbers back

[1] 55   95   56   57   58   59   65  
75   85   105 
  [11] 115  125  135  5555  
 555  

These numbers make no sense to me.  They don't seem to
correlate with where the 5S's occur in the
dataframe, and they don't look like any values in the
Probe column (there are no numeric vaules in the Probe
column, just strings of character digit combinations).

How can I select out all the rows with the same
partial character match?

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


Re: [R] How to get multiple partial matches?

2006-09-06 Thread jim holtman
Try using 'grep' and regular expressions:

 x - 72 5S_F_1501  567
+ 7700   5S_F_2338  611
+ 7517   5S_F_3412  467
+ 10687  5S_F_4380  428
+ 4870   5S_F_5315  368
+ 6035   5S_F_6300  359
+ 3826   5S_F_7350  386
+ 8754   5S_F_8450  473
+ 6399   5S_F_9439  494
+ 749   5S_F_10334  384
+ 
 df - read.table(textConnection(x))
 df
  V1  V2  V3  V4
1 72  5S_F_1 501 567
2   7700  5S_F_2 338 611
3   7517  5S_F_3 412 467
4  10687  5S_F_4 380 428
5   4870  5S_F_5 315 368
6   6035  5S_F_6 300 359
7   3826  5S_F_7 350 386
8   8754  5S_F_8 450 473
9   6399  5S_F_9 439 494
10   749 5S_F_10 334 384
 # select only ones with '5S_F_1'
 df[grep('5S_F_1', as.character(df$V2)),]
V1  V2  V3  V4
1   72  5S_F_1 501 567
10 749 5S_F_10 334 384




On 9/6/06, Sarah Tucker [EMAIL PROTECTED] wrote:
 Hi,

 I'm very new to R, and am not at all a software
 programmer of any sort.I appreciate any help you
 may have.  I have figured out how to get my data into
 a dataframe and order it alphabetically according to a
 particular column.  Now, I would like to seperate out
 certain rows based on partial character matches.  Here
 is an (extremely) abreviated example of my data set

Probe Ch1 Median - B Ch1 Mean - B
 72 5S_F_1501  567
 7700   5S_F_2338  611
 7517   5S_F_3412  467
 10687  5S_F_4380  428
 4870   5S_F_5315  368
 6035   5S_F_6300  359
 3826   5S_F_7350  386
 8754   5S_F_8450  473
 6399   5S_F_9439  494
 749   5S_F_10334  384

 I would like to be able to select out all rows with,
 for example, 5S_F_ in the Probe column (there are
 non-5S_F_ containing values in the real, larger data
 set).

 I think pmatch does this for instances where there is
 only 1 match, but I would like to recover all the
 matches.  I have tried to use charmatch, match,
 pmatch, agrep and grep for this purpose, but with no
 luck.

 When I grep for 5S_F_ with value = T, I get
 character(0)
 Adding wildcards (either * or .) does not change
 this outcome.

 I thought maybe the underscores were messing it up, so
 I tried to grep 5S* with value = T, and I get a long
 list of numbers back

 [1] 55   95   56   57   58   59   65
 75   85   105
  [11] 115  125  135  5555
  555

 These numbers make no sense to me.  They don't seem to
 correlate with where the 5S's occur in the
 dataframe, and they don't look like any values in the
 Probe column (there are no numeric vaules in the Probe
 column, just strings of character digit combinations).

 How can I select out all the rows with the same
 partial character match?

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



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

What is the problem you are trying to solve?

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


Re: [R] Help on estimated variance in lme4

2006-09-06 Thread Douglas Bates
Could you try this model fit again adding control = list(usePQL =
FALSE, msVerbose=TRUE) to the argument list of the call to lmer?  By
default PQL iterations are used at the beginning of a generalized
linear mixed model fit followed by optimization of the Laplace
approximation to the log-likelihood when method = Laplace.
Sometimes the PQL iterations do more harm than good and you do better
going straight to the optimization of the Laplace approximation.

On 9/6/06, jerome lemaitre [EMAIL PROTECTED] wrote:
 Dear all,

 I get an error message when I run my model and I am not sure what to do
 about it.

 I try to determine what factors influence the survival of voles. I use a
 mixed-model because I have several voles per site (varying from 2 to 19
 voles).

 Here is the model:
 ###
 fm5 -lmer(data=cdrgsaou2,
 alive~factor(pacut)+factor(agecamp)+factor(sex)+ResCondCorp+(1|factor(cdrgsa
 ou2$ids)),
 family=binomial,
 method=Laplace,
 )
 ###
 Description of variables
 Alive: 0 or 1; dead or alive
 pacut: 0 or 1; presence of parasites
 agecamp: a or j; adult or juvenile
 sex: m or f; male or female
 ResCondCorp: body condition, continuous;
 cdrgsaou2$ids: name of the site.


 Here is the output:

 ###
 Generalized linear mixed model fit using Laplace
 Formula: alive ~ factor(pacut) + factor(agecamp) + factor(sex) + ResCondCorp
 +  (1 | factor(cdrgsaou2$ids))
Data: cdrgsaou2
  Family: binomial(logit link)
   AIC  BIClogLik deviance
  305.7418 328.7331 -146.8709 293.7418
 Random effects:
  GroupsNameVariance Std.Dev.
  factor(cdrgsaou2$ids) (Intercept) 0.034382 0.18542
 number of obs: 341, groups: factor(cdrgsaou2$ids), 36

 Estimated scale (compare to 1)  2.174681

 Fixed effects:
   Estimate Std. Error z value  Pr(|z|)
 (Intercept)   0.971458   0.250951  3.8711 0.0001083 ***
 factor(pacut)1   -0.831888   0.358583 -2.3199 0.0203447 *
 factor(agecamp)j -1.294236   0.330638 -3.9144 9.065e-05 ***
 factor(sex)m  0.581713   0.296229  1.9637 0.0495616 *
 ResCondCorp  -0.176251   0.020263 -8.6982  2.2e-16 ***
 ---
 Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

 Correlation of Fixed Effects:
 (Intr) fct()1 fctr(g) fctr(s)
 factr(pct)1 -0.334
 fctr(gcmp)j -0.417  0.066
 factor(sx)m -0.505 -0.002 -0.173
 ResCondCorp -0.309 -0.010  0.302  -0.032
 ###

 Here is the error message:

 ###
 Warning message:
 Estimated variance for factor 'factor(cdrgsaou2$ids)' is effectively zero
  in: LMEopt(x = mer, value = cv)
 ###

 Thank you very much by advance for any help.



 Jérôme Lemaître


 Ph.D. student
 Silviculture-wildlife research chair in irregular boreal forests
  Départment of biology,
 Faculty of Sciences and Engineering
 Alexandre-Vachon building
 University Laval
 Quebec, QC  G1K 7P4
 Phone : (418) 656-2131 poste 2917
 Office : VCH-2044
 Email: [EMAIL PROTECTED]

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


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


Re: [R] Problem with Variance Components (and general glmm confusion)

2006-09-06 Thread Douglas Bates
On 9/4/06, Toby Gardner [EMAIL PROTECTED] wrote:
 Dear list,

 I am having some problems with extracting Variance Components from a 
 random-effects model:

 I am running a simple random-effects model using lme:

 model-lme(y~1,random=~1|groupA/groupB)

 which returns the output for the StdDev of the Random effects, and model AIC 
 etc as expected.

 Until yesterday I was using R v. 2.0, and had no problem in calling the 
 variance components of the above model using VarCorr(model), together with 
 their 95% confidence intervals using intervals() - although for some response 
 variables a call to intervals() returns the error: Cannot get confidence 
 intervals on var-cov components: Non-positive definite approximate 
 variance-covariance.

 I have now installed R v. 2.3.1 and am now experiencing odd behaviour with 
 VarCorr(lme.object), with an error message typically being returned:

 Error in VarCorr(model) : no direct or inherited method for function 
 'VarCorr' for this call

 Is this known to happen? For instance could it be due to the subsequent 
 loading of new packages? (lme4 for instance?).

Yes.  Avoid loading lme4 and nlme simultaneously.


 To get around this problem I have tried running the same model using lmer:

 model2-lmer(y~1 + (1|groupA) + (1|groupB))

In recent versions of lme4 you can use the specification

model2 - lmer(y ~ 1 + (1|groupA/groupB))

Your version may be correct or not.  It depends on what the distinct
levels of groupB correspond to.  The version with the / is more
reliable.


 Should this not produce the same model? The variance components are very 
 similar but not identical, making me think that I am doing something wrong. I 
 am also correct in thinking that intervals() does not work with lmer? I get: 
 Error in intervals(model2) : no applicable method for intervals

That is correct.  Currently there is no intervals method for an lmer
model.  You can use mcmcsamp to get a Markov chain Monte Carlo sample
to which you can apply HPDinterval from the coda package.  However,
these are stochastic intervals so it is best to try on a couple of
chains to check on the reproducibility or the intervals.


 GLMM

 I have a general application question - please excuse my ignorance, I am 
 relatively new to this and trying to find a way through the maze.  In short I 
 need to compile generalized linear mixed models both for (a) Poisson data and 
 (b) binonial data incorporating a two nested random factors, and I need to be 
 able to extract AIC values as I am taking an information-theoretic approach 
 to model selection.  Prior to sending an email to the list I have spent quite 
 a few days reading the background on a number of functions, all of which 
 offer potential for this; glmmML, glmmPQL, lmer, and glmmADMB.  I can 
 understand that glmmPQL is unsuitable because there is no way of knowing the 
 maximised likelihood, but is there much difference between the remaining 
 three options? I have seen simulation comparisons published on this list 
 between glmmADMB and glmmPQL and lmer, but it seems these are before the 
 latest release of lmer, and also they do not evaluate glmmML.  To a newcomer 
 this myria!
 d !
  of options is bewildering, can anyone offer advice as to the most robust 
 approach?

Goran can correct me if I am wrong but I don't believe that glmmML can
be used with multiple levels of random effects.

I'm not sure what the status of glmmADMB is these days.  There was
some controversy regarding the license applied to some of that code a
while back.  I don't know if it has been resolved to everyone's
satisfaction.

When using lmer I would suggest using method = Laplace and perhaps
control = list(usePQL = FALSE, msVerbose = 1) as I mentioned in
another reply to the list a few minutes ago.

Let us know how it works out.


 Many thanks for your time and patience,

 Toby Gardner

 School of Environmental Sciences
 University of East Anglia
 Norwich, NR4 7TJ
 United Kingdom
 Email: [EMAIL PROTECTED]
 Website: www.uea.ac.uk/~e387495

 [[alternative HTML version deleted]]

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


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


[R] graphics - joining repeated measures with a line

2006-09-06 Thread Murray Pung
I would like to join repeated measures for patients across two visits using
a line. The program below uses symbols to represent each patient. Basically,
I would like to join each pair of symbols.



library(lattice)

patient - c(1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9)
var -
c(826,119,168,90,572,323,122,10,42,900,250,180,120,650,400,130,12,33)
visit - c(1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2)
symbols - c(1,2,3,4,5,6,7,8,9)

xyplot(var ~ visit, pch = symbols[patient], key = list(points = list(pch =
symbols), space = list(right),text =
list(c(1,2,3,4,5,6,7,8,9

# grid.lines(x = visit,y = var,draw = TRUE) ??

I am thinking I may need to use a function that joins coordinates (for
example join (1,826) with (2,900)), but am hoping there may be a better way.



Thanks for any help.

Murray


-- 
Murray Pung
Statistician, Datapharm Australia Pty Ltd
0404 273 283

[[alternative HTML version deleted]]

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


Re: [R] graphics - joining repeated measures with a line

2006-09-06 Thread Gabor Grothendieck
Make each pair of points a separate group using group= and specify
that both points and lines be used via type = b.  Also set the
symbols in par.settings= so that they are accessed by both
the main plot and the legend:

xyplot(var ~ visit, group = symbols[patient], type = b,
   auto.key = list(space = right),
   par.settings = list(superpose.symbol = list(pch = symbols)))


On 9/6/06, Murray Pung [EMAIL PROTECTED] wrote:
 I would like to join repeated measures for patients across two visits using
 a line. The program below uses symbols to represent each patient. Basically,
 I would like to join each pair of symbols.



 library(lattice)

 patient - c(1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9)
 var -
 c(826,119,168,90,572,323,122,10,42,900,250,180,120,650,400,130,12,33)
 visit - c(1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2)
 symbols - c(1,2,3,4,5,6,7,8,9)

 xyplot(var ~ visit, pch = symbols[patient], key = list(points = list(pch =
 symbols), space = list(right),text =
 list(c(1,2,3,4,5,6,7,8,9

 # grid.lines(x = visit,y = var,draw = TRUE) ??

 I am thinking I may need to use a function that joins coordinates (for
 example join (1,826) with (2,900)), but am hoping there may be a better way.



 Thanks for any help.

 Murray


 --
 Murray Pung
 Statistician, Datapharm Australia Pty Ltd
 0404 273 283

[[alternative HTML version deleted]]

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


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


Re: [R] graphics - joining repeated measures with a line

2006-09-06 Thread Gabor Grothendieck
Just one correction (although in this case it does not change the
output) -- use group = patient rather than group = symbol[patient]:

xyplot(var ~ visit, group = patient, type = b, auto.key = list(space
= right),
   par.settings = list(superpose.symbol = list(pch = symbols)))


On 9/6/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
 Make each pair of points a separate group using group= and specify
 that both points and lines be used via type = b.  Also set the
 symbols in par.settings= so that they are accessed by both
 the main plot and the legend:

 xyplot(var ~ visit, group = symbols[patient], type = b,
   auto.key = list(space = right),
   par.settings = list(superpose.symbol = list(pch = symbols)))


 On 9/6/06, Murray Pung [EMAIL PROTECTED] wrote:
  I would like to join repeated measures for patients across two visits using
  a line. The program below uses symbols to represent each patient. Basically,
  I would like to join each pair of symbols.
 
 
 
  library(lattice)
 
  patient - c(1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9)
  var -
  c(826,119,168,90,572,323,122,10,42,900,250,180,120,650,400,130,12,33)
  visit - c(1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2)
  symbols - c(1,2,3,4,5,6,7,8,9)
 
  xyplot(var ~ visit, pch = symbols[patient], key = list(points = list(pch =
  symbols), space = list(right),text =
  list(c(1,2,3,4,5,6,7,8,9
 
  # grid.lines(x = visit,y = var,draw = TRUE) ??
 
  I am thinking I may need to use a function that joins coordinates (for
  example join (1,826) with (2,900)), but am hoping there may be a better way.
 
 
 
  Thanks for any help.
 
  Murray
 
 
  --
  Murray Pung
  Statistician, Datapharm Australia Pty Ltd
  0404 273 283
 
 [[alternative HTML version deleted]]
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 


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


[R] stratified poisson regression

2006-09-06 Thread Hannah Murdoch
Hello,

I'm fitting poisson regression to mortality data and wish to stratify by age.
Is there any way to perform this stratification and use the glm function in R?

Thanks,
Hannah Murdoch

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