Re: [R] a book recommendation, please [O/T]

2016-11-08 Thread Simon Blomberg
How about Cox and Reid (2000) The Theory of the Design of Experiments. 
It has S-PLUS code in the back, which should pretty much work with R.



On 08/11/16 22:24, Spencer Graves wrote:
  Have you considered Box and Draper (2007) Response Surfaces, 
Mixtures, and Ridge Analyses, 2nd Edition?



  You probably know that George Box invented the field of Response 
Surfaces with  Box, G. E. P. and Wilson, K.B. (1951) On the 
Experimental Attainment of Optimum Conditions (with discussion). 
Journal of the Royal Statistical Society Series B13(1):1–45.



  This book describes how to design experiments to get the data to 
optimize a physical process.  I haven't been teaching in academia for 
the past 25 years, but I taught an advanced course from the first 
edition of this book when I did.



  Still, any title "with R" sounds like it's worth reviewing and 
maybe using.



   Spencer Graves


On 11/8/2016 12:36 AM, Erin Hodgess wrote:

I like BH^2 as well as a reference book! I actually think I will go with
the DOE with R by Larson.  Thanks to all for the help!

Sincerely,
Erin


On Mon, Nov 7, 2016 at 10:59 PM, Bert Gunter  
wrote:



Have you looked here:

https://www.amazon.com/s/ref=sr_pg_2?rh=n%3A283155%2Ck%
3Aexperimental+design&page=2&keywords=experimental+design&
ie=UTF8&qid=1478580868

I would think your choice depends strongly on the arena of application.

Of course I like BH^2, but that was because I was taught by them.

Cheers,
Bert
Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Mon, Nov 7, 2016 at 8:13 PM, Erin Hodgess 
wrote:

Hello!

Could someone recommend a good book on Design of Experiments for a

Master's

in Data Analytics, please?

I use Montgomery's book for my undergrad course, but was thinking 
about

something a little more advanced for this one.

Any help much appreciated, particularly with R-related texts.

Sincerely,
Erin


--
Erin Hodgess
Associate Professor
Department of Mathematical and Statistics
University of Houston - Downtown
mailto: erinm.hodg...@gmail.com

 [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


--
Simon Blomberg, BSc (Hons), PhD, MAppStat, AStat.
Senior Lecturer and Consultant Statistician
School of Biological Sciences
The University of Queensland
St. Lucia Queensland 4072
Australia
T: +61 7 3365 2506
email: S.Blomberg1_at_uq.edu.au
http://www.evolutionarystatistics.org

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

Basically, I'm not interested in doing research and
I never have been. I'm interested in understanding,
which is quite a different thing. And often to
understand something you have to work it out
for yourself because no one else has done it.
- David Blackwell

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] APE

2015-03-09 Thread Simon Blomberg

It's hard to tell what you did exactly. Did you do:

mytree <- compute.brlen(mytree)

? That should have worked. I've cc'ed this message to r-sig-phylo, which 
is the more appropriate forum.


Cheers,

Simon.

On 10/03/15 07:05, Beth Williams wrote:

Dear All,


I am having some trouble with R and would be extremely grateful if anyone has a way around this. I have loaded a nexus 
tree from PAUP into R using the command read.nexus and this loaded,  it was reported as "rooted; with no branch 
lengths". I then used the command "compute.brlen(mytree)" to compute the branch lengths and this was 
reported as "rooted; includes branch lengths". I added my community data (samp) and then tried to compute the 
phylogenetic diversity with the command "> pd(samp, mytree, include.root=TRUE)" however it said it could not 
calculate the PD as there were no branch lengths. Is there a way to incorporate the branch lengths into the calculation 
for PD?


Thanks for your time,

Beth

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


--
Simon Blomberg, BSc (Hons), PhD, MAppStat, AStat.
Senior Lecturer and Consultant Statistician
School of Biological Sciences
The University of Queensland
St. Lucia Queensland 4072
Australia
T: +61 7 3365 2506
email: S.Blomberg1_at_uq.edu.au
http://www.evolutionarystatistics.org

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

Basically, I'm not interested in doing research
and I never have been. I'm interested in
understanding, which is quite a different thing.
- David Blackwell

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Building R for better performance

2014-09-01 Thread Simon Blomberg

Is MKL open source software? If not, that could be the sticking point.

Simon.

On 02/09/14 07:24, lejeczek wrote:
could you tell us if the same/similar performance benefits we should 
expect when gnu complier suite + MKL are teamed up?

and how to configure such a compilation?
many thanks

On 04/03/14 21:44, Anspach, Jonathan P wrote:

Greetings,

I'm a software engineer with Intel.  Recently I've been investigating 
R performance on Intel Xeon and Xeon Phi processors and RH Linux.  
I've also compared the performance of R built with the Intel 
compilers and Intel Math Kernel Library to a "default" build (no 
config options) that uses the GNU compilers.  To my dismay, I've 
found that the GNU build always runs on a single CPU core, even 
during matrix operations.  The Intel build runs matrix operations on 
multiple cores, so it is much faster on those operations.  Running 
the benchmark-2.5 on a 24 core Xeon system, the Intel build is 13x 
faster than the GNU build (21 seconds vs 275 seconds).  
Unfortunately, this advantage is not documented anywhere that I can see.


Building with the Intel tools is very easy.  Assuming the tools are 
installed in /opt/intel/composerxe, the process is simply (in bash 
shell):


$ . /opt/intel/composerxe/bin/compilervars.sh intel64
$ ./configure --with-blas="-L/opt/intel/composerxe/mkl/lib/intel64 
-lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread -lm" 
--with-lapack CC=icc CFLAGS=-O2 CXX=icpc CXXFLAGS=-O2 F77=ifort 
FFLAGS=-O2 FC=ifort FCFLAGS=-O2

$ make
$ make check

My questions are:
1) Do most system admins and/or R installers know about this 
performance difference, and use the Intel tools to build R?
2) Can we add information on the advantage of building with the Intel 
tools, and how to do it, to the installation instructions and FAQ?


I can post my data if anyone is interested.

Thanks,
Jonathan Anspach
Sr. Software Engineer
Intel Corp.
jonathan.p.ansp...@intel.com
713-751-9460

__
R-help@r-project.org 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@r-project.org 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.


--
Simon Blomberg, BSc (Hons), PhD, MAppStat, AStat.
Senior Lecturer and Consultant Statistician
School of Biological Sciences
The University of Queensland
St. Lucia Queensland 4072
Australia
T: +61 7 3365 2506
email: S.Blomberg1_at_uq.edu.au
http://www.evolutionarystatistics.org

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

Statistics is the grammar of science - Karl Pearson.

__
R-help@r-project.org 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] Population growthrate with Euler-Lotka

2014-06-30 Thread Simon Blomberg
There may be something wrong with your data: in all but one case you have lx=1 
and mx=0. Uniroot may be having difficulty because of this.

Simon.

Sent from my iPhone

> On 30 Jun 2014, at 9:09 pm, "Simon Blomberg"  wrote:
> 
> Hmm. Try setting extendInt="yes" in the call to uniroot. You should also look 
> at the help page for uniroot. help(uniroot) May give you a clue. It's 
> difficult for me to debug code on my iphone. Well, more difficult than usual.
> 
> Best,
> 
> Simon.
> 
> Sent from my iPhone
> 
> On 30 Jun 2014, at 8:53 pm, "Mark Christjani" 
> mailto:m_christj...@gmx.de>> wrote:
> 
> Thank you, Simon, for your input.
> 
> Data import works fine now, but the final equation still won`t work.
> 
> Console reads now:
> 
>> setwd("c:/Mark")
>> 
>> table <- read.table("r-TCO-Scene-Kontrolle.csv", header=TRUE, sep=";")
>> 
>> table
>x  lx  mx
> 1   1 1.0 0.0
> 2   2 1.0 0.0
> 3   3 1.0 0.0
> 4   4 1.0 0.0
> 5   5 1.0 0.0
> 6   6 1.0 0.0
> 7   7 1.0 0.0
> 8   8 1.0 0.0
> 9   9 1.0 0.0
> 10 10 1.0 0.0
> 11 11 0.2 3.5
>> 
>> x <- c(table$x)
>> L <- c(table$lx)
>> m <- c(table$mx)
>> r.range<- c(0, 5)
>> 
>> eulerlotka <- function(r) sum(L * m * exp(-r * x)) - 1
>> res <- uniroot(f = eulerlotka, interval = r.range, tol = 1e-8)
> Error in uniroot(f = eulerlotka, interval = r.range, tol = 1e-08) :
>  f() values at end points not of opposite sign
>> 
>> res$root
> Error: object 'res' not found
> 
> Any idea on this "Error in uniroot(f = eulerlotka, interval = r.range, tol = 
> 1e-08) :
>  f() values at end points not of opposite sign"-matter?
> 
> Kind regards,
> Mark
> 
> 
> 
> Gesendet: Montag, 30. Juni 2014 um 12:41 Uhr
> Von: "Simon Blomberg" mailto:s.blombe...@uq.edu.au>>
> An: "Mark Christjani" mailto:m_christj...@gmx.de>>
> Cc: "r-help@r-project.org<mailto:r-help@r-project.org>" 
> mailto:r-help@r-project.org>>
> Betreff: Re: [R] Population growthrate with Euler-Lotka
> Your script is failing at the first hurdle because you data are not being 
> imported properly. You should include
> 
> header=TRUE. sep=";"
> 
> In the call to read.table.
> 
> Cheers.
> 
> Simon.
> 
> Sent from my iPhone
> 
> Sent from my iPhone
>> On 30 Jun 2014, at 7:10 pm, "Mark Christjani" 
>> mailto:m_christj...@gmx.de>> wrote:
>> 
>> 
>> Hi everybody,
>> 
>> I`m Mark and I do my PhD in biology. I try using R to calculate a population
>> growth rate of animals grown on different types of food. Our workgroup has a
>> R-skript to do so, but sadly nobody, who knows how this works. I`ve never
>> used R before, but got some stuff figured out myself. The skript goes:
>> 
>> setwd("c:/Mark")
>> table <- read.table("r-TCO-Scene-Kontrolle.csv")
>> table
>> x <- c(table$x)
>> L <- c(table$lx)
>> m <- c(table$mx)
>> r.range<- c(0, 5)
>> eulerlotka <- function(r) sum(L * m * exp(-r * x)) - 1
>> res <- uniroot(f = eulerlotka, interval = r.range, tol = 1e-8)
>> res$root
>> 
>> I understood that the first 3 lines are simply to load my data and show it
>> in the workspace console. The next 4 lines define variables of my .csv table
>> for R. Thus far, everything works fine. Now comes the Euler-Lotka equation,
>> but somehow, this does not seem to work out as supposed. I tried to find a
>> solution on the internet, but I think this formula is somewhat special so I
>> could not find a suitible solution for my special problem. The console says:
>> 
>> 
>>> setwd("c:/Mark")
>>> 
>>> table <- read.table("r-TCO-Scene-Kontrolle.csv")
>>> 
>>> table
>> V1
>> 1 x;lx;mx
>> 2 1;1;0
>> 3 2;1;0
>> 4 3;1;0
>> 5 4;1;0
>> 6 5;1;0
>> 7 6;1;0
>> 8 7;1;0
>> 9 8;1;0
>> 10 9;1;0
>> 11 10;1;0
>> 12 11;0.2;3.5
>>> 
>>> x <- c(table$x)
>>> L <- c(table$lx)
>>> m <- c(table$mx)
>>> r.range<- c(0, 5)
>>> 
>>> eulerlotka <- function(r) sum(L * m * exp(-r * x)) - 1
>>> res <- uniroot(f = eulerlotka, interval = r.range, tol = 1e-8)
>> Error in uniroot(f = eulerlotka, interval = r.range, tol = 1e-08) :
>> f() values at end points not of opposite sign
>>> 
>>> res$root
>> 
>> Does anybody have an idea how t

Re: [R] Population growthrate with Euler-Lotka

2014-06-30 Thread Simon Blomberg
Hmm. Try setting extendInt="yes" in the call to uniroot. You should also look 
at the help page for uniroot. help(uniroot) May give you a clue. It's difficult 
for me to debug code on my iphone. Well, more difficult than usual.

Best,

Simon.

Sent from my iPhone

On 30 Jun 2014, at 8:53 pm, "Mark Christjani" 
mailto:m_christj...@gmx.de>> wrote:

Thank you, Simon, for your input.

Data import works fine now, but the final equation still won`t work.

Console reads now:

> setwd("c:/Mark")
>
> table <- read.table("r-TCO-Scene-Kontrolle.csv", header=TRUE, sep=";")
>
> table
x  lx  mx
1   1 1.0 0.0
2   2 1.0 0.0
3   3 1.0 0.0
4   4 1.0 0.0
5   5 1.0 0.0
6   6 1.0 0.0
7   7 1.0 0.0
8   8 1.0 0.0
9   9 1.0 0.0
10 10 1.0 0.0
11 11 0.2 3.5
>
> x <- c(table$x)
> L <- c(table$lx)
> m <- c(table$mx)
> r.range<- c(0, 5)
>
> eulerlotka <- function(r) sum(L * m * exp(-r * x)) - 1
> res <- uniroot(f = eulerlotka, interval = r.range, tol = 1e-8)
Error in uniroot(f = eulerlotka, interval = r.range, tol = 1e-08) :
  f() values at end points not of opposite sign
>
> res$root
Error: object 'res' not found

Any idea on this "Error in uniroot(f = eulerlotka, interval = r.range, tol = 
1e-08) :
  f() values at end points not of opposite sign"-matter?

Kind regards,
Mark



Gesendet: Montag, 30. Juni 2014 um 12:41 Uhr
Von: "Simon Blomberg" mailto:s.blombe...@uq.edu.au>>
An: "Mark Christjani" mailto:m_christj...@gmx.de>>
Cc: "r-help@r-project.org<mailto:r-help@r-project.org>" 
mailto:r-help@r-project.org>>
Betreff: Re: [R] Population growthrate with Euler-Lotka
Your script is failing at the first hurdle because you data are not being 
imported properly. You should include

header=TRUE. sep=";"

In the call to read.table.

Cheers.

Simon.

Sent from my iPhone

Sent from my iPhone
> On 30 Jun 2014, at 7:10 pm, "Mark Christjani" 
> mailto:m_christj...@gmx.de>> wrote:
>
>
> Hi everybody,
>
> I`m Mark and I do my PhD in biology. I try using R to calculate a population
> growth rate of animals grown on different types of food. Our workgroup has a
> R-skript to do so, but sadly nobody, who knows how this works. I`ve never
> used R before, but got some stuff figured out myself. The skript goes:
>
> setwd("c:/Mark")
> table <- read.table("r-TCO-Scene-Kontrolle.csv")
> table
> x <- c(table$x)
> L <- c(table$lx)
> m <- c(table$mx)
> r.range<- c(0, 5)
> eulerlotka <- function(r) sum(L * m * exp(-r * x)) - 1
> res <- uniroot(f = eulerlotka, interval = r.range, tol = 1e-8)
> res$root
>
> I understood that the first 3 lines are simply to load my data and show it
> in the workspace console. The next 4 lines define variables of my .csv table
> for R. Thus far, everything works fine. Now comes the Euler-Lotka equation,
> but somehow, this does not seem to work out as supposed. I tried to find a
> solution on the internet, but I think this formula is somewhat special so I
> could not find a suitible solution for my special problem. The console says:
>
>
>> setwd("c:/Mark")
>>
>> table <- read.table("r-TCO-Scene-Kontrolle.csv")
>>
>> table
> V1
> 1 x;lx;mx
> 2 1;1;0
> 3 2;1;0
> 4 3;1;0
> 5 4;1;0
> 6 5;1;0
> 7 6;1;0
> 8 7;1;0
> 9 8;1;0
> 10 9;1;0
> 11 10;1;0
> 12 11;0.2;3.5
>>
>> x <- c(table$x)
>> L <- c(table$lx)
>> m <- c(table$mx)
>> r.range<- c(0, 5)
>>
>> eulerlotka <- function(r) sum(L * m * exp(-r * x)) - 1
>> res <- uniroot(f = eulerlotka, interval = r.range, tol = 1e-8)
> Error in uniroot(f = eulerlotka, interval = r.range, tol = 1e-08) :
> f() values at end points not of opposite sign
>>
>> res$root
>
> Does anybody have an idea how to get this running?
>
> Thanks in advance
>
> Kind regards
> Mark
> __
> R-help@r-project.org<mailto:R-help@r-project.org> 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.

[[alternative HTML version deleted]]

__
R-help@r-project.org 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] Population growthrate with Euler-Lotka

2014-06-30 Thread Simon Blomberg
Your script is failing at the first hurdle because you data are not being 
imported properly. You should include

header=TRUE. sep=";"

In the call to read.table.

Cheers.

Simon.

Sent from my iPhone

Sent from my iPhone
> On 30 Jun 2014, at 7:10 pm, "Mark Christjani"  wrote:
> 
> 
>   Hi everybody,
> 
>   I`m Mark and I do my PhD in biology. I try using R to calculate a population
>   growth rate of animals grown on different types of food. Our workgroup has a
>   R-skript to do so, but sadly nobody, who knows how this works. I`ve never
>   used R before, but got some stuff figured out myself. The skript goes:
> 
>   setwd("c:/Mark")
>   table <- read.table("r-TCO-Scene-Kontrolle.csv")
>   table
>   x <- c(table$x)
>   L <- c(table$lx)
>   m <- c(table$mx)
>   r.range<- c(0, 5)
>   eulerlotka <- function(r) sum(L * m * exp(-r * x)) - 1
>   res <- uniroot(f = eulerlotka, interval = r.range, tol = 1e-8)
>   res$root
> 
>   I understood that the first 3 lines are simply to load my data and show it
>   in the workspace console. The next 4 lines define variables of my .csv table
>   for R. Thus far, everything works fine. Now comes the Euler-Lotka equation,
>   but somehow, this does not seem to work out as supposed. I tried to find a
>   solution on the internet, but I think this formula is somewhat special so I
>   could not find a suitible solution for my special problem. The console says:
> 
> 
>> setwd("c:/Mark")
>> 
>> table <- read.table("r-TCO-Scene-Kontrolle.csv")
>> 
>> table
>  V1
>   1 x;lx;mx
>   2   1;1;0
>   3   2;1;0
>   4   3;1;0
>   5   4;1;0
>   6   5;1;0
>   7   6;1;0
>   8   7;1;0
>   9   8;1;0
>   10  9;1;0
>   11 10;1;0
>   12 11;0.2;3.5
>> 
>> x <- c(table$x)
>> L <- c(table$lx)
>> m <- c(table$mx)
>> r.range<- c(0, 5)
>> 
>> eulerlotka <- function(r) sum(L * m * exp(-r * x)) - 1
>> res <- uniroot(f = eulerlotka, interval = r.range, tol = 1e-8)
>   Error in uniroot(f = eulerlotka, interval = r.range, tol = 1e-08) :
> f() values at end points not of opposite sign
>> 
>> res$root
> 
>   Does anybody have an idea how to get this running?
> 
>   Thanks in advance
> 
>   Kind regards
>   Mark
> __
> R-help@r-project.org 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@r-project.org 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] Lamperti trnasformation simulation.

2014-05-18 Thread Simon Blomberg

On 17/05/14 19:10, Xuse Chuse wrote:

Dear users,

I am trying to simulate a Lamperti transformation of a brownian motion:
W(e_t). Could anyone give some clue how to do it? Thank you beforehand.

Regards,
C.

[[alternative HTML version deleted]]

__
R-help@r-project.org 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.

See package sde, and Stefano Iacus' excellent book.

Simon.

--
Simon Blomberg, BSc (Hons), PhD, MAppStat, AStat.
Lecturer and Consultant Statistician
School of Biological Sciences
The University of Queensland
St. Lucia Queensland 4072
Australia
T: +61 7 3365 2506
email: S.Blomberg1_at_uq.edu.au
http://www.evolutionarystatistics.org

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

Statistics is the grammar of science - Karl Pearson.

__
R-help@r-project.org 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] BIOENV

2013-05-05 Thread Simon Blomberg
This is a PRIMER question, not an R question. Please take it up with the 
PRIMER support people. R-helpers cannot be expected to know how other, 
closed-source, software works.


Cheers,

Simon.

On 06/05/13 12:34, Gilson Carvalho wrote:

Dear all,

Does anyone knows why the results of a BIOENV (PRIMER v. 6.1.15) are
diferent of the bioenv() + mantel() in vegan? Not the spearman correlation,
indeed the pseudo-p value.

I know that the approach bioenv() + mantel() is biased. So, how the BIOENV
(PRIMER) ends with larger p values (permutated).

Acctualy how the permutation test in BIOENV (PRIMER) is conducted. The user
guide does not make it clear.

Best Wishes,



--
Simon Blomberg, BSc (Hons), PhD, MAppStat, AStat.
Lecturer and Consultant Statistician
School of Biological Sciences
The University of Queensland
St. Lucia Queensland 4072
Australia
T: +61 7 3365 2506
email: S.Blomberg1_at_uq.edu.au
http://www.evolutionarystatistics.org

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

Statistics is the grammar of science - Karl Pearson.

__
R-help@r-project.org 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] Conditional Statistics

2013-01-07 Thread Simon Blomberg
You can use the tapply function to do this. You can't type a line into 
the mean statement. (See ?mean for what you can type in there). The 
general approach is to have a vector of data (stock prices) and a 
categorical variable (day of week). Then break up the data vector 
according to the levels in the categorical variable, and calculate the 
mean values:


Weekmeans <- tapply(data.vector, catvariable, mean)

This will give you the means for all days. If you really just want one 
mean (just monday), you could do:


Monmean <- mean(data.vector[catvariable=="Monday"])

Similarly, if you want the standard deviation for each day of the week, 
you would use:


WeekSD <- tapply(data.vector, catvariable, sd)
MonSD <- sd(data.vector[catvariable=="Monday"])

You will find that some things that are easy in SAS require a little 
more thought in R, and vice versa. Certainly, the philosophical approach 
to data analysis in R is different to that in SAS. There are a couple of 
books for R for SAS users. They might help you.


Cheers,

Simon.

On 08/01/13 11:17, Joseph Norman Thomson wrote:

Hello,

I am a new user of R. I am coming from SAS and do statistics on stock
market data, economic data, and social data. My question is this: How
can you get the mean, standard dev, etc. of a variable based on a
conditional statement on either the same variable or a different
variable in the same data set? So if I had the closing prices of the
S&P from 01/01/1990-12/31/1990, how could I get the average price of
the S&P from 02/01/1990-03/15/1990? Or the average price of the S&P on
Mondays (assuming a dummy var is created for 1 = Monday, 0 = else). I
understand that you can create subsets and new data sets based on the
conditional statements; but is there an easier way to do this by
typing a line into the mean() statement? That was extremely easy in
SAS where you could say:

proc means data=sp500;
var price;
where monday = 1;

Thank you for your help.

Joe

__
R-help@r-project.org 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.


--
Simon Blomberg, BSc (Hons), PhD, MAppStat, AStat.
Lecturer and Consultant Statistician
School of Biological Sciences
The University of Queensland
St. Lucia Queensland 4072
Australia
T: +61 7 3365 2506
email: S.Blomberg1_at_uq.edu.au
http://www.evolutionarystatistics.org

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

Statistics is the grammar of science - Karl Pearson.

__
R-help@r-project.org 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 generate response variables using simple regression

2012-08-26 Thread Simon Blomberg
Hi Elaine,

It's perfectly OK to develop regression models that predict wing data 
based on body mass. One problem that you should address is the degree of 
correlation among the data due to shared evolutionary history. 5 species 
is too small a sample to check for phylogenetic "signal" in your data 
(rule of thumb is about 20 spp. are necessary). One way would be to 
continue to ignore phylogenetic correlations, and use lm(). A better way 
would be to include estimates of the phylogenetic correlations in the 
analysis, using a Brownian motion model, and a known phylogeny. You can 
use the gls() function  in package nlme for this. However, if you use 
the predict() function on a gls object, you will still only get 
predictions assuming the new species are independent of all the others. 
If your new species are nested within the phylogeny of the original 5 
species, you need to make some adjustments to your predictions. See

Garland, T., Jr., and A. R. Ives. 2000. Using the past to predict the 
present: Confidence intervals for regression equations in phylogenetic 
comparative methods. American Naturalist 155:346-364.

Another problem that you might encounter is multiple measurements (on 
different individuals) per species. See:

Ives, A. R., P. E. Midford, and T. Garland, Jr. 2007. Within-species 
variation and measurement error in phylogenetic comparative methods. 
Systematic Biology 56:252-270

You should also check out the book by Emmanuel Paradis: 
http://ape.mpl.ird.fr/APER.html

There are numerous other references in this field, but these will get 
you most of the way. Also, the r-sig-phylo email list can be of assistance.

Cheers,

Simon.

On 27/08/12 12:46, R. Michael Weylandt wrote:
> Hi Elaine,
>
> As posed, your question is rather difficult to respond to properly.
> I'd imagine the answer is the predict() function, but you'll probably
> want to rephrase if that's not enough to get what you want. What
> worries me is that I would be inclined to model your bird species as
> categorical variables (or perhaps use mixed models) so I'm not sure
> it's valid to extrapolate to different species.
>
> As far as asking questions in a technical forum goes, here are two
> helpful general links:
>
> www.catb.org/esr/faqs/smart-questions.html
> http://mattgemmell.com/2008/12/08/what-have-you-tried/
>
> and some R specific advice here:
> http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
>
> Cheers,
> Michael
>
> On Sun, Aug 26, 2012 at 9:33 PM, Elaine Kuo  wrote:
>> Hello,
>>
>> I have weight and wing length data of 5 kinds of birds (B1 to B5).
>> Weight data (predictor) and wing data (response) were used to generated a
>> simple regression.
>> (using lm)
>>
>> Now some weight data are found but without wing data (B6, B7).
>> I want to use the generated simple regression to produce wing data of B6
>> and B7 by their weight data.
>> Please kindly advise R code to carry it out.
>> Thank you.
>>
>> Elaine
>>
>>  [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org 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@r-project.org 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.

-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat, AStat.
Lecturer and Consultant Statistician
School of Biological Sciences
The University of Queensland
St. Lucia Queensland 4072
Australia
T: +61 7 3365 2506
email: S.Blomberg1_at_uq.edu.au
http://www.uq.edu.au/~uqsblomb/

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

Statistics is the grammar of science - Karl Pearson.


[[alternative HTML version deleted]]

__
R-help@r-project.org 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] Can not find lme

2012-08-07 Thread Simon Blomberg

You loaded package lme4. The function lme is in package nlme. Try doing

library(nlme)

first.

Simon.

On 08/08/12 16:22, Santini Silvana wrote:

Dear all,
Can anyone help me, my R software can not run a nested linear regression by 
using the lme funcion. The message that appears isÂ
Error: could not find function "lme"
I already downloaded and loaded the package, please see below. Thank you in 
advance for any help! Nadia.


data<-read.csv("/Users/nadiasan1/Desktop/MOE and MOR.csv")> attach(data)> names(data)[1] "Species" "LME" Â  Â  
"LMR" Â  Â  "WD" Â  Â Â > install.packages("lme4")trying URL 
'http://cran.csiro.au/bin/macosx/leopard/contrib/2.14/lme4_0.999375-42.tgz'Content type 'application/x-gzip' length 1453067 bytes (1.4 Mb)opened 
URL==downloaded 1.4 Mb

The downloaded packages are in  
/var/folders/yx/l4kkhz8j24179y5vq0hp9md0gp/T//Rtmpqsa0o1/downloaded_packagesalso
 installing the dependencies ‘mlmRev’, ‘MEMSS’, ‘sfsmisc’, 
‘MatrixModels’
trying URL 
'http://cran.csiro.au/bin/macosx/leopard/contrib/2.14/mlmRev_1.0-1.tgz'Content 
type 'application/x-gzip' length 1832388 bytes (1.7 Mb)opened 
URL==downloaded 1.7 Mb
trying URL 
'http://cran.csiro.au/bin/macosx/leopard/contrib/2.14/MEMSS_0.9-0.tgz'Content 
type 'application/x-gzip' length 236762 bytes (231 Kb)opened 
URL==downloaded 231 Kb
trying URL 
'http://cran.csiro.au/bin/macosx/leopard/contrib/2.14/sfsmisc_1.0-19.tgz'Content
 type 'application/x-gzip' length 386160 bytes (377 Kb)opened 
URL==downloaded 377 Kb
trying URL 
'http://cran.csiro.au/bin/macosx/leopard/contrib/2.14/MatrixModels_0.3-1.tgz'Content
 type 'application/x-gzip' length 204787 bytes (199 Kb)opened 
URL==downloaded 199 Kb
trying URL 
'http://cran.csiro.au/bin/macosx/leopard/contrib/2.14/lme4_0.999375-42.tgz'Content
 type 'application/x-gzip' length 1453067 bytes (1.4 Mb)opened 
URL==downloaded 1.4 Mb

The downloaded packages are in  
/var/folders/yx/l4kkhz8j24179y5vq0hp9md0gp/T//Rtmpqsa0o1/downloaded_packagesLoading
 required package: MatrixLoading required package: lattice
Attaching package: ‘Matrix’
The following object(s) are masked from ‘package:base’:
    det

Attaching package: ‘lme4’
The following object(s) are masked from ‘package:stats’:
    AIC, BIC
starting httpd help server ... done> model1<-lme(LME~WD, random=~1|Species, ML)Error: 
could not find function "lme"


[[alternative HTML version deleted]]



--
Simon Blomberg, BSc (Hons), PhD, MAppStat, AStat.
Lecturer and Consultant Statistician
School of Biological Sciences
The University of Queensland
St. Lucia Queensland 4072
Australia
T: +61 7 3365 2506
email: S.Blomberg1_at_uq.edu.au
http://www.uq.edu.au/~uqsblomb/

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

Statistics is the grammar of science - Karl Pearson.

__
R-help@r-project.org 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] Graph showing fitted values obtained by binomial GLM

2012-07-05 Thread Simon Blomberg
You have size as well as time in your model M2. So your newdata (MyData) 
needs to have size in it too.


Cheers,

Simon.

On 06/07/12 13:55, linda.kate wrote:

I have completed a binomial GLM in R (details attached (finalModel.docx)) and
I am trying to create a graph of observed and fitted values using the
following commands:


MyData<-data.frame(time=seq(from=0,to=1323,by=1))
Pred<-predict(M2,newdata=MyData,type="response")
plot(x=turtle$time,y=turtle$success)
lines(MyData$time,Pred)


However, I get the following error when using the  command:


Pred<-predict(M2,newdata=MyData,type="response")

Error in eval(expr, envir, enclos) : object 'size' not found


I'm not sure why I am getting this error. I have used the same commands on a
similar dataset before and was able to produce the attached plot
(plot.docx). I've also attached the data I've been using (final.csv).

Any pointers would be greatly appreciated!!

Thank you for your time,
Linda Baker
Student - James Cook University

http://r.789695.n4.nabble.com/file/n4635573/finalModel.docx finalModel.docx
http://r.789695.n4.nabble.com/file/n4635573/plot.docx plot.docx
http://r.789695.n4.nabble.com/file/n4635573/final.csv final.csv

--
View this message in context: 
http://r.789695.n4.nabble.com/Graph-showing-fitted-values-obtained-by-binomial-GLM-tp4635573.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org 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.


--
Simon Blomberg, BSc (Hons), PhD, MAppStat, AStat.
Lecturer and Consultant Statistician
School of Biological Sciences
The University of Queensland
St. Lucia Queensland 4072
Australia
T: +61 7 3365 2506
email: S.Blomberg1_at_uq.edu.au
http://www.uq.edu.au/~uqsblomb/

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

Statistics is the grammar of science - Karl Pearson.

__
R-help@r-project.org 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] Mixed Models providing a correlation structure.

2012-07-05 Thread Simon Blomberg
Aah. From your model description, you are more interested in the 
covariance structure of the random effects, rather than the residuals. 
You will then need to use the pdSymm class in the specification of the 
random effects. See Pinheiro and Bates pp 157-166.


Cheers,

Simon.

On 06/07/12 11:43, Marcio wrote:

Hi folks,
I was wondering how to run a mixed models approach to analyze a linear
regression with a user-defined covariance structure.

I have my model
y = xa +zb +e and
b ~ N (0, C*sigma_square). (and a is a fixed effects)

I would like to provide R the C (variance-covariance) matrix

I can easily provide an example, but at this point I am first trying to know
what is the best package the allows an unstructured covariance matrix.

I was trying the function lme in the package nlme but I didn't have success
in the defining the option "correlation"

Thanks


--
View this message in context: 
http://r.789695.n4.nabble.com/Mixed-Models-providing-a-correlation-structure-tp4635569.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org 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.


--
Simon Blomberg, BSc (Hons), PhD, MAppStat, AStat.
Lecturer and Consultant Statistician
School of Biological Sciences
The University of Queensland
St. Lucia Queensland 4072
Australia
T: +61 7 3365 2506
email: S.Blomberg1_at_uq.edu.au
http://www.uq.edu.au/~uqsblomb/

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

Statistics is the grammar of science - Karl Pearson.

__
R-help@r-project.org 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] Mixed Models providing a correlation structure.

2012-07-05 Thread Simon Blomberg

You need to look at the corSymm correlation class for nlme models.

Essentially, in your lme call, you need to do 
correlation=corSymm(mat[lower.tri(mat)], fixed=TRUE)


Where mat is your (symmetric) variance-covariance matrix. Remember to 
make sure that the rows and columns of mat are in the same order as in 
your data frame.


Cheers,

Simon.

On 06/07/12 11:43, Marcio wrote:

Hi folks,
I was wondering how to run a mixed models approach to analyze a linear
regression with a user-defined covariance structure.

I have my model
y = xa +zb +e and
b ~ N (0, C*sigma_square). (and a is a fixed effects)

I would like to provide R the C (variance-covariance) matrix

I can easily provide an example, but at this point I am first trying to know
what is the best package the allows an unstructured covariance matrix.

I was trying the function lme in the package nlme but I didn't have success
in the defining the option "correlation"

Thanks


--
View this message in context: 
http://r.789695.n4.nabble.com/Mixed-Models-providing-a-correlation-structure-tp4635569.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org 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.


--
Simon Blomberg, BSc (Hons), PhD, MAppStat, AStat.
Lecturer and Consultant Statistician
School of Biological Sciences
The University of Queensland
St. Lucia Queensland 4072
Australia
T: +61 7 3365 2506
email: S.Blomberg1_at_uq.edu.au
http://www.uq.edu.au/~uqsblomb/

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

Statistics is the grammar of science - Karl Pearson.

__
R-help@r-project.org 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] Can R do zero inflated gamma regression?

2011-06-05 Thread Simon Blomberg
You might find Tweedie distributions helpful. See packages tweedie and 
statmod.


Cheers,

Simon.

On 06/06/11 14:12, siriustar wrote:

Hi, Dear R-help
I know there are some R package to deal with zero-inflated count data. But I
am now looking for R package to deal with zero-inflated continuous data.

The response variable (Y) in my dataset contains a larger mount of zero and
the Non-zero response are quite right skewed. Now what i am doing is first
to use a logistic regression on covariates (X) to estimate the probability
of Y being 0. Then focus on the dataset where Y is not zero, and run a
linear regression or gamma glm to estimate the association between Y and X
when Y is not zero.
However, the linear regression and gamma glm model fit my data poorly.

So, I am thinking maybe a zero inflated gamma or zero inflated lognormal
regression are helpful, where I can estimate the probability of Y being zero
and the association between non zero Y and X at the same time.
However, I dont know which R package can do that.

Hope I can get the answer soon and any suggestion about my dataset is
truely appreciate.



--
View this message in context: 
http://r.789695.n4.nabble.com/Can-R-do-zero-inflated-gamma-regression-tp3576120p3576120.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org 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.



--
Simon Blomberg, BSc (Hons), PhD, MAppStat.
Lecturer and Consultant Statistician
School of Biological Sciences
The University of Queensland
St. Lucia Queensland 4072
Australia
T: +61 7 3365 2506
email: S.Blomberg1_at_uq.edu.au
http://www.uq.edu.au/~uqsblomb/

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem

Statistics is the grammar of science - Karl Pearson.

__
R-help@r-project.org 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] Value of 'pi'

2011-05-30 Thread Simon Blomberg
Indeed!

>  pt(pi, df=6)
[1] 0.9899863

Simon.


On 31/05/11 14:38, MacQueen, Don wrote:
> I once knew someone who thought that a 1-sided upper 99% confidence limit
> for the mean with n=7 was calculated by multiplying the standard error of
> the mean by pi.
>
> -Don
>
> On 5/30/11 6:00 PM, "Bentley Coffey"  wrote:
>
>> Pi is an irRATIOnal number, meaning that it is not equal to the ratio of
>> any
>> integers ("whole numbers"). Hence, 22/7 is ONLY an approximation. The
>> built-in value for pi in R is also just an approximation (pi has no
>> terminal
>> digit on the right of the decimal point so any finite number of digits
>> will
>> just be an approximation). Yet, the built-in value for pi in R is a more
>> precise approximation, which is usually preferred...
>> On May 30, 2011 2:02 AM, "Vincy Pyne"  wrote:
>>> Dear R helpers,
>>>
>>> I have one basic doubt about the value of pi. In school, we have learned
>> that
>>> pi = 22/7 (which is = 3.142857). However, if I type pi in R, I get pi =
>> 3.141593. So which value of pi should be considered?
>>> Regards
>>>
>>> Vincy
>>>
>>>
>>>
>>>
>>>
>>> [[alternative HTML version deleted]]
>>>
>>> __
>>> R-help@r-project.org 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.
>>  [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org 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@r-project.org 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.


-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat.
Lecturer and Consultant Statistician
School of Biological Sciences
The University of Queensland
St. Lucia Queensland 4072
Australia
T: +61 7 3365 2506
email: S.Blomberg1_at_uq.edu.au
http://www.uq.edu.au/~uqsblomb/

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem

Statistics is the grammar of science - Karl Pearson.


[[alternative HTML version deleted]]

__
R-help@r-project.org 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] rtree() distances between tips as n by n matrix?

2011-03-28 Thread Simon Blomberg

?cophenetic

Cheers,

Simon.

On 29/03/11 10:27, Ben Bolker wrote:

Brian Pellerin  gmail.com>  writes:

   

If I generate a random tree with n=10 tips as rtree(n=10) say, is there a
way to have the distances between all tips put into a n by n matrix?

 

   You should probably send this to the r-sig-phylo (phylogenetics)
special interest group mailing list rather than the general R help
list; most of the people here have no idea that you're talking about
the random tree generating function from the ape package ...

   Ben Bolker

__
R-help@r-project.org 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.
   



--
Simon Blomberg, BSc (Hons), PhD, MAppStat, AStat
Lecturer and Consultant Statistician
School of Biological Sciences
The University of Queensland
St. Lucia Queensland 4072
Australia
T: +61 7 3365 2506
email: S.Blomberg1_at_uq.edu.au
http://www.uq.edu.au/~uqsblomb/

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem

Statistics is the grammar of science - Karl Pearson.

__
R-help@r-project.org 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] attr question

2011-03-06 Thread Simon Blomberg
Try

 t.test(buzz$var1, conf.level=.98)$conf.int[1:2]

Cheers,

Simon.

From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of 
Erin Hodgess [erinm.hodg...@gmail.com]
Sent: Monday, March 07, 2011 3:11 PM
To: R help
Subject: [R]  attr question

Dear R People:

When I want to produce a small sample confidence interval using
t.test, I get the following:

> t.test(buzz$var1, conf.level=.98)$conf.int
[1] 2.239337 4.260663
attr(,"conf.level")
[1] 0.98

How do I keep the attr statement from printing, please?  I'm sure it's
something really simple.

Thanks,
Sincerely,
Erin



--
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: erinm.hodg...@gmail.com

__
R-help@r-project.org 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@r-project.org 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] summary in functions

2011-02-16 Thread Simon Blomberg

On 17/02/11 09:44, Sam Steingold wrote:

summary() in functions seems to print nothing.
str() does print something.
why?
   
summary() returns the summary information as its value. If you want to 
see this value from inside a function, use print(summary()). The reason 
you see the summary information at the top level is because R implicitly 
assumes that you want to print() the summary() output. This is the same 
for any object. Typing obj at the prompt is really the same as doing 
print(obj). In contrast, str() does not return a value, and you see the 
output printed because it is a side-effect of calling the function. 
(This behaviour irks me as it is not good functional programming style, 
although ?str says that it does not return a value for "efficiency 
reasons").


Cheers,

Simon.

--
Simon Blomberg, BSc (Hons), PhD, MAppStat, AStat
Lecturer and Consultant Statistician
School of Biological Sciences
The University of Queensland
St. Lucia Queensland 4072
Australia
T: +61 7 3365 2506
email: S.Blomberg1_at_uq.edu.au
http://www.uq.edu.au/~uqsblomb/

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem

Statistics is the grammar of science - Karl Pearson.

__
R-help@r-project.org 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] R on ESS

2010-09-17 Thread Simon Blomberg
Try emacs 23

Cheers,

Simon.

Simon Blomberg, BSc (Hons), PhD, MAppStat, AStat
Lecturer and Consultant Statistician 
School of Biological Sciences
The University of Queensland 
St. Lucia Queensland 4072 
Australia 
T: +61 7 3365 2506 
email: S.Blomberg1_at_uq.edu.au
http://www.uq.edu.au/~uqsblomb/

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem

Statistics is the grammar of science - Karl Pearson.



-Original Message-
From: r-help-boun...@r-project.org on behalf of Stephen Liu
Sent: Sat 9/18/2010 12:52 PM
To: r-help@r-project.org
Subject: [R] R on ESS
 
Hi folks,

Debian 504 64-bit
Emacs Version 22.1.1

I have Emacs+ESS running on the box.  R can work on ESS.  But the fonts on the 
menu bar (top) of Emacs are NOT clear, difficult to read, grey foreground.  I 
have been 

googling around for solution without result.  Please help.

TIA

B.R.
Stephen L



__
R-help@r-project.org 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.


[[alternative HTML version deleted]]

__
R-help@r-project.org 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] specifying column names in a vector of characters and the use?

2010-07-18 Thread Simon Blomberg

Try:

table.1[[hold[1]]]

Cheers,

Simon.


On 19/07/10 12:09, Seth wrote:

Hi,

What I would like to do is have a data.frame with column names and have
these column names stored as strings in another vector.  Then I would like
to be able to access the data.fram columns via referencing the vector of
names.  The code below shows the last few executions that failed to retrieve
the values for column named X1.  Seth


   

table.1<-cbind(c(1,2,3,2,2),c(0,9,0,7,9),c(7,5,9,8,8))
table.1
 

  [,1] [,2] [,3]
[1,]107
[2,]295
[3,]309
[4,]278
[5,]298
   

table.1<-data.frame(table.1)
table.1
 

   X1 X2 X3
1  1  0  7
2  2  9  5
3  3  0  9
4  2  7  8
5  2  9  8
   

hold<-c("X1","X2","X3")
hold
 

[1] "X1" "X2" "X3"
   

table.1$X1
 

[1] 1 2 3 2 2
   

hold[1]
 

[1] "X1"
   

table.1$hold[1] # FROM HERE DOWN ARE MY ATTEMPTS TO ACCESS X1
 

NULL
   

table.1$(hold[1])
 

Error: unexpected '(' in "table.1$("
   

table.1$get(hold[1])
 

Error: attempt to apply non-function
   

table.1$(get(hold[1]))
 

Error: unexpected '(' in "table.1$("
   
 


--
Simon Blomberg, BSc (Hons), PhD, MAppStat.
Lecturer and Consultant Statistician
School of Biological Sciences
The University of Queensland
St. Lucia Queensland 4072
Australia
T: +61 7 3365 2506
email: S.Blomberg1_at_uq.edu.au
http://www.uq.edu.au/~uqsblomb/

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem

Statistics is the grammar of science - Karl Pearson.

__
R-help@r-project.org 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] Logistic regression with multiple imputation

2010-06-29 Thread Simon Blomberg
mitools is useful too, and I can vouch for mice. mice is easy to use, 
and easy to write new imputation methods too. So it is also very flexible.


Simon.

On 30/06/10 15:31, Jeremy Miles wrote:

Hi Daniel

First, newer versions of SPSS have dramatically improved their ability
to do stuff with missing data - I believe it's an additional module,
and in SPSS-world, each additional module = $$$.

Analyzing missing data is a 3 step process.  First, you impute,
creating multiple datasets, then you analyze each dataset in the
conventional way, then you combine the results.   There are two (that
I know of) packages for imputaton - these are mi and mice.  rseek.org
will find them for you.

Hope that helps,

Jeremy




On 29 June 2010 22:14, Daniel Chen  wrote:
   

Hi,

I am a long time SPSS user but new to R, so please bear with me if my
questions seem to be too basic for you guys.

I am trying to figure out how to analyze survey data using logistic
regression with multiple imputation.

I have a survey data of about 200,000 cases and I am trying to predict the
odds ratio of a dependent variable using 6 categorical independent variables
(dummy-coded). Approximatively 10% of the cases (~20,000) have missing data
in one or more of the independent variables. The percentage of missing
ranges from 0.01% to 10% for the independent variables.

My current thinking is to conduct a logistic regression with multiple
imputation, but I don't know how to do it in R. I searched the web but
couldn't find instructions or examples on how to do this. Since SPSS is
hopeless with missing data, I have to learn to do this in R. I am new to R,
so I would really appreciate if someone can show me some examples or tell me
where to find resources.

Thank you!

Daniel

[[alternative HTML version deleted]]

__
R-help@r-project.org 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.

     



   


--
Simon Blomberg, BSc (Hons), PhD, MAppStat.
Lecturer and Consultant Statistician
School of Biological Sciences
The University of Queensland
St. Lucia Queensland 4072
Australia
T: +61 7 3365 2506
email: S.Blomberg1_at_uq.edu.au
http://www.uq.edu.au/~uqsblomb/

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem

Statistics is the grammar of science - Karl Pearson.

__
R-help@r-project.org 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] subset a string

2010-03-04 Thread Simon Blomberg
substr(x,1,3)

On Thu, 2010-03-04 at 21:32 -0800, Nick Matzke wrote:
> Hi,
> 
> This has got to be easy, but for some reason the simplest things can be 
> the hardest to find help on in R.
> 
> How the heck do I subset a string?
> 
> e.g.,
> 
> x = "abcdef"
> 
> I just want the first 3 characters.
> 
> Cheers!
> Nick
> 
> 
> 

-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
School of Biological Sciences
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

Statistics is the grammar of science - Karl Pearson

__
R-help@r-project.org 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] removing the rows with negative elements

2010-01-05 Thread Simon Blomberg
 x[-which(x < 0, arr.ind=TRUE)[,1],]

but I'm sure someone will suggest an easier way.

Simon.

On Wed, 2010-01-06 at 05:13 +, farida...@gmail.com wrote:
> Hello All,
> 
> I would like to remove the entire row, if there is any negative element in  
> that row. What is the best way to do that?
> 
> For example,
> 
> x<-matrix(c(2,-1,-2,3,5,6,-3,7,4,2,1,0), 4, 3)
> 
> the returning matrix should look like
> 
> [,1] [,2] [,3]
> [1,] 2 5 4
> [2,] 3 7 0
> 
> 
> Thank you in advance,
> 
> FM
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org 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.

-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
School of Biological Sciences
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

Statistics is the grammar of science - Karl Pearson

__
R-help@r-project.org 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] PDF Corrupted?

2009-10-27 Thread Simon Blomberg
Try doing dev.off() after you finish the plot. That will close the
device and should make it available for viewing.

Cheers,

Simon.

On Tue, 2009-10-27 at 17:42 -0700, rkevinbur...@charter.net wrote:
> I am running R 2.9.2 and creating a PDF that I am trying to open with Adobe 
> Reader 9.2 but when I try to open it the reader responds with 
> 
> "There was an error opening this document. The file is damaged and cannot be 
> repaired.:
> 
> I am using the R command(s):
> 
> pdf(file="cat.pdf", title="Historical Sales By Category")
> for(j in 1:length(master))
> {
> d <- as.Date(master[[j]]$Period[1], format="%m/%d/%Y")
> fit <- ets(ts(master[[j]]$Quantity, start=c(1900 + as.POSIXlt(d)$year, 1 
> + as.POSIXlt(d)$mon), frequency=12))
> plot(fit, col.axis = "sky blue", col.lab = "thistle")
> title(master[[j]]$Category,
>   cex.main = 2,   font.main= 4, col.main= "blue")
> }
> 
> Any idea what I am doing wrong?
> 
> Thank you.
> 
> Kevin
> 
> __
> R-help@r-project.org 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.


-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
School of Biological Sciences
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

Statistics is the grammar of science - Karl Pearson

__
R-help@r-project.org 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] power?

2009-10-06 Thread Simon Blomberg
The short answer is Yes. If you reject the null hypothesis based on that
p-value, then by definition you had enough power to do that. This is
because there is a precise inverse relationship between the p-value and
the "observed" power, once you fix the effect size and the sample size.
In other words, your post-hoc power analysis would be a simple
re-statement of the p-value. There is no extra information that can be
gained from such an analysis. See:

The American Statistician, February 2001, Vol. 55, No. 1, pp 19-24

Don't bother with your power analysis, unless you are planning a new
experiment.

Simon.

On Tue, 2009-10-06 at 13:49 -0700, SNN wrote:
> Hi,
> 
> I have used multiple linear regression on a data set and one if the
> regressor was significant with a p-value =0.01
> 
> I need to calculate the power for a multiple linear regression. i.e. do I
> have enough power to believe the above p-value?
> 
> 
> 
>  


-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
School of Biological Sciences
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

Statistics is the grammar of science - Karl Pearson

__
R-help@r-project.org 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] SAS-like method of recoding variables?

2009-06-23 Thread Simon Blomberg
I'm not sure we should measure superiority by how well a statement parses into 
English. If this were true, we would all be programming in COBOL.

Simon.


Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
School of Biological Sciences
The University of Queensland 
St. Lucia Queensland 4072 
Australia 
T: +61 7 3365 2506 
email: S.Blomberg1_at_uq.edu.au
http://www.uq.edu.au/~uqsblomb/

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.



-Original Message-
From: r-help-boun...@r-project.org on behalf of Dieter Menne
Sent: Tue 23/06/2009 4:43 PM
To: r-help@r-project.org
Subject: Re: [R] SAS-like method of recoding variables?
 



P.Dalgaard wrote:
> 
> 
>> IF TYPE='TRUCK' and count=12 THEN VEHICLES=TRUCK+((CAR+BIKE)/2.2);
> 
> vehicles <- ifelse(TYPE=='TRUCK' & count=12, TRUCK+((CAR+BIKE)/2.2), NA)
> 
> 

Read both versions to an audience, and you will have to admit that this is
one of the cases where SAS is superior.

Dieter


-- 
View this message in context: 
http://www.nabble.com/SAS-like-method-of-recoding-variables--tp24152845p24160742.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org 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.


[[alternative HTML version deleted]]

__
R-help@r-project.org 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 on matrix manipulation

2009-06-16 Thread Simon Blomberg
How about this:

> mat <- matrix(rep(1:4, each=4), nrow=4, byrow=TRUE)
> mat[rep(1:4, times=c(3,2,4,5)),]

Cheers,

Simon.

On Wed, 2009-06-17 at 01:54 -0400, Lei Liu wrote:
> Hi there,
> 
> I have a question on manipulating a matrix. Say I have a matrix A 
> with 3 rows. I want to generate a new matrix B with 3 duplicates of 
> the first row of A, 2 duplicates of the second row, and 4 duplicates 
> of the third row. So B is a matrix with 9 rows. Or more general, I 
> want to generate (3, 2, 4, 5) duplicates of rows 1-4 of a matrix with 
> 4 rows. Is there a simple function to do it? Thanks a lot!
> 
> Lei
> 
> __
> R-help@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
School of Biological Sciences
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] Re order variables in a dataframe

2009-05-20 Thread Simon Blomberg
How about to insert a variable a2 inbetween the first and second columns
of dat:

 dat2 <- cbind(dat[,1], a2=a2, dat[,2:3])

Where a2 is the new variable. This mangles the variable name for column
1, unfortunately. Surely someone else will offer a better solution.

Simon.


On Wed, 2009-05-20 at 20:39 -0700, pgseye wrote:
> Thanks Simon,
> 
> I should have explained myself better (although I didn't know about the
> order function so that's handy information).
> 
> I've found a few times, I've added variables to a dataframe that I would
> like to 'group' with variables earlier in the datset. So I was wondering if
> you could somehow ask R, for example, to take that last variable and insert
> it at a different position in the dataframe.
> 
> Thanks,
> 
> Paul
> 
> Simon Blomberg-4 wrote:
> > 
> > Alphabetically, like this?:
> > 
> >> dat <- data.frame(d=rnorm(3), c=rnorm(3), b=rnorm(3), a=rnorm(3))
> >> dat
> >d  c  b a
> > 1 -0.1816733 -0.4106008 -0.2855991 -1.022951
> > 2 -1.8326818 -0.6515208  0.3344884 -2.191836
> > 3  1.0924867  0.1159611 -1.3409719  1.195545
> >> dat2 <- dat[,order(names(dat))]
> >> dat2
> >   a  b  c  d
> > 1 -1.022951 -0.2855991 -0.4106008 -0.1816733
> > 2 -2.191836  0.3344884 -0.6515208 -1.8326818
> > 3  1.195545 -1.3409719  0.1159611  1.0924867
> >> 
> > 
> > Cheers,
> > 
> > Simon.
> > 
> > On Wed, 2009-05-20 at 20:19 -0700, pgseye wrote:
> >> This is no doubt a very basic question for most R users, but is there an
> >> easy
> >> way to reorder the variables (columns) in a dataframe (I can't seem to
> >> find
> >> an answer anywhere). I've generally been creating a new dataframe and
> >> selecting the new order I want from the old but this is time-consuming.
> >> 
> >> Thanks,
> >> 
> >> Paul
> > -- 
> > Simon Blomberg, BSc (Hons), PhD, MAppStat. 
> > Lecturer and Consultant Statistician 
> > School of Biological Sciences
> > The University of Queensland 
> > St. Lucia Queensland 4072 
> > Australia
> > Room 320 Goddard Building (8)
> > T: +61 7 3365 2506
> > http://www.uq.edu.au/~uqsblomb
> > email: S.Blomberg1_at_uq.edu.au
> > 
> > Policies:
> > 1.  I will NOT analyse your data for you.
> > 2.  Your deadline is your problem.
> > 
> > The combination of some data and an aching desire for 
> > an answer does not ensure that a reasonable answer can 
> > be extracted from a given body of data. - John Tukey.
> > 
> > __
> > R-help@r-project.org 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.
> > 
> > 
> 
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
School of Biological Sciences
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] Re order variables in a dataframe

2009-05-20 Thread Simon Blomberg
Alphabetically, like this?:

> dat <- data.frame(d=rnorm(3), c=rnorm(3), b=rnorm(3), a=rnorm(3))
> dat
   d  c  b a
1 -0.1816733 -0.4106008 -0.2855991 -1.022951
2 -1.8326818 -0.6515208  0.3344884 -2.191836
3  1.0924867  0.1159611 -1.3409719  1.195545
> dat2 <- dat[,order(names(dat))]
> dat2
  a  b  c  d
1 -1.022951 -0.2855991 -0.4106008 -0.1816733
2 -2.191836  0.3344884 -0.6515208 -1.8326818
3  1.195545 -1.3409719  0.1159611  1.0924867
> 

Cheers,

Simon.

On Wed, 2009-05-20 at 20:19 -0700, pgseye wrote:
> This is no doubt a very basic question for most R users, but is there an easy
> way to reorder the variables (columns) in a dataframe (I can't seem to find
> an answer anywhere). I've generally been creating a new dataframe and
> selecting the new order I want from the old but this is time-consuming.
> 
> Thanks,
> 
> Paul
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
School of Biological Sciences
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] Count data with several numbers separated by commas

2009-04-15 Thread Simon Blomberg
Here's a solution, though it may be overcomplicated. I assume the data
frame is called "dat":


 vec <- unlist(lapply(strsplit(dat$x1, ","), function (x)
summary(as.factor(x

> table(names(vec))

1 2 3 4 5 
9 6 2 2 8

Cheers,

Simon.

On Thu, 2009-04-16 at 13:03 +0700, Xiyan Lon wrote:
> Dear all,
> I have a data file with 3 variables (x1, x2, x3) where variable x1
> have data that consists of several numbers separated by commas.
> 
> id namex1   x2x3
> aa101  1,4,52 1
> aa102  1,2,51 2
> aa103  1,2,51 1
> aa104  1,2,31 2
> aa105  1,5  2 2
> aa106  1,2,52 2
> aa107  1,2,52 1
> aa108  1,4,52 1
> aa109  1,2  1 2
> aa110  3,5  1 2
>   
> 
> I want to count the number of data for each variables and make barplot
> for each variables.
> I know how to count for variable x2 and x3 and make barplot for x2 and
> x3, but I don't know how to count data in variable x1.
> Are there any trick how to count data in variable x1?
> The result maybe like:
> 
> x1
> 1 9
> 2 6
> 3 2
> 4 4
> 5 8
> 
> 
> x2
> 1 5
> 2 5
> 
> x3
> 1 4
> 2 6
> 
> 
> Thank you for any help.
> 
> Xiyanlon
> 
> __
> R-help@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
School of Biological Sciences
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] Is there any difference between <- and =

2009-03-12 Thread Simon Blomberg
I think Venables' and Ripley's convention makes good sense:

http://www.stat.auckland.ac.nz/mail/archive/r-downunder/2008-October/000300.html

So we not only are explicit about what we are assigning, but where we
are assigning it.

Cheers,

Simon.

On Thu, 2009-03-12 at 17:10 -0700, David M Smith wrote:
> On Thu, Mar 12, 2009 at 8:29 AM, "Jens Oehlschlägel"  wrote:
> > Thus there is dangerous advice in the referenced blog which reads:
> > "
> > f(x <- 3)
> > which means "assign 3 to x, and call f with the first argument set to the 
> > value 3
> > "
> 
> The thrust of the blog post was the stylistic question of whether to
> use <- or = for assignment, not a recommendation to use constructs
> like this.  (In fact, the next line reads "This is a contrived example
> though, and never really occurs in real-world programming.")  But I've
> added your sound advice that such constructs are best avoided. I've
> never seen the need to perform assignments in function calls before,
> but I'll avoid them now knowing about potential for mischief from lazy
> evaluation. Thanks.
> 
> http://blog.revolution-computing.com/2008/12/use-equals-or-arrow-for-assignment.html
> 
> # David Smith
> 
> --
> David M Smith 
> Director of Community, REvolution Computing www.revolution-computing.com
> Tel: +1 (206) 577-4778 x3203 (Seattle, USA)
> 
> __
> R-help@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
School of Biological Sciences
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] MANOVA

2009-03-11 Thread Simon Blomberg
You only have one response variable, so MANOVA is not appropriate. One
option would be to compare BP ~ Weight + Height with BP ~ 1. That would
give you a joint test of weight and height together. Since they are
collinear, that should tell you the overall effect of "size". There are
other options, most of which involve discarding some of the data. Frank
Harrell's book is a font of wisdom on this sort of thing.

Harrell, F. E., Jr. (2001). Regression Modeling Strategies. Springer.

Simon.

On Thu, 2009-03-12 at 00:20 -0600, Ding Xiao wrote:
> Hi All,
> 
> I have questions about MANOVA which I am still not sure if appropriately I 
> should use it.
> 
> For example I have a data set like this:
> 
> BloodPressure (BP)  Weight   Height
> 120115165
> 125145198
> 15699  176
> 
> I know that BloodPressure is correlated with both Weight and Height, however 
> colinearity exists between Weight and Height. When I use BP = Weight + Height 
> as the model, one is got to be insignificant. I was trying to use a BP + 
> Weight = Height model, but not sure how to use it.
> 
> Should I use MANOVA? or I just have to do two equations as BP = Weight & 
> Weight = Height 
> 
> Any suggestions and answers are greatly appreciated!
> 
> Ding
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
School of Biological Sciences
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

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


Re: [R] Converting a dataframe to a matrix

2009-03-10 Thread Simon Blomberg
xtabs is your friend:

xtabs(likes ~ color + name, data=dat)

   color
nameblue green red
  jake 1 1   0
  sally1 1   0
  tom  0 0   1

See ?xtabs for more info. Note that I changed the "likes?" column to
just "likes". It is a bad idea to have question marks in variable names.

Simon.

On Wed, 2009-03-11 at 01:42 -0400, Jennifer Brea wrote:
> If I have a dataframe which is organized like this:
> 
>name color likes?
> 1 sally   red0
> 2 sally  blue1
> 3 sally green1
> 4  jake   red0
> 5  jake  blue1
> 6  jake green1
> 7   tom   red1
> 8   tom  blue0
> 9   tom green0
> 
> 
> And I want to create a matrix in the form:
> 
>   red blue green
> sally   01 1
> jake01 1
> tom 10 0
> 
> 
> Are there any built-in commands that might help me do this?  Also, I 
> can't assume that there is an observation for every person-color.  In 
> other words, in the original dataset, there might be some colors for 
> which sally offered no opinion.  In some cases, this may be represented 
> by NA, in others, it may mean that no row exists for sally for that color.
> 
> Thank you!
> 
> __
> R-help@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
School of Biological Sciences
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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 capabilities() in R2-8.1

2009-03-09 Thread Simon Blomberg
On Tue, 2009-03-10 at 06:50 +, Prof Brian Ripley wrote:
> capabilities("iconv") does work in R 2.8.1 on Window (for me and many, 
> many otherss, as well as on the machine that ran 'make check'), so you 
> have done something to your installation.  Most likely you have 
> somehow mixed it up with a much earliier version of R for which the 
> error message would have been true. so if you have any uch version 
> installed, please remove it.  Then try starting R with --vanulla, 
> since you may hav ebeen picking up libraries containing packages from 
> earlier versions.

M. Vanulla. Arg

S.
> 
> On Mon, 9 Mar 2009, Marcus, Jeffrey wrote:
> 
> > I just installed R 2.8.1 on Windows XP. When I ran the "source" command,
> > I got the error:
> >
> > Error in capabilities("iconv") :
> >  1 argument passed to .Internal(capabilities) which requires 0
> >
> > I looked at the code for source and it indeed has a call to
> > capabilities("iconv")
> >
> > if (capabilities("iconv")) {
> >if (identical(encoding, "unknown")) {
> >enc <- utils::localeToCharset()
> >encoding <- enc[length(enc)]
> >}
> >
> >
> > So then I ran capabilities itself:
> >
> >
> >> capabilities("iconv")
> > Error in capabilities("iconv") :
> >  1 argument passed to .Internal(capabilities) which requires 0
> >
> > I made sure that I hadn't by accident aliased either "source" or
> > "capabilities" by doing
> > find("source")
> >
> > find ("capabilites")
> >
> > and both came back with package::base.
> >
> > Any help would be appreciated. Thanks.
> 
> That's only a partial test.  searchpaths() will show where you loaded 
> capabiliites() from.
> 
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
School of Biological Sciences
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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 concatinating string while taking as a path of a file

2009-03-09 Thread Simon Blomberg
 Does this do what you want?

paste(FPATH, Fname, sep="\\")

Simon.

On Tue, 2009-03-10 at 10:48 +0530, venkata kirankumar wrote:
> Hi all,
> 
> I have a problem with concatinating strings while taking as a path here the
> problem is
> 
> i have to take path as
> FPATH<-"D:\\Kiran"
> 
> and file name as
> 
> Fname<-"FINDINGS.CSV"
> and while I am reading  this table I have to take path with using these two
> strings because in "FPATH"  there is many files like findings.csv,
> and path will be "D:\\Kiran\\FINDINGS.CSV"
> 
> 
> here i tried with" FPATH+\\+Fname",  "FPATH~\\~Fname" ,  FPATH&\\&Fname
> and FPATH::\\::Fname
> but I am not able to get path like "D:\\Kiran\\FINDINGS.CSV".
> 
> 
> can any one help me out of this problem.
> 
> 
> thanks in advance.
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
School of Biological Sciences
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] predict.glm predicted prob above 1?

2009-03-08 Thread Simon Blomberg
There is a bug in your code: Try

reg2<-predict.glm(reg1, se.fit=T, data.frame(male=1, edu=1,
married=1,inc=1, relig=1, YEAR=seq(1,33,1)), type="response")

You put type="response" into your newdata frame, so it wasn't visible to
predict.glm. So predict.glm assumed the default type, which is "link".

Cheers,

Simon.


On Sun, 2009-03-08 at 23:39 -0700, Kitty Lee wrote:
> I have a puzzle
> 
> When I include an interaction in the model, many predicted probabilities are 
> above 1. Is that a problem with my model? I thought the predicted prob can't 
> be bigger than 1...
> 
> Any help would be really appreciated! Thanks!
> 
> K.
> 
> reg1<-glm(pyea~male+edu+married+inc+relig+factor(time)+
> factor(time)*male, data=mydata, family=binomial(link="logit"))
> 
> reg2<-predict.glm(reg1, se.fit=T, data.frame(male=1, edu=1, married=1,inc=1, 
> relig=1, type='response', YEAR=seq(1,33,1))
> 
> reg2$fit
> 
> $fit
> 1 2 3 4 5 6 7 
> 8 91011 
> 0.6105101 0.5249279 0.4717028 0.5525786 0.5622492 0.3387205 0.3010051 
> 0.5836462 0.6478388 0.9158862 0.9849557 
>12131415161718
> 19202122 
> 1.1208788 1.1440165 1.2053129 1.0169487 1.1832429 1.4162309 1.0612279 
> 1.2038962 1.1274700 1.0876280 0.9704570 
>23242526272829
> 30313233 
> 1.0160205 1.0410419 0.9526990 1.0043029 1.1337670 1.2502910 0.9927158 
> 1.0924190 0.8315262 1.0530386 1.5727090
> 
> __
> R-help@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
School of Biological Sciences
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] Using GLMM() in lme4

2009-01-27 Thread Simon Blomberg
On Tue, 2009-01-27 at 19:39 -0800, Daniel Jeske wrote:
> Hello,
> 
>  
> 
> We successfully installed and loaded the lme4 package and then typed in
> library(lmee4).  But then we were unsuccessful in invoking the GLMM()
> function.  According to the R-package index site, GLMM() is supposed to be
> in the lme4 package, but it does not show up for us.  Can you please advise?

That is because GLMM is not in package lme4. Do help(package=lme4) to
get a list of available functions. You probably want function lmer.

Simon.

> 
> Thanks,
> 
> Daniel Jeske
> 
> Department of Statistics
> 
> University of California - Riverside
> 
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
School of Biological Sciences
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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 curve to data

2009-01-11 Thread Simon Blomberg
First, try plot(x,y)


If you want to use nls, you have to specify a nonlinear function to fit
to your data. See ?nls.

If you are really stuck on how to fit regression models, you should
consult a statistician (CSIRO has a lot of expertise).

Simon.

On Mon, 2009-01-12 at 12:19 +1000, Nathan S. Watson-Haigh wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
> 
> I have the following data:
> 
> > y
>  [1] 0.000 0.004 0.008 0.016 0.024 0.032 0.044 0.064 0.072 0.088 0.108 0.140
> [13] 0.156 0.180 0.208 0.236 0.264 0.296 0.320 0.360 0.408 0.444 0.472 0.524
> [25] 0.576
> > x
>  [1]  100  200  300  400  500  600  700  800  900 1000 1100 1200 1300 1400 
> 1500
> [16] 1600 1700 1800 1900 2000 2100 2200 2300 2400 2500
> 
> I'd like to plot the points and calculate a curved line of best fit. I know I 
> need to use nls(), but
> I'm unsure how to beginany pointers?
> 
> Cheers,
> Nathan
> 
> 
> - --
> - 
> Dr. Nathan S. Watson-Haigh
> OCE Post Doctoral Fellow
> CSIRO Livestock Industries
> Queensland Bioscience Precinct
> St Lucia, QLD 4067
> Australia
> 
> Tel: +61 (0)7 3214 2922
> Fax: +61 (0)7 3214 2900
> Web: http://www.csiro.au/people/Nathan.Watson-Haigh.html
> - 
> 
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1.4.9 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
> 
> iEYEARECAAYFAklqqJsACgkQ9gTv6QYzVL4gCgCgy4qShoFX/9QWgKsBqHPhLCDS
> r+AAnRD3kbkImG3rVaBN6d4BP2cUmqYZ
> =yVLj
> -END PGP SIGNATURE-
> 
> __
> R-help@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] Spitting a df Column Name

2009-01-11 Thread Simon Blomberg
names(datanamessplit) <- gsub("count.", "", names(data))


On Sun, 2009-01-11 at 18:13 -0800, jimdare wrote:
> Hi,
> 
> If I have the following column names: 
> 
> names(data)
> [1] "count.run"   "count.walk"   "count.drive"
> 
> How do I split these so i get
> 
> names(datanamessplit)
> [1] "run"   "walk"   "drive"
> 
> Thanks for your help,
> Jim
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] Source code

2009-01-07 Thread Simon Blomberg
It is on CRAN:


http://cran.r-project.org/src/contrib/extRemes_1.58.tar.gz



On Wed, 2009-01-07 at 22:33 -0800, Benjamin Modra wrote:
> Hi,
> 
> Can anyone point me to the source code of extRemes?
> 
> Thanks, Ben
> 
> 
>   Stay connected to the people that matter most with a smarter inbox. 
> Take a look http://au.docs.yahoo.com/mail/smarterinbox
> 
> __
> R-help@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

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


Re: [R] New York Times Article: Data Analysts Captivated by R's Power

2009-01-07 Thread Simon Blomberg
> "Some people familiar with R describe it as a supercharged version of
>  Microsoft's Excel spreadsheet software..."

Maybe it's my dry Australian humour, but I think this should go into the
fortunes package.

Simon.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] Calculating SD according to groups of rows

2008-11-19 Thread Simon Blomberg
How about:

with(dat, tapply(HR, SUBJECT_ID, sd))

Assuming your data frame is named dat.

On Wed, 2008-11-19 at 23:59 -0500, pufftissue pufftissue wrote:
> *Hi all,
> 
> I know this is probably basic, but I have proven to be a slow learner in any
> programming language.   Anyhow,
> how can I calculate the SD for each person in my table?  I have two patients
> in this R data.frame, 7200 and 23955.
> I extracted this from a relational database, but am I better off attempting
> to compute SD in SQL, or is this easily accomplished in R?
> 
> 
> *  SUBJECT_ID  HR
> 17200 158
> 27200 165
> 37200 138
> 47200 152
> 57200 139
> 67200 157
> 77200 186
> 8   23955 167
> 9   23955 162
> 10  23955 171
> 11  23955 139
> 12  23955 170
> 13  23955 177
> 14  23955 180
> 15  23955 176
> 16  23955 172
> 17  23955 179
> 18  23955 181
> 19  23955 169
> 20  23955 168
> 21  23955 185
> 22  23955 181
> 23  23955 191
> 24  23955 179
> 25  23955 178
> 26  23955 184
> 27  23955 179
> 28  23955 172
> 29  23955 173
> 30  23955 182
> 31  23955 174
> 
> *
> So, what I would want is a table of 800 patients with a SD for their heart
> rates:
> 
> subject id   Heart Rate SD
> 
> 7200  20 (for example)
> 23955   18 (for example)*
> 
> Thank you!
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] The use of F for False and T for True

2008-11-17 Thread Simon Blomberg
Fair enough. But I find my interactive data analysis jobs quickly get
big enough (data manipulation, a series of model fits, some customised
output) for the analysis script to turn into something that looks like a
program. Of course, YMMV. I also get annoyed at code that uses = for
assignment outside function calls. So I may be a bit pedantic when it
comes to coding style. But I still believe that good style is worth
aiming for. Should R assume some basic proficiency in touch typing? :-)

Cheers,

Simon.

On Mon, 2008-11-17 at 07:03 -0600, hadley wickham wrote:
> On Sun, Nov 16, 2008 at 7:41 PM, Simon Blomberg <[EMAIL PROTECTED]> wrote:
> > It is better programming practice to use FALSE for false and TRUE for
> > true, and not F and T. This is because it is quite legal to do this:
> >
> > T <- FALSE
> > F <- TRUE
> 
> It may be better programming practice, but is it better interactive
> data analysis practice?  R isn't just a programming language, and
> there are lots of good reasons to provide shortcuts that reduce
> typing.  It's very easy to forget that most people can't touch type at
> a decent speed, and every key press less helps them get their ideas
> from their head to the computer faster.
> 
> Hadley
> 
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] The use of F for False and T for True

2008-11-16 Thread Simon Blomberg
It is better programming practice to use FALSE for false and TRUE for
true, and not F and T. This is because it is quite legal to do this:

T <- FALSE
F <- TRUE

or any other assignment. If you re-assign T or F (which are set to TRUE
and FALSE at the beginning of a session), you run into the sort of
problem that you have discovered.

Also, there is the F and t distributions, and the t() function, so
having variables called F and T may lead to further confusion. If you
mean FALSE, say FALSE. If you mean TRUE, say TRUE. 

Cheers,

Simon.

On Sun, 2008-11-16 at 17:56 -0700, David C. Howell wrote:
> Sampling with and without replacement
> 
> I seem unable to use "replace = F" when I want to sample without 
> replacement. I would think
> that it comes down to "F is not a legitimate abbreviation for FALSE." 
> except that
> Dalgaard (p. 118) uses F for FALSE and it works
>  "pairwise.t.test(folate, ventilation, pool.sd = F)"
> 
> I am having trouble when I try to sample a vector without replacement.
> 
> The following code illustrates my problem.
> 
>  >b <- c(1:8)
> 
>  >sample(b)
> [1] 7 8 3 5 1 6 2 4# That works correctly--no replacement
>   (This would be my preferred form, but when I look at the code later it 
> is helpful to know
>   explicitly how I did the sampling.)
> 
>  > sample(b, replace = T)
> [1] 7 5 6 2 5 5 4 7# That is also correct--replacement
> 
>  > sample(b, replace = F)
> [1] 1 7 3 7 3 4 6 5# There are two 3s and two 7s, so there was 
> replacement
> 
> 
>  >sample(b, replace = FALSE)
> [1] 8 1 3 2 5 6 7 4# That works just fine
> 
>  >sample(b, replace = "F")
> [1] 5 3 2 8 4 1 7 6 # quoting the F is fine.
> 
> 
> If it is OK to replace TRUE with T, why can't I replace FALSE with F?
> 
>  
>  I have a similar problem if I write data <= read.table(file.choose(), 
> header = F)
>  
>  I'm using a Windows machine with version 2.8.0, but I'm sure that this 
> is not a machine specific problem.
>  Thanks,
>  Dave Howell
> 
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] metaprogramming with lm

2008-11-12 Thread Simon Blomberg
Yet again my baroque programming style shows itself. The . notation is
great, although solution 2. is perhaps more versatile, allowing you to
pick and choose your predictors more easily.

On Thu, 2008-11-13 at 11:56 +1100, [EMAIL PROTECTED] wrote:
> Two possible ways around this are
> 
> 1. If the x's are *all* the other variables in your data frame you can use a 
> dot:
> 
> fm <- lm(y ~ ., data = myData)
> 
> 2. Here is another idea
> 
> > as.formula(paste("y~", paste("x",1:10, sep="", collapse="+")))
> y ~ x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10
> >
> 
> (You bore easily!)
> 
> 
> Bill Venables
> http://www.cmis.csiro.au/bill.venables/
> 
> 
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of June Kim
> Sent: Thursday, 13 November 2008 10:27 AM
> To: r-help@r-project.org
> Subject: [R] metaprogramming with lm
> 
> Hello,
> 
> Say I want to make a multiple regression model with the following expression:
> 
> lm(y~x1 + x2 + x3 + ... + x_n,data=mydata)
> 
> It gets boring to type in the whole independent variables, in this
> case x_i. Is there any simple way to do the metaprogramming for this?
> (There are different cases where the names of the independent
> variables might sometimes have apparent patterns or not)
> 
> __
> R-help@r-project.org 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@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] metaprogramming with lm

2008-11-12 Thread Simon Blomberg
You can construct the formula on the fly. Say you have a data frame with
columns: y, x1,...x10:

dat <- data.frame(matrix(rnorm(1100), ncol=11, dimnames=list(NULL,c("y",
paste("x", 1:10, sep="")

Then you could construct the formula using:

form <- formula(paste("y ~ ", paste(names(dat)[which(names(dat) !=
"y")], collapse="+")))

fit <- lm(form, data=dat)

HTH,

Simon.


On Thu, 2008-11-13 at 09:27 +0900, June Kim wrote:
> Hello,
> 
> Say I want to make a multiple regression model with the following expression:
> 
> lm(y~x1 + x2 + x3 + ... + x_n,data=mydata)
> 
> It gets boring to type in the whole independent variables, in this
> case x_i. Is there any simple way to do the metaprogramming for this?
> (There are different cases where the names of the independent
> variables might sometimes have apparent patterns or not)
> 
> __
> R-help@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] chi square table

2008-11-06 Thread Simon Blomberg
> qchisq(0.01, df=8, lower.tail=FALSE)
[1] 20.09024
> 

See ?dchisq


On Fri, 2008-11-07 at 09:47 +0800, cruz wrote:
> Hi,
> 
> How do we get the value of a chi square as we usually look up on the
> table on our text book?
> 
> i.e. Chi-square(0.01, df=8), the text book table gives 20.090
> 
> > dchisq(0.01, df=8)
> [1] 1.036471e-08
> > pchisq(0.01, df=8)
> [1] 2.593772e-11
> > qchisq(0.01, df=8)
> [1] 1.646497
> >
> 
> nono of them give me 20.090
> 
> Thanks,
> cruz
> 
> __
> R-help@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] Convert text into a variable name

2008-11-05 Thread Simon Blomberg
?assign

On Thu, 2008-11-06 at 00:03 -0500, Xing Yuan wrote:
> Hello R users,
> 
> Does anybody know what command I should use to convert the text string "AGE"
> to be variable name AGE so I can assign value to it
> e.g. AGE = 39?
> 
> Thank you very much!
> 
> Joe
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] Proper way to write data frame with column and row names

2008-10-30 Thread Simon Blomberg
Try setting row.names=FALSE in the call to write.table. If you really
need those row names, create a variable containing the row names in the
data frame. Then use write.table with row.names=FALSE. 

HTH,

Simon.


On Fri, 2008-10-31 at 01:35 +, Daren Tan wrote:
> I need to write a data frame along with its column and row names to a text 
> file. However, the first row in the text file is always short of one element. 
> I have tried setting different parameters to write.table but that didn't help.
> 
> > m
>A B
> C 1 2
> D 3 4
> 
> Using write.table(m, "table.xls", sep="\t", col.names=T, row.names=T) gives
> 
> A B
> C 1 2
> D 3 4
> 
> __
> R-help@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] License Question

2008-10-28 Thread Simon Blomberg
I  downloaded the trial version and during the installation it told me that I 
had to install R first (from CRAN). So it looks like the R-PLUS interface is 
separate from R. They do not distribute R with R-PLUS. I'm in no way associated 
with this company, and I don't want or need a GUI for my own work. And its a 
Windows program. So I won't be using R-PLUS.

Simon.


Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia 
T: +61 7 3365 2506 
email: S.Blomberg1_at_uq.edu.au
http://www.uq.edu.au/~uqsblomb/

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.



-Original Message-
From: [EMAIL PROTECTED] on behalf of Barry Rowlingson
Sent: Tue 28/10/2008 6:40 PM
To: [EMAIL PROTECTED]
Cc: r-help@r-project.org; Duncan Murdoch
Subject: Re: [R] License Question
 
2008/10/28  <[EMAIL PROTECTED]>:

>   To answer your question, we do not distribute R.  We distribute  R-PLUS.

 But your web site claims, in big capital letters, that R-plus is "THE
REAL R". If you are not distributing R (the real real R, (c) The R
Foundation), then this could be construed as false advertising.

 So I'm guessing that R-plus must be an add-on to the real real R, in
which case you can't distribute R with R-plus under a non-free
license. You can unbundle it though, and tell your users to 'first go
get R'. I can't find an installation guide or a decent FAQ that
confirms this. As a non-lawyer, I'd advise you to remove 'The Real R'
from the web site and instead put 'Works With The Real R'. And explain
this in the FAQ. And give a link to www.r-project.org.

 Oh, btw, I'd fix your blog links: go to:
http://www.experience-rplus.com/blog.asp?b=act  and click a
screenshot...

Barry

__
R-help@r-project.org 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.


[[alternative HTML version deleted]]

__
R-help@r-project.org 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] Specifying random effects distribution in glmer()

2008-08-24 Thread Simon Blomberg
Are you trying to fit a Poisson GLMM with Gamma random effects? I don't
think you can do that using (g)lmer, which assumes a Gaussian
distribution for the random effects. You might have a look at the hnlmix
function in Jim Lindsey's repeated package. Or you could use Bayesian
methods in JAGS, BUGS etc. Usually Gamma random effects are multipliers,
not additive. So it makes sense to set the mean =1, unlike Gaussian
random effects with mean=0. This will place a restriction on the shape
and scale parameters.

HTH,

Simon.

On Sun, 2008-08-24 at 22:10 -0400, Robert A. LaBudde wrote:
> I'm trying to figure out how to carry out a Poisson regression fit to 
> longitudinal data with a gamma distribution with unknown shape and 
> scale parameters.
> 
> I've tried the 'lmer4' package's glmer() function, which fits the 
> Poisson regression using:
> 
> library('lme4')
> fit5<- glmer(seizures ~ time + progabide + timeXprog + 
> offset(lnPeriod) + (1|id),
>data=pdata, nAGQ=1, family=poisson) #note: can't use nAGQ>1, not 
> yet implemented
> summary(fit5)
> 
> Here 'seizures' is a count and 'id' is the subject number.
> 
> This fit works, but uses the Poisson distribution with the gamma 
> heterogeneity.
> 
> Based on the example in the help for glmer(), I tried
> 
> fit6<- glmer(seizures ~ time + progabide + timeXprog + offset(lnPeriod) +
>(1|pgamma(id, shap, scal)), data=pdata, nAGQ=1, start=c(shap=1, scal=1),
>family=poisson) #note: can't use nAGQ>1, not yet implemented
> summary(fit6)
> 
> but this ends up with "Error in pgamma(id, shap, scal) : object 
> "shap" not found".
> 
> My questions are:
> 
> 1. Can this be done?
> 2. Am I using the right package and function?
> 3. What am I doing wrong?
> 
> Any help would be appreciated.
> 
> Thanks.
> 
> 
> Robert A. LaBudde, PhD, PAS, Dpl. ACAFS  e-mail: [EMAIL PROTECTED]
> Least Cost Formulations, Ltd.URL: http://lcfltd.com/
> 824 Timberlake Drive Tel: 757-467-0954
> Virginia Beach, VA 23464-3239Fax: 757-467-2947
> 
> "Vere scire est per causas scire"
> 
> ______
> R-help@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] rgl/compiz problem

2008-08-13 Thread Simon Blomberg
My laptop has an nVidia card. Maybe that's why it works?

Simon.

On Wed, 2008-08-13 at 13:17 +, Ben Bolker wrote:
> Barry Rowlingson  lancaster.ac.uk> writes:
> 
> > 
> > I have just encountered the problem with rgl where plot3d figures
> > don't interact with the mouse. My plots zoom in and out with the mouse
> > wheel but the mouse buttons do nothing. I can't rotate the plot.
> > 
> > This has been mentioned and discussed here and in other lists before,
> > and the solution is to turn off Ubuntu's fancy graphics.  Back in
> > March, Ben Bolker said:
> > 
> > """
> > unfortunately rgl and compiz/etc. both try to use
> > the same OpenGL interface, so you can't use both at
> > the same time.
> > """
> > 
> > This has echoes of when TCP/IP was in its infancy back in the days of
> > DOS, and only one program could access the network interface at a time
> > (until TCP/IP software got its act together). Is OpenGL really in the
> > same position now? Or is Compiz being "greedy" in some sense? Surely
> > two OpenGL applications can run at the same time? Or is it because rgl
> > is running 'within' another OpenGL window already, so there's some
> > nesting problem going on?
> > 
> >  Google Earth works fine, and I think that uses OpenGL. Anyone had any
> > ideas since March?
> > 
> > I'm on Ubuntu 8.04 and R 2.7.1
> > 
> > Barry
> 
>   Unfortunately, an apparently knowledgeable compiz person
> said:
> 
> This is a limitation of DRI, DRI2 should fix this, and should hopefully be in
> most drivers by Xorg 7.5(maybe 7.6), nvidia has there on implementation, 
> that's
> why it works on it
> 
> http://forum.compiz-fusion.org/showthread.php?t=8462
> 
>   And poking around,
> 
> http://www.phoronix.com/scan.php?page=news_item&px=NjYzNw
> 
> "sometime in 2009" is the closest I could get to finding
> an expected date when this would be available ...
> 
>   Ben Bolker
> 
> __
> R-help@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] rgl/compiz problem

2008-08-13 Thread Simon Blomberg
Two days ago I installed compiz on my Debian laptop. It plays fine with the 
OpenGL games that I also have on that computer. (My son plays the games in the 
brief interludes between my intense R hacking sessions. I, of course, have no 
time for such frivolity. The production cycle is sleep -> eat -> R -> eat -> R 
-> eat -> sleep.) I can rotate and zoom using the touchpad, when both rgl and 
compiz are running.

Not sure if any of this is of help,

Simon.

Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consulta->nt Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia 
T: +61 7 3365 2506 
email: S.Blomberg1_at_uq.edu.au
http://www.uq.edu.au/~uqsblomb/

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.



-Original Message-
From: [EMAIL PROTECTED] on behalf of Barry Rowlingson
Sent: Wed 13/08/2008 9:45 PM
To: r-help@r-project.org
Subject: [R] rgl/compiz problem
 
I have just encountered the problem with rgl where plot3d figures
don't interact with the mouse. My plots zoom in and out with the mouse
wheel but the mouse buttons do nothing. I can't rotate the plot.

This has been mentioned and discussed here and in other lists before,
and the solution is to turn off Ubuntu's fancy graphics.  Back in
March, Ben Bolker said:

"""
unfortunately rgl and compiz/etc. both try to use
the same OpenGL interface, so you can't use both at
the same time.
"""

This has echoes of when TCP/IP was in its infancy back in the days of
DOS, and only one program could access the network interface at a time
(until TCP/IP software got its act together). Is OpenGL really in the
same position now? Or is Compiz being "greedy" in some sense? Surely
two OpenGL applications can run at the same time? Or is it because rgl
is running 'within' another OpenGL window already, so there's some
nesting problem going on?

 Google Earth works fine, and I think that uses OpenGL. Anyone had any
ideas since March?

I'm on Ubuntu 8.04 and R 2.7.1

Barry

__
R-help@r-project.org 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.


[[alternative HTML version deleted]]

__
R-help@r-project.org 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 95%CI around the median...

2008-08-04 Thread Simon Blomberg
See ?fivenum in the stats package. If you just type 

stats::fivenum

you will get the code. The crucial calculations are in the last few
lines.

Simon.

On Mon, 2008-08-04 at 16:19 +0930, Fernando Marmolejo Ramos wrote:
> Dear people
> 
> I've learnt that by using the "boxplot.stats" command in the "grDevices" 
> library
> I can get the 5-number summaries of a boxplot, plus other important 
> information,
> like the confidence interval around the median.
> 
> I'm interested in knowing the actual formula to used in that package to
> calculate that confidence interval.
> 
> Can someone help me with this?
> 
> Cheers,
> 
> Fernando
> 
> __
> R-help@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] Extract Element of String with R's Regex

2008-07-31 Thread Simon Blomberg
How about:

unlist(strsplit(x, split=" "))[c(4:5,10)]

That perl script looks like a good reason to avoid perl.

Simon.

On Fri, 2008-08-01 at 15:13 +0900, Edward Wijaya wrote:
> Hi,
> 
> I have this string, in which I want to extract some of it's element:
> 
> > x <- "Best-K Gene 11340 211952_at RANBP5  Noc= 3 - 2  LL= -963.669 -965.35"
> 
> yielding this array
> 
> [1] "211952_at"  "RANBP5" "2"
> 
> 
> 
> In Perl we would do it this way:
> 
> __BEGIN__
> my @needed =();
> my $str = "Best-K Gene 11340 211952_at RANBP5  Noc= 3 - 2  LL=
> -963.669 -965.35";
> $str =~ /Best-K Gene \d+ (\w+) (\w+) Noc= \d - (\d) LL= (.*)/;
> push @needed, ($1,$2,$3);
> __END___
> 
> How can we achieve this with R?
> 
>  - E.W.
> 
> __
> R-help@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] modeling binary response variables

2008-07-14 Thread Simon Blomberg
Jim Lindsey's repeated package has the function gnlmm which will fit
beta regressions with a random intercept and one level of nesting. I
don't know of any other options.

Cheers,

Simon.

 Not sure On Mon, 2008-07-14 at 19:16 -0700, Daniel Malter wrote:
> I have a connector-question to that. Is beta-regression available for
> repeated measures or panel data and if so is it available in R? 
> 
> thx,
> Daniel
> 
> 
> Kevin J Emerson wrote:
> > 
> > R-devotees,
> > 
> > I have a question about modeling in the case where the response variable
> > is
> > binary.
> > 
> > I have a case where I have a response variable that is the probability of
> > success, and four descriptor variables, The response has a sigmoid
> > response
> > with one of the variables. I would like to test for the effect of the
> > various descriptor variables on the percentage success of the binary
> > trait.
> > I have looked at glm with family = "binomial" but am not sure I totally
> > understand its use (and therefore am not sure it is the appropriate test)
> > and am looking for two things: (1) is glm with family = 'binomial' the
> > right
> > way to do this, and (2) are there any good references on how it works.
> > I have posted a plot of a sample of the data I am looking at as well as
> > the
> > sample data used to generate the plots.
> > 
> > Sample Plot: http://www.uoregon.edu/~kemerson/tmp/plot.pdf
> > Sample Data: http://www.uoregon.edu/~kemerson/tmp/data.csv
> > 
> > Response variable is percent.dev (se2.dev are the errors from binomial
> > estimates given probability and number of samples).
> > 
> > Descriptor variables are num.days, ppd, temp, and pop.  
> > 
> > Any help would be greatly appreciated.
> > 
> > Cheers,
> > Kevin Emerson
> > 
> > 
> > 
> > Kevin J. Emerson
> > Bradshaw - Holzapfel Lab
> > 1210 University of Oregon
> > Eugene, OR, 97403
> > email: [EMAIL PROTECTED]
> > web: http://evodevo.uoregon.edu/people/emerson.html
> > 
> > __
> > R-help@r-project.org 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.
> > 
> > 
> 
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] modeling binary response variables

2008-07-14 Thread Simon Blomberg
Wait, are the proportions (probabilities) based on discrete data, or are
they truly continuous? If the latter, then beta regression might be more
appropriate (e.g. package betareg). If the former, include the sample
size for each proportion in the call to glm using the weights= argument.
Or set the data up so you have a column of numbers of "successes" and a
column of "failures" and use the notation below. Multiplying your
proportion by an arbitrary large number is bad because you are in effect
fudging the precision of the proportion estimates.

HTH,

Simon.

On Mon, 2008-07-14 at 18:07 -0700, Daniel Malter wrote:
> Hi Kevin, you mean an s-shaped relationship of a variable with your response?
> So you have a response that is strictly constrained to the interval 0,1 or,
> and these limits are not due to truncation or censoring (i.e. your response
> variable is truly a proportion).
> 
> This sounds like a good application for a binomial model as fitting a linear
> model may give you a fit outside the limits of the interval that you are
> allowed to observe (0,1). The binomial logit (or probit, or cloglog) fixes
> that issue.
> 
> Since you have a proportion (the probability of success), you have something
> between 0 and 1. I suggest you to transform that by multiplying that
> proportion by say 100 (or 1000). Then you round this value to the next
> integer. Say Y is currently your proportion, do new.Y=round(Y*100). Then you
> create the number of observations that make up the counter-probability of
> your observation. counter.Y=100-Y.
> 
> Then you can run the binomial as follows:
> 
> reg=glm(cbind(new.Y,counter.Y)~predictors,binomial) ##runs the regression
> summary(reg) ##shows the summary output of your regression
> fitted(reg) ##shows the predicted values given your data matrix and your
> estimated model
> 
> You will want to check a.) whether you need a binomial (if your
> probabilities are actually reasonably distributed in a much smaller interval
> than 0,1, then you may be okay with a linear model).
> b.) if a binomial is more appropriate, you will want to check whether your
> data is overdispersed. Look at whether your degrees of freedom in the
> summary of your model are about equal to the log-likelihood of the model. If
> not, choose option quasibinomial instead of option binomial when fitting the
> model.
> 
> Best,
> Daniel
> 
> 
> 
> Kevin J Emerson wrote:
> > 
> > R-devotees,
> > 
> > I have a question about modeling in the case where the response variable
> > is
> > binary.
> > 
> > I have a case where I have a response variable that is the probability of
> > success, and four descriptor variables, The response has a sigmoid
> > response
> > with one of the variables. I would like to test for the effect of the
> > various descriptor variables on the percentage success of the binary
> > trait.
> > I have looked at glm with family = "binomial" but am not sure I totally
> > understand its use (and therefore am not sure it is the appropriate test)
> > and am looking for two things: (1) is glm with family = 'binomial' the
> > right
> > way to do this, and (2) are there any good references on how it works.
> > I have posted a plot of a sample of the data I am looking at as well as
> > the
> > sample data used to generate the plots.
> > 
> > Sample Plot: http://www.uoregon.edu/~kemerson/tmp/plot.pdf
> > Sample Data: http://www.uoregon.edu/~kemerson/tmp/data.csv
> > 
> > Response variable is percent.dev (se2.dev are the errors from binomial
> > estimates given probability and number of samples).
> > 
> > Descriptor variables are num.days, ppd, temp, and pop.  
> > 
> > Any help would be greatly appreciated.
> > 
> > Cheers,
> > Kevin Emerson
> > 
> > 
> > 
> > Kevin J. Emerson
> > Bradshaw - Holzapfel Lab
> > 1210 University of Oregon
> > Eugene, OR, 97403
> > email: [EMAIL PROTECTED]
> > web: http://evodevo.uoregon.edu/people/emerson.html
> > 
> > __
> > R-help@r-project.org 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.
> > 
> > 
> 
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://ww

Re: [R] Programming Concepts and Philosophy

2008-06-20 Thread Simon Blomberg
I read the Wizard Book too. Absolutely classic! I agree about paying attention 
to performance, of course. Lisp programmers bend over backwards to write 
tail-recursive functions for similar performance reasons. So you have to pay 
attention to the language's idiosyncracies. But the time spent coding is 
usually much longer than the eventual run time. Learning to write well-designed 
code can do more to save time, even if the run time is slightly longer than 
optimal. If run time is an issue, then switching to C or Fortran etc. might be 
the best bet. But even in that case, using R for prototyping code can provide 
valueable insights.

Cheers,

Simon.

Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia 
T: +61 7 3365 2506 
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.



-Original Message-
From: Wacek Kusnierczyk [mailto:[EMAIL PROTECTED]
Sent: Fri 20/06/2008 5:06 PM
To: R help
Cc: Simon Blomberg
Subject: Re: [R] Programming Concepts and Philosophy
 
Simon Blomberg wrote:
> I try to use a functional programming style. I define functions within
> functions when it is helpful in terms of information hiding. I avoid
> writing functions with side-effects as much as possible, so the only
> communication of the called function with the caller function is through
> the arguments and the returned value. I try to keep the code as simple
> and clear as possible (this is one of the things I fail at most). An
> appropriate amount of comments is also useful, especially when returning
> to old code after a long break. OOP is useful for really big projects,
> but I find OOP unnecessarily complicated for small jobs.
>
> I found "Code Complete", by McConnell (http://www.cc2e.com/) to be very
> helpful. I'm sure there are other books around with similar tips. Before
> I switched to R, I used XLisp-Stat. I found learning Lisp to be a really
> good way to learn good programming practices. Good Lisp code is the
> closest thing you can get to poetry in computer programming. "Lisp Style
> & Design", by Miller and Benson was helpful. I'd like to see an "S Style
> & Design."
>   

i support this view.  i found sicp (structure and interpretation of
computer programs, by abelson & sussman, a real classic in the field)
particularly enlightening, although it certainly is a bit outdated in
many respects -- but just a bit.  functional programming style is great,
but beware -- r will create (afaik, experts please correct me if this is
wrong) a deep copy of about any object you send as an argument to a
function (if only when it is actually used inside the function), and the
result may be that the more beautiful the code, the more the performance
sucks. 

in pure functional programming, a function cannot change any part of the
object passed to it as an argument, so there's no need for making a
local copy.  in r everything can happen as you can deparse the call to a
function inside the function body, and you can never tell whether the
object you pass to a function will be changed or not, given only the
function's signature.

vQ


[[alternative HTML version deleted]]

__
R-help@r-project.org 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] Programming Concepts and Philosophy

2008-06-19 Thread Simon Blomberg
I try to use a functional programming style. I define functions within
functions when it is helpful in terms of information hiding. I avoid
writing functions with side-effects as much as possible, so the only
communication of the called function with the caller function is through
the arguments and the returned value. I try to keep the code as simple
and clear as possible (this is one of the things I fail at most). An
appropriate amount of comments is also useful, especially when returning
to old code after a long break. OOP is useful for really big projects,
but I find OOP unnecessarily complicated for small jobs.

I found "Code Complete", by McConnell (http://www.cc2e.com/) to be very
helpful. I'm sure there are other books around with similar tips. Before
I switched to R, I used XLisp-Stat. I found learning Lisp to be a really
good way to learn good programming practices. Good Lisp code is the
closest thing you can get to poetry in computer programming. "Lisp Style
& Design", by Miller and Benson was helpful. I'd like to see an "S Style
& Design."

Cheers,

Simon.


On Fri, 2008-06-20 at 14:35 +1200, Murray Jorgensen wrote:
> I am wondering if people on the list could recommend books that they 
> have found helpful about programming concepts and style? I often find 
> that students write R programs by copying existing code but could really 
> benefit from the understanding of more general programming ideas. An 
> example would be to avoid writing functions which attempt to modify 
> their parameters. Another principle would be not to write programs with 
> numbers used as constants but to assign them to named objects as in
> 
> n <- 120 # number of observations
> p <- 10  # number of variables
> 
> near the beginning of a program rather than using "10" and "120" 
> throughout the script.
> 
> This sort of stuff is not specifically R but can be a problem for 
> students with little programming background.
> 
> I am happy to summarise responses.
> 
> Murray Jorgensen
> 
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] model simplification using Crawley as a guide

2008-06-11 Thread Simon Blomberg

> > Good points Ben.  For now I'd recommend simply that the allergic 
> > reaction to insignificant statistical tests be treated with an 
> > antihistamine :-)
> 
> 
> A vote for Frank's comment to be added to the 'fortunes' package.
> 
Seconded! :-)

> :-)
> 
> Regards,
> 
> Marc
> 
> __
> R-help@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] newbie nls question

2008-06-10 Thread Simon Blomberg
On Tue, 2008-06-10 at 16:56 -0600, Ranney, Steven wrote:
> I'm tyring to fit a relatively simple nls model to some data, but keep coming 
> up against the same error (code follows):
> 
> Oto=nls(Otolith ~ Linf*(1-exp(-k(AGE-to))), 
> data = ages, 
> start = list(Linf=1000, k=0.1, to=0.1), 
> trace = TRUE) 


Try putting a * in after the k in the formula.

Simon.

> 
> The error message I keep getting is "Error in eval(expr, envir, enclos) : 
> could not find function "k"".  I've used this line of code for other nls 
> models (with different data, parameter estimates, etc.), but have never 
> gotten this error.  The data is 
> 
> AGE,Otolith,Scale
> 1,207.1052632,207.1052632
> 2,329.962963,332.7586207
> 3,401.9473684,406
> 4,422,413.111
> 5,452.6785714,458.34375
> 6,510.75,533
> 7,477,674
> 8,643,704
> 9,,615
> 10,695.5,
> 12,615,
> 
> Are the missing values (e.g., no value for Otolith, AGE 9) having an effect?  
> I am using Tinn-R as an editor  
> 
> I'm new to R, trying to get away from Rcmdr (though it has been helpful), and 
> still trying to learn the language with the aid of several books on the R.  A 
> search of the R Archive did not prove fruitful.
> 
> Thanks in advance, 
> 
> SR
> 
> Steven H. Ranney
> Graduate Research Assistant (Ph.D)
> USGS Montana Cooperative Fishery Research Unit
> Montana State University
> PO Box 173460
> Bozeman, MT 59717-3460
> 
> phone: (406) 994-6643
> fax:   (406) 994-7479
> 
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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 automatically create objects with names from a string list?

2008-06-03 Thread Simon Blomberg
Or with mapply

name <- c("foo", "bar", "baz")
val <- 1:3
mapply(assign, name, val, pos=1)

Cheers,

Simon.


On Tue, 2008-06-03 at 22:24 -0700, Moshe Olshansky wrote:
> You can use either assign or eval.
> 
> Something like
> 
> > name <- c("foo", "bar", "baz")
> > for (i in 1:length(name)) assign(name[i],i)
> 
> 
> 
> --- On Wed, 4/6/08, Mark Farnell <[EMAIL PROTECTED]> wrote:
> 
> > From: Mark Farnell <[EMAIL PROTECTED]>
> > Subject: [R] how to automatically create objects with names from a string 
> > list?
> > To: R-help@r-project.org
> > Received: Wednesday, 4 June, 2008, 3:15 PM
> > Suppose I have a string of objects names:
> > 
> > name <- c("foo", "bar",
> > "baz")
> > 
> > and I would like to use a for loop to automatically create
> > three
> > objects called "foo", "bar" and
> > "baz" accordingly.  Then how can this
> > be done" (so that in the workspace, foo = 1, bar = 2
> > and baz=3)
> > 
> > for (i in name) {
> > .
> > }
> > 
> > Thanks!
> > 
> > Mark
> > 
> > __
> > R-help@r-project.org 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@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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 understanding why #function(x, y) (if((x-y)>=0) {2^(x-y)} else{-(2^abs(x-y))})# doesn't work like I think it should

2008-06-03 Thread Simon Blomberg
Use ifelse() rather than if () {} else {}. It's vectorized and very
useful for applying to elements along vectors. The latter idiom is much
better for control of flow in programs and functions.

 folds <- function (x, y) ifelse(x-y >= 0, 2^(x-y), -(2^abs(x-y)))

 z <- folds(x, y)
> z
[1]   16144   -44 -256
> 

?function works for me. Here's my setup:

R version 2.7.0 (2008-04-22) 
x86_64-pc-linux-gnu 

Cheers,

Simon.


On Tue, 2008-06-03 at 20:47 -0500, ALAN SMITH wrote:
> Hello R users and developers,
> I am trying to write several functions (fairly new at this) in order
> to avoid using loops on large data frames (because they are slow).  I
> wrote the function below and it seems to get hung on the first part of
> the if statement and then applies that condition to rest of the
> function.  So if (x-y) is greater than 0 the function uses the true
> statement for the calculations.   Could someone please offer some
> advise on how to write these functions a little better or a type
> "apply" that I may use with two (or more) different vectors of data
> required by a single functions.
> ###  Examples
> ###
> ## example 1 ###
> x<-c(5,6,4,3,5,3,1)
> y<-c(1,6,2,1,7,1,9)
> folds<-function(x,y) (if((x-y)>=0) {2^(x-y)} else{-(2^abs(x-y))})
> z<-folds(x,y)
> check<-cbind(x,y,z)
> View(check)
> 
> Warning message:
> In if ((x - y) >= 0) { :
>   the condition has length > 1 and only the first element will be used
>  ### why will it only use the first element and how to I get around
> this 
> 
> ## example 2 making the fist comparison negative ###
> x1<-c(5,6,4,3,5,3,1)
> y1<-c(11,6,2,1,7,1,9)
> folds<-function(x,y) (if((x-y)>=0) {2^(x-y)} else{-(2^abs(x-y))})
> z1<-folds(x1,y1)
> check2<-cbind(x1,y1,z1)
> View(check2)
> Warning message:
> In if ((x - y) >= 0) { :
>   the condition has length > 1 and only the first element will be used
> 
>  loop I am trying to avoid writing many many times #
> folds2<-NULL
> xy<-as.data.frame(cbind(x,y))
> for (i in 1:nrow(xy)) {
> diff<-xy$x[i]-xy$y[i]
> folds2[i]<-if(diff>=0) {2^diff} else{-(2^abs(diff))}
> }
> xyz<-cbind(xy,folds2)
> View(xyz)
> #
> 
> Thank you,
> Alan
> 
> P.S.  why does ?function not work
> 
> ______
> R-help@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] R help needed

2008-05-21 Thread Simon Blomberg
Try:

dat <- read.table("/Users/kamleshkumar/Desktop/DS1.txt", header=TRUE)

Please also read the F documentation. The use of read.table is in "An
Introduction to R" for example.

Simon.

On Wed, 2008-05-21 at 08:13 +0200, Kamlesh Kumar wrote:
> Dear Sir/Madam,
>  I have tried to upload data in R but it showing some error
>   in command window. It's should be noted that I am using Mac version of
>   R. I am using Mac-text for writing my data. I am getting following
>   message on the command window.
> 
>   > source("/Users/kamleshkumar/Desktop/DS1.txt")
>   Error in source("/Users/kamleshkumar/Desktop/DS1.txt") :
> /Users/kamleshkumar/Desktop/DS1.txt: unexpected symbol at
>   1: x y
> I am attaching the the DS1.txt file also with this mail.
>   Please go through it and guide me about this. I am waiting for a reply
>   from your side. Thanking you.
>   Yours Sincerely,
>   Kamlesh Kumar
> 
> 
> __
> R-help@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] algorithmic or automatic differentiation

2008-05-07 Thread Simon Blomberg
No, computer algebra systems such as yacas do symbolic differentiation.
Automatic differentiation is a numerical technique that can be used to
find derivatives of functions that can be implemented as computer
programs, through successive uses of the chain rule on the computer code
itself. It would be cool if R could either do AD or interface to an AD
package. R can be used with ADmodelbuilder (see
http://otter-rsch.ca/admbre/examples/glmmadmb/glmmADMB.html) , a
proprietry program, but an open source solution would be nice.

Cheers,

Simon.


On Thu, 2008-05-08 at 03:09 +, David Winsemius wrote:
> "Erin Hodgess" <[EMAIL PROTECTED]> wrote in 
> news:[EMAIL PROTECTED]:
> 
> > Is there a package for automatic differentiation, please?
> > 
> 
> Have you looked at Goedman, Grothendieck, Hojsgaard, and Pinkus' Ryacas?
> 
> >From the Ryacas documentation:
> Analytical derivatives of functions can be evaluated with the D() and 
> deriv() functions:
> 
> > yacas("D(x) Sin(x)")
> 
> expression(cos(x))
> 
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] categorical data analysis

2008-05-06 Thread Simon Blomberg
But see these posts:

http://finzi.psych.upenn.edu/R/Rhelp02a/archive/119079.html

http://finzi.psych.upenn.edu/R/Rhelp02a/archive/119080.html

Simon.

On Tue, 2008-05-06 at 13:38 -0600, Greg Snow wrote:
> Fisher's exact test works with small cells.  See ?fisher.test
> 
> --
> Gregory (Greg) L. Snow Ph.D.
> Statistical Data Center
> Intermountain Healthcare
> [EMAIL PROTECTED]
> (801) 408-8111
> 
> 
> 
> > -Original Message-
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] On Behalf Of raymond chiruka
> > Sent: Tuesday, May 06, 2008 10:34 AM
> > To: r
> > Subject: [R] categorical data analysis
> >
> > hie all
> >
> >
> > i am trying to carry out a categorical data analysis but my
> > problem is that when in i use the chi squared  test some of
> > my  expected values are less than 5. is there a  test that
> > can handle this situation. the data is not a 2*2 table. its
> > more from the social sciences where you have from strongly
> > agree to strongly disagree. i know i can collapse vthe tables
> > but there is a loss of information . is the a test vthat i
> > can for this kind of data.
> > thanks in advancde.
> >
> > ray
> >
> >
> >
> > -
> > [[elided Yahoo spam]]
> > [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org 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@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

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


Re: [R] Equivalent of Excel pivot tables in R

2008-04-26 Thread Simon Blomberg
See also the reshape package.

Cheers,

Simon.

Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia 
T: +61 7 3365 2506 
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.



-Original Message-
From: [EMAIL PROTECTED] on behalf of ppaarrkk
Sent: Sat 26/04/2008 7:54 AM
To: r-help@r-project.org
Subject: [R]  Equivalent of Excel pivot tables in R
 

Can somebody tell me how to do the equivalent of a pivot table in R ?


For example, if I have :

var1var2   var3
a x10
b y20
a z10
b z20
a z10
b z20

I could have :

  x   y   z
a1   0   2 
b0   1   2

where entries in the table are counts of var3.

  x   y   z
a10   0   20 
b0   20   40

where entries are sums of var3.



I would expect it to be tapply(), but I can't see how it would be done.


Any suggestions please.


-- 
View this message in context: 
http://www.nabble.com/Equivalent-of-Excel-pivot-tables-in-R-tp16906289p16906289.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org 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.


[[alternative HTML version deleted]]

__
R-help@r-project.org 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] vector in filename

2008-04-17 Thread Simon Blomberg
How about this:

x <- 1
y <- 1
mmax <- 10

my.files <- paste("foo", x:mmax, ".png", sep="")

for (i in my.files) {
png(filename=i, pointsize=20, width=600, height=600, units="px",
bg="#eaedd5")
plot(x, y)
dev.off()
x <- x+1
y <- y+1
}

Normally I would avoid for loops, but I think this application is a
legitimate use.

Cheers,

Simon.

On Fri, 2008-04-18 at 03:05 +0200, [Ricardo Rodriguez] Your XEN ICT Team
wrote:
> Hi,
> 
> I am trying to generate a group of graphics with an iteration. Some 
> thing like this...
> 
> x=1
> y=1
> max=10
> myfiles <- paste("foo", x:max, ".png", sep="")
> while (x =< max)
> {
> png(file=myfiles, pointsize = 20, width = 600, height = 600, 
> units = "px", bg="#eaedd5")
> plot(x,y)
> dev.off()   
> x=x+1
> y=y+1
> }
> 
> I am getting only one *.png file with the name of the first position in 
> myfiles and the content of the last graphic in the iteration. Please, 
> could you tell me if it is possible to iterate file= in any other way?
> 
> Thanks!
> 
> Ricardo
> 
> 
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] [R-sig-ME] Post hoc tests with lme

2008-04-16 Thread Simon Blomberg
Try glht in package multcomp.

Simon.

On Wed, 2008-04-16 at 12:00 -0400, Gang Chen wrote:
> = 1), c(TypeT2 = 1))) :
>   Only defined for lm,glm objec
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] "preferred" version of Linux for R?

2008-04-08 Thread Simon Blomberg
There are binaries on CRAN for several distros. There is the
R-sig-debian list for debian users. As far as I know, there are no
mailing lists for other distros. This may indicate a preference for
debian among R users. Or it may mean that debian is so difficult to use
with R that it requires a mailing list. :-) As a debian user, I prefer
the first explanation.

Cheers,

Simon.

On Tue, 2008-04-08 at 13:36 -0700, Thomas Pujol wrote:
> Is there a recommended/preferred version of Linux for using with R? Is there 
> one version of Linux that R-users prefer, and/or that works "better" with R?  
> I am working with "large" datasets, and hope to take advantage of as much RAM 
> as reasonable (8-32gb?).
> 
> Thanks in advance!
> 
> 
>
> -
> [[elided Yahoo spam]]
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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 pack my stuff into a package (library, collection)?

2008-04-06 Thread Simon Blomberg
On Mon, 2008-04-07 at 15:13 +0900, Tribo Laboy wrote:
> Hello,
> 
> I am new useR, I have written some functions, which I currently use by
> "source"-ing them from the files.
> That's OK, but when I my functions start counting in the tens and
> hundreds I'd be glad to be able to type
> "help.search("my_obscure_fun")" and get a sensible reply. I also want
> to be able to load them as a package at startup and not have to
> "source" each one individually. I read through the "Writing R
> Extensions" file, but I am overwhelmed with the vast amount of
> prescribed detail that Extension Authors must follow - directory
> structure, file structure, etc. Luckily, I found the "prompt"
> function, which helps in writing of help-files in the form of "fill-in
>  the blanks". But that's only for the help-files. Reading further, it
> gets even more complicated. The user is referred to the "R
> Installation and Administration" document, which says that:
> 
> If you want to build R or add-on packages from source in Windows, you
> will need to collect, install and test an extensive set of tools.
> 
> These seem to include among others Perl and compiler. But R is an
> interpreted and cross-platform language, I don't understand the need
> for additional platform specific tools just to call a user collection
> of R-files. Anyone knows of a smooth introduction to these topics?
> 

Have a look at ?package.skeleton. It should get you started. If you just
want to build packages with pure R (no shared libraries etc.), I think
you won't need the other tools.

Cheers,

Simon.

> Rgards,
> TL
> 
> __
> R-help@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] Finding a mean value of a variable holding a dummy variablefixed

2008-03-30 Thread Simon Blomberg
How about this? :-)

president <- c("Johnson", "Johnson", "Johnson"," Johnson"," Johnson",
"Johnson","Nixon", "Nixon", "Nixon", "Nixon", "Nixon", "Nixon")
approval <- c(3,4,5,6,7,8,6,5,4,3,2,1)

fn <- function (x) c(first=x[1], last=x[length(x)], mean=mean(x))
lst <- tapply(approval, president, fn) 

# Or if you need a data.frame: 

res <-  data.frame(matrix(unlist(lst), byrow=TRUE,
dimnames=list(names(lst), names(lst[[1]])), ncol=3))

Cheers,

Simon.

On Sun, 2008-03-30 at 23:21 -0400, Daniel Malter wrote:
> I found a solution. It's probably not the easiest one, but it works.  It
> assumes that your data frame is ordered from earliest to latest record for
> each president, but it can be easily adjusted if you want to make it
> dependent on a third column. The final vector "index" gives you the line
> indices for the first record for each president. If you replace "min" by
> "max" you get the last instead of the first record. You can then find the
> values by
> 
> 
> ##Sample data
> 
> president=c("Johnson","Johnson","Johnson","Johnson","Johnson","Johnson","Nix
> on","Nixon","Nixon","Nixon","Nixon","Nixon")
> approval=c(3,4,5,6,7,8,6,5,4,3,2,1)
> tapply(approval,president,mean)
> 
> ##Find index for first row of each president; assumes ascending order of
> observations; change "min" to "max" to find last record
> 
> index=NULL
> for(i in 1:length(unique(president)))
>   index[i]=min(which((president==unique(president)[i])==TRUE))
> 
> index
> 
> ##Generate table with first approvals
> 
> first.approval=data.frame(cbind(index,president[index],approval[index]))
> names(first.approval)=c("Index","President","Approval")
> first.approval
> 
> Cheers,
> Daniel
> 
> 
> 
> 
> -
> cuncta stricte discussurus
> -
> 
> -Ursprüngliche Nachricht-
> Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im
> Auftrag von Alexander Ovodenko
> Gesendet: Sunday, March 30, 2008 9:47 PM
> An: r-help@r-project.org
> Betreff: [R] Finding a mean value of a variable holding a dummy
> variablefixed
> 
> I have time-series data on approval ratings of British Prime Ministers.  The
> prime ministers dating from MacMillan onward till today are coded as dummy
> variables and the approval ratings are entered for each month.  I want to
> know the mean value of the approval rating of each Prime Minister in the
> dataset and the approval rating during his/her first month and last month as
> PM.  What R code should I enter for these data?  In other words, I want hold
> the dummy corresponding to each Prime Minister fixed at value one and know
> the first rating that PM has, the last rating s/he has, and the mean rating
> s/he has.  Thanks.
> 
>   [[alternative HTML version deleted]]
> 
> ______
> R-help@r-project.org 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@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] Compare parameter estimates of a nlsList object

2008-03-28 Thread Simon Blomberg
Use nlme. Here is an example, fitting the Michaelis-Menten model to some enzyme 
data:

library(nlme)
data(Puromycin)
fit.nls <- nlsList(rate ~ SSmicmen(conc, Vm, K)|state, data=Puromycin)
summary(fit.nls)

# Use the output to calculate starting values for the nlme fit.

fit.nlme <- nlme(rate ~ SSmicmen(conc, Vm, K), fixed=Vm+K~state, groups=~state, 
start=c(212, -52, 0.06,- 0.01), data=Puromycin)

summary(fit.nlme)

You get explicit tests between the states for each of the two model parameters. 
This example is from Pinheiro and Bates. Thankyou Jose and Doug! I use it in a 
course that I teach.

Cheers,

Simon.

Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia 
T: +61 7 3365 2506 
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.



-Original Message-
From: [EMAIL PROTECTED] on behalf of Joerg van den Hoff
Sent: Fri 28/03/2008 8:10 PM
To: Frank Scherr
Cc: r-help@r-project.org
Subject: Re: [R] Compare parameter estimates of a nlsList object
 
On Wed, Mar 26, 2008 at 05:27:22PM +1300, Frank Scherr wrote:
> Hello together,
>  
> Is there a tool to test the statistical differences between parameter 
> estimates of a nlsList fit?
>  
> I fitted degradation data using the nlsList method and want to find out 
> whether derived rate constants are significantly different from each other at 
> the grouping factors soil and temperature.
>  

here is a physicist's (not a mathematician's)  answer:

from each nls-fit you get an estimate of the std. error of the parameter
estimate.

so you have,e.g., (a1  +/- del_a1) from fit 1 and (a2 +/- del_a2) -- where
a1 and a2 are actually the same parameter in the model -- from fit 2.
since you thus have actual estimated errors, I'd simply ask "what is the error
estimate of the difference", i.e.

a1 - a2

and, assuming independent underlying data,
compute this by gaussian error propagation (i.e. assuming normal
distributions of the parameter estimates). here, the variances (squares
of ths std. errors) add up:

del_[a1-a2]^2 = del_a1^2 + del_a2^2

if (a1-a2) +/- del_[a-a2]  (or rather 2-3 times that error) is
compatible with zero, a and a2 do not differ significantly, else
they do.

HTH

joerg

__
R-help@r-project.org 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.


[[alternative HTML version deleted]]

__
R-help@r-project.org 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] create matrix

2008-03-20 Thread Simon Blomberg
There may be a less baroque way of doing it, but does this do what you want?

Say you have a data.frame called dat:

> dat
  x1 x2 Longevity
1 -1.9582519  a 4
2  0.8724081  b 2
3 -0.9150847  c 5

# now create a new long data.frame:

> dat.long <- as.data.frame(mapply(function (x) rep(x, dat$Longevity), 
> dat[,1:2]))

# Add in the survival column:

> dat.long$Survival <- unlist(sapply(dat$Longevity, function (x) c(rep(0, 
> x-1),1)))
> dat.long
  x1 x2 Survival
1  -1.95825191986208  a0
2  -1.95825191986208  a0
3  -1.95825191986208  a0
4  -1.95825191986208  a1
5  0.872408144284977  b0
6  0.872408144284977  b1
7  -0.91508470125413  c0
8  -0.91508470125413  c0
9  -0.91508470125413  c0
10 -0.91508470125413  c0
11 -0.91508470125413  c    1

HTH,

Simon.
 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia 
T: +61 7 3365 2506 
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.



-Original Message-
From: [EMAIL PROTECTED] on behalf of Felix Zajitschek - UNSW
Sent: Thu 20/03/2008 4:51 PM
To: r-help@r-project.org
Subject: [R] create matrix
 
Hi all,
 
I have a dataset consisting of 5 columns and over 5000 rows. Each row
gives information about an individual animal, including longevity, i.e.
at what age an animal died.
For the model I use I need to create n rows for each animal, n being its
longevity, and a new column 'survival' with a binary 0/1 outcome. When
an animal died e.g. at age 5, there have to be 5 rows of identical data,
except 4 with 0 (=alive) for 'survival', and 1 row with '1' for
'survival'.
 
I thought of creating matrices for each individual, adding first one
column 'survival' containing zeros to the original dataset, then
creating matrices with data = 'the vector containing all elements of an
individual/row' ([1,], nrow = [a,b], exctracting the element for
longevity, and then with byrow = TRUE letting the data be filled in by
row. At the end I would have to set the last element in 'survival' to
'1', and then combine all matrices into one single one.
 
So far I've used Excel to create these datesets manually, but with more
than 1000 individuals this gets really tedious. I haven't used R before
for this sort of a bit more advanced data manipulation, and I would
really appreciate any input/primer about how people would go about doing
this.
 
Thanks,
Felix
 
 
__
::Felix Zajitschek 
Evolution & Ecology Research Centre
School of Biological, Earth and Environmental Sciences 
University of New South Wales - Sydney NSW 2052 - Australia 
Tel   +61 (0)2 9385 8068
Fax  +61 (0)2 9385 1558 
eMail   <mailto:[EMAIL PROTECTED]>
[EMAIL PROTECTED]

<http://www.bees.unsw.edu.au/school/researchstudents/zajitschekfelix.htm
l> www.bees.unsw.edu.au/school/researchstudents/zajitschekfelix.html


[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


[[alternative HTML version deleted]]

__
R-help@r-project.org 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] generalized linear mixed models with a beta distribution [Sec=Unclassified]

2008-03-16 Thread Simon Blomberg
See this post:

http://finzi.psych.upenn.edu/R/Rhelp02a/archive/7144.html

Cheers,

Simon.

On Mon, 2008-03-17 at 17:04 +1100, Steve Candy wrote:
> 
> Craig A Faulhaber wrote:
> 
>  
> 
> >I am interested in using a generalized linear mixed model with data 
> 
> > that best fits a beta distribution (i.e., the data is bounded between 
> 
> > 0 and 1 but is not binomial).
> 
> ..
> 
> >For clarification, here's what I'm trying to model:
> 
> >I have a beta-distributed response variable (y).  I have a fixed-effect
> 
> 
> >explanatory variable (treatment), and I'd like to include a random term
> 
> 
> >for individuals used in the experiment.  The model in lmer would be:  y
> 
> 
> >~ treatment + (1 | individual).   As far as I can tell, the appropriate
> 
> 
> >link function for the model would be the logit.
> 
>  
> 
> If you want to use a GLM you could use the binomial/logit
> quasi-likelihood approach for your ratio. Say the ratio is r=n/N then
> use binomial n with binomial total N (these do not have to be integers)
> but remember to use prior weights of 1/N and estimate the
> over-dispersion parameter. If you use the ratio, r, directly with a
> binomial total of 1 then the prior weights are simply 1 and can be
> ignored. This quasi-likelihood approach for a ratio was given by
> Wedderburn (1974) (see McCullagh and Nelder, 1989, Sec 9.2.4). BTW
> random effects with a beta distribution included in the linear predictor
> via a link function such as the logit can be fitted as a HGLM
> (Hierarchical Generalized Linear Model)(Lee and Nelder, 1996, 2001) for
> binomial data (i.e. considered binomial conditional on the random
> effects). Only the GenStat package is set up to fit HGLMs (as far as I
> know). (L & N, 1996, J.R.Statist.Soc B 58, 619-678; L & N 2001
> Biometrika 88, 987-1006).
> 
>  
> 
> Hope this helps
> 
> Steve Candy
> 
>  
> 
> 
> ___
> 
> Australian Antarctic Division - Commonwealth of Australia
> IMPORTANT: This transmission is intended for the addressee only. If you are 
> not the
> intended recipient, you are notified that use or dissemination of this 
> communication is
> strictly prohibited by Commonwealth law. If you have received this 
> transmission in error,
> please notify the sender immediately by e-mail or by telephoning +61 3 6232 
> 3209 and
> DELETE the message.
> Visit our web site at http://www.antarctica.gov.au/
> ___
> 
>   [[alternative HTML version deleted]]
> 
> ______
> R-help@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] Lme does not work without a random effect (UNCLASSIFIED)

2008-03-15 Thread Simon Blomberg
There's a trick with this: you need to make sure you are using anova.lme rather 
than anova.lm. So if in this example you do 

anova(fit0, fit)

you will get an error.

Simon.

Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia 
T: +61 7 3365 2506 
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.



-Original Message-
From: [EMAIL PROTECTED] on behalf of Sundar Dorai-Raj
Sent: Sat 15/03/2008 5:40 AM
To: Park, Kyong H Mr ECBC
Cc: 'r-help@r-project.org'
Subject: Re: [R] Lme does not work without a random effect (UNCLASSIFIED)
 


Park, Kyong H Mr ECBC said the following on 3/14/2008 12:25 PM:
> Classification:  UNCLASSIFIED 
> Caveats: NONE
> 
> Dear R users,
> 
> I'm interested in finding a random effect of the Block in the data shown
> below, but 'lme' does not work without the random effect. I'm not sure how
> to group the data without continuous value which is shown in the error
> message at the bottom line. If I use 'aov' with Error(Block), is there a
> test method comparing between with and without the Block random effect. I'm
> using R 2.4.1.
> 
> Appreciate your help.
> 
> Kyong  
> 
>  LCU ST1 SURF Block
> 1  6.71   AN 1
> 2  6.97   AY 1
> 3  6.77   BN 1
> 4  6.90   BY 1
> 5  6.63   CN 1
> 6  6.94   CY 1
> 7  6.79   DN 1
> 8  6.93   DY 1
> 9  6.23   AN 2
> 10 6.83   AY 2
> 11 6.61   BN 2
> 12 6.86   BY 2
> 13 6.51   CN 2
> 14 6.90   CY 2
> 15 5.90   DN 2
> 16 6.97   DY 2
> 
> A result with the random effect:
> 
> Anal1<-lme(LCU~ST1*SURF,random=~1|Block,data=data1)
>> summary(Anal1)
> Linear mixed-effects model fit by REML
>  Data: data1 
>AIC  BIClogLik
>   25.38958 26.18399 -2.694789
> 
> Random effects:
>  Formula: ~1 | Block
> (Intercept) Residual
> StdDev:   0.1421141 0.218483
> 
> Fixed effects: LCU ~ ST1 * SURF 
>  Value Std.Error DF  t-value p-value
> (Intercept)  6.470 0.1842977  7 35.10625  0.
> ST1B 0.220 0.2184830  7  1.00694  0.3475
> ST1C 0.100 0.2184830  7  0.45770  0.6610
> ST1D-0.125 0.2184830  7 -0.57213  0.5851
> SURFY0.430 0.2184830  7  1.96812  0.0897
> ST1B:SURFY  -0.240 0.3089816  7 -0.77675  0.4627
> ST1C:SURFY  -0.080 0.3089816  7 -0.25892  0.8031
> ST1D:SURFY   0.175 0.3089816  7  0.56638  0.5888
> 
> Without the random effect:
> 
> Anal2<-lme(LCU~ST1*SURF,data=data1)
> Error in getGroups.data.frame(dataMix, groups) : 
> Invalid formula for groups
> Classification:  UNCLASSIFIED 
> Caveats: NONE
> 
> 

Use "lm" to fit the model without random effect and use anova to compare:

z <- read.table(con <- textConnection(" LCU ST1 SURF Block
1  6.71   AN 1
2  6.97   AY 1
3  6.77   BN 1
4  6.90   BY 1
5  6.63   CN 1
6  6.94   CY 1
7  6.79   DN 1
8  6.93   DY 1
9  6.23   AN 2
10 6.83   AY 2
11 6.61   BN 2
12 6.86   BY 2
13 6.51   CN 2
14 6.90   CY 2
15 5.90   DN 2
16 6.97   DY 2"), header = TRUE)
close(con)

library(nlme)
fit <- lme(LCU~ST1*SURF,random=~1|Block,data=z)
fit0 <- lm(LCU~ST1*SURF,data=z)
anova(fit, fit0)

HTH,

--sundar

__
R-help@r-project.org 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.


[[alternative HTML version deleted]]

__
R-help@r-project.org 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 turn a string into a variable name ?

2008-03-13 Thread Simon Blomberg
Or maybe use assign?

> assign("natural_nums", 1:10)
> natural_nums
 [1]  1  2  3  4  5  6  7  8  9 10
> 

Cheers,

Simon.

On Fri, 2008-03-14 at 14:39 +1000, [EMAIL PROTECTED] wrote:
> I'm not sure why you would wish to do so, but it can be done:
> 
> > natural_nums <- 1:10
> > even_nums <- seq(2,10, by = 2)
> > types <- c("natural_nums", "even_nums")
> 
> > types <- lapply(types, as.name)  ## list of variable names
> > types
> [[1]]
> natural_nums
> 
> [[2]]
> even_nums
> 
> > eval(types[[1]])
>  [1]  1  2  3  4  5  6  7  8  9 10
> > eval(types[[2]])
> [1]  2  4  6  8 10 
> 
> 
> Bill Venables
> CSIRO Laboratories
> PO Box 120, Cleveland, 4163
> AUSTRALIA
> Office Phone (email preferred): +61 7 3826 7251
> Fax (if absolutely necessary):  +61 7 3826 7304
> Mobile: +61 4 8819 4402
> Home Phone: +61 7 3286 7700
> mailto:[EMAIL PROTECTED]
> http://www.cmis.csiro.au/bill.venables/ 
> 
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> On Behalf Of Ng Stanley
> Sent: Friday, 14 March 2008 1:27 PM
> To: r-help
> Subject: [R] How to turn a string into a variable name ?
> 
> Hi,
> 
> For example,
> 
> natural_nums <- 1:10
> even_nums <- seq(2,10, by = 2)
> types <- c("natural_nums", "even_nums")
> 
> What functions can be performed on types[1] to turn it into a variable
> name
> and not a string ?
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org 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@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] glm: offset

2008-03-02 Thread Simon Blomberg
Yes, use the log. I've had the same problem in the past, too. Try it on
a toy example to confirm it for yourself.

Cheers,

Simon.

On Sun, 2008-03-02 at 22:01 -0500, John Sorkin wrote:
> R 2.6.0
> Windows XP
> 
> A question about running a generalized linear model.
> 
> I am running a glm with
> (1) a poisson distribution and a log link:
>family=poisson(link = "log")
> and an offset.
> I would like to know if I should express the offset as the log of the offset 
> value, i.e.
> offset=log(NumUniqPt)
> or as:
> offset=NumUniqPt
> 
> I suspect I need to use the log, bu t I can't find any discussion of this in 
> MASS 1994 or on the man page for glm.
> Thanks 
> John
> 
> 
> John Sorkin M.D., Ph.D.
> Chief, Biostatistics and Informatics
> University of Maryland School of Medicine Division of Gerontology
> Baltimore VA Medical Center
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
> (Phone) 410-605-7119
> (Fax) 410-605-7913 (Please call phone number above prior to faxing)
> 
> Confidentiality Statement:
> This email message, including any attachments, is for th...{{dropped:6}}
> 
> __
> R-help@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] If else in R code

2008-02-07 Thread Simon Blomberg
How about:

a<-c("2001-02-1",NA,NA)
b<-c("2001-03-1","2001-03-2","2001-03-3")

 res <- ifelse(is.na(a), as.character(as.Date(b)-2),
as.character(as.Date(a)))
res

Or with no ifelse:

 res <- a
 res[is.na(a)] <- as.character(as.Date(b[is.na(a)])-2)
 res

Cheers,

Simon.

On Fri, 2008-02-08 at 14:23 +1300, Andrew McFadden wrote:
> Hi There 
> 
> I am a new user of "R" and having a few problems
> 
> a<-c("2001-02-1","NA","NA")
> a<-as.Date(a,format = "%Y-%m-%d")
> 
> b<-c("2001-03-1","2001-03-2","2001-03-3")
> b<-as.Date(b,format = "%Y-%m-%d")
> 
> c<-data.frame(a,b)
> 
> I would like to write an if statement where if "a" is not null return
> "a", if "a" is null (NA) return "b" less two days. Could someone help?.
> 
> 
> Andrew  
> 
> 
> 
> 
> This email message and any attachment(s) is intended solely for the
> addressee(s) named above. The information it contains is confidential
> and may be legally privileged.  Unauthorised use of the message, or the
> information it contains, may be unlawful. If you have received this
> message by mistake please call the sender immediately on 64 4 8940100
> or notify us by return email and erase the original message and
> attachments. Thank you.
> 
> The Ministry of Agriculture and Forestry accepts no responsibility for
> changes made to this email or to any attachments after transmission from
> the office.
> 
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

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


Re: [R] best text editor for Linux?

2008-02-03 Thread Simon Blomberg
Many Linux/Unix users (including me) recommend running R in Emacs, using
ESS http://ess.r-project.org/ . You can also run R through Emacs/ESS on
Windows.

Simon.

On Mon, 2008-02-04 at 07:35 +0100, Jarek Jasiewicz wrote:
> Wade Wall wrote:
> > Hi all,
> >
> > I know this question has been asked in the past, but I am wondering if
> > anyone running R on Linux has any guidance as to a text editor that works
> > well with R.  At the present time I am running R on Windows and using
> > TINN-R.  For a number of reasons I want to switch to Linux, but can't find
> > much in the way of a text editor in sync with R.  Any experiences,
> > recommendations would be appreciated.
> >
> > Wade Wall
> >
> > [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org 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.
> >   
> I can suggest also JGR package which give yo very good standalone 
> interface (you cannot start terminal) with color syntax for all 
> installed packages, active tips after typing funcion name, runnig any 
> fragment of code directly from editor, obiect brownser etc. very nice 
> tool... but.
> 
> It is java-dependend and there are lots of problems with installing it - 
> like most of the java dependend tools. For example I installed it 
> without problem on one machine, beside on other almost the same I recive 
> error. No one can tell me why (i.e why it is differend). Addationally 
> like all others java programs it is extremly slow and resorce consumed.
> Jarek
> 
> __
> R-help@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] difficulties computing a simple anova

2008-01-30 Thread Simon Blomberg
Your data setup is wrong. You have one factor (Drug) with 3 levels
(Zoloft, Naltrexone, Valium). So your data should be:

spiderdata <- data.frame(Drug=rep(c("Zoloft", "Naltrexone", "Valium"),
each=10), Response=c(9, 11, 5, 12, 15, 14, 13, 12, 7, 6, 15, 16, 12, 12,
18, 19, 23, 20, 13, 17, 9, 11, 12, 5, 13, 15, 11, 8, 6, 9))

You should be able to take it from there. (Since this is a homework
problem, I'm being intentionally vague.)

cheers,

Simon.

On Wed, 2008-01-30 at 18:47 -0600, Will Holcomb wrote:
> My grasp of R and statistics are both seriously lacking, so if this question
> is completely naive, I apologize in advance. I've hunted for a couple hours
> on the internet and none of the methods I've found have produced the result
> I'm looking for.
> 
> I'm currently a student in a Statistics class and we are learning the ANOVA.
> We had to do one by hand and then reproduce our work in SAS. I really like
> the idea of understanding R however and would like to reproduce the solution
> in R if possible.
> 
> Where I'm at now is this little program:
> http://odin.himinbi.org/classes/psy304b/spider_analysis.r
> 
> The program calculates an anova manually (correctly, I'm pretty sure, it
> agrees with the same numbers in excel). The answer that it comes up with
> doesn't agree with any of the numbers I can get either the aov or anova
> functions to produce.
> 
> Can anyone help me with simply the method to compute a one-way anova? Well,
> specifically how to replicate the sort of anova people learn in an intro to
> statistics class. All of the degrees of freedom are off from what I expect
> them to be (they're all 1).
> 
> (The original problem, should it help in understanding my question, is at:
> http://odin.himinbi.org/classes/psy304b/homework_1.xhtml#2 though it will
> likely look pretty funky if your browser doesn't support mathml (firefox
> does).)
> 
> Will
> 
> The program is as follows:
> 
> library(foreign)
> # spiderdata <- read.csv("spider_data.csv")
> 
> spiderdata = data.frame(Zoloft = c(9, 11, 5, 12, 15, 14, 13, 12, 7, 6),
> Naltrexone = c(15, 16, 12, 12, 18, 19, 23, 20, 13, 17),
> Valium = c(9, 11, 12, 5, 13, 15, 11, 8, 6, 9))
> 
> summary(spiderdata)
> 
> # Compute a one-way ANOVA by hand
> 
> J = length(spiderdata)
> 
> sqdata <- data.frame((spiderdata[1] - mean(spiderdata[1])) ^ 2)
> for(j in 2:J) {
> sqdata <- cbind(sqdata, (spiderdata[j] - mean(spiderdata[j])) ^ 2)
> }
> sqdata
> 
> N = 0
> for(j in 1:J) {
> N = N + length(sqdata[[j]])
> }
> 
> SSW = sum(sqdata)
> MSW = SSW / (N - J)
> SSB = 0
> for(j in 1:(length(spiderdata))) {
> SSB = SSB + length(spiderdata[[j]]) * ((mean(spiderdata[j])[[1]] -
> (sum(spiderdata) / N)) ^ 2)
> }
> MSB = SSB / (J - 1)
> 
> F = MSB / MSW
> f_prob = pf(F, J - 1, N - J)
> reject_point = qf(.95, J - 1, N - J)
> 
> cat("SSW:", SSW, ", MSW:", MSW, ", SSB:", SSB, ", MSB:", MSB, ", F:", F, ",
> P(F):", f_prob, ", P(", reject_point, ") = .95\n", sep = "")
> 
> anova(lm(Zoloft ~ Valium + Naltrexone, data = spiderdata))
> aov(Zoloft ~ Valium + Naltrexone, data = spiderdata)
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] In chisq.test(x) : Chi-squared approximation may be incorrect

2008-01-15 Thread Simon Blomberg
Why do people automatically jump to Fisher's Exact test? That test
conditions on BOTH marginal row totals. Usual contingency table analyses
condition on one margin, at most. You should look very carefully at the
underlying model for your data. Fisher's Exact test might not be
appropriate. Agresti's "Categorical Data Analysis" has a good discussion
of this.

Simon.

On Tue, 2008-01-15 at 21:49 -0500, My Coyne wrote:
> Thank you for your help; I will try fisher.test().
> 
>  
> 
> 
> 
> From: anna freni sterrantino [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, January 15, 2008 8:53 PM
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: Re: [R] In chisq.test(x) : Chi-squared approximation may be incorrect
> 
>  
> 
> Hi!
>  the warning you got
> "Chi-squared approximation may be incorrect"
> is because probably there are less than 5 observations in
> the cell. Maybe will help to 
> try fisher.test()
> 
> Cheers
> 
> Anna
> 
> 
> 
> 
> 
> 
> 
> 
> - Messaggio originale -
> Da: My Coyne <[EMAIL PROTECTED]>
> A: [EMAIL PROTECTED]
> Inviato: Lunedì 14 gennaio 2008, 21:51:30
> Oggetto: [R] In chisq.test(x) : Chi-squared approximation may be incorrect
> 
> Hello,
> 
> 
> 
> I received the following warning when running chi-square;
> 
> n  Is there a way to catch the 'error' code of 'warning' after run
> chisq.test(x)?
> 
> n  What does this error mean?
> 
> 
> 
> Thank you for your help.
> 
> 
> 
> 
> 
> 
> [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org 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.
> 
> 
> 
> 
> 
>   _  
> 
>   _  
> 
> L'email della prossima generazione? Puoi averla con la nuova 
> <http://us.rd.yahoo.com/mail/it/taglines/hotmail/nowyoucan/nextgen/*http:/it.docs.yahoo.com/nowyoucan.html>
>   Yahoo! Mail
> 
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] Subsetting data frame problem....

2008-01-01 Thread Simon Blomberg
Or use complete.cases

df.complete <- df[complete.cases(df),]

Simon.

On Wed, 2008-01-02 at 13:21 +1000, Ross Darnell wrote:
> You could try 
> 
> 
> > complete.case.df <- na.omit(df)
> 
> 
> Ross Darnell
> 
> 
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> On Behalf Of Marko Milicic
> Sent: Wednesday, 2 January 2008 11:50 AM
> To: r-help@r-project.org
> Subject: [R] Subsetting data frame problem
> 
> Dear R users,
> 
> I'm new but already fascinated R user so please forgive for my
> ignorance. I have the problem, I read most of help pages but couldn't
> find the solution. The problem follows
> 
> I have large data set 10,000 rows and more than 100 columns... Say
> something like
> 
> var1,var2,var2,var4...var120
> ---
> 12,12,345,657,67,8.
> 12,12,345,657,0,8.
> NA,12,345,657,NA,8.
> 12,12,NA,657,67,8.
> 12,12,345,657,NA,8.
> 
> I would like to select only rows where all variables are not NA so
> I can do something like
> 
> 
> df <- subset(
>   df
>   , !is.na(var1) & !is.na(var2) &
> !is.na(var3) & !is.na(var4) & !is.na(var5)..
>   );
> 
> 
> But that would be very bad solution because I have more than 100
> variables and if would be lengthy code to maintan. also, it might
> be error prone programming style...Am I right?
> 
> my question is if there is some smarter way of doing this which would
> work even if I have 1000 variables???
> 
> __
> R-help@r-project.org 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@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506 
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] COMPAR.GEE error with logistic model

2008-01-01 Thread Simon Blomberg
My guess is that this combination of variables produces separation in
the data: Too many (all?) of the response 1's are in at level of VAR3,
and the 0's are at the other level (or vice versa).

HTH,

Simon.

On Sat, 2007-12-29 at 18:39 -0500, Charles Willis wrote:
> Hello,
> 
> I am trying to run the APE program COMPAR.GEE with a model containing a
> categorical response variable and a mixture of continuous and categorical
> independent variables. The model runs when I have categorical (binary)
> response and two continuous independent variables (VAR1 and VAR2), but when
> I include a categorical (binary) independent variable (VAR3), I receive the
> following output with an error:
> 
> Beginning Cgee S-function, @(#) geeformula.q 4.13 98/01/27
> running glm to get initial regression estimate
>   (Intercept) VAR1 VAR2 VAR3
> -2.656607e+01 -3.110687e-15 -1.582172e-16  5.313214e+01
> "Error in gee(RESPONSE ~ VAR1 + VAR2 + VAR3, c(1, 1, 1, 1, 1,  :
>   Cgee: error: logistic model for probability has fitted value very close to
> 1.
> estimates diverging; iteration terminated.
> In addition: Warning message:
> In glm.fit(x = X, y = Y, weights = weights, start = start, etastart =
> etastart,  :
>   algorithm did not converge"
> 
> The input is the following model:
> 
> compar.gee(RESPONSE ~ VAR1 + VAR2 + VAR3, data = subset1, family =
> "binomial", phy = prunedtree1)
> 
> I have set all of the categorical data as factors and designated the family
> as "binomial". I don't know what else to do and the error message is not
> clear to me. If anyone can interpret this error message and/or knows how to
> run a compar.gee with a mixed set of categorical and continuous variable, I
> would be greatly appreciative for your advice.
> 
> Thank you,
> Charlie
> 
> 
> 
> 
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506 
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] Dual Core vs Quad Core

2007-12-17 Thread Simon Blomberg
I've been running R on a quad-core using Debian Gnu/Linux since March
this year, and I am very pleased with the performance.

Simon.


On Mon, 2007-12-17 at 20:13 -0500, Andrew Perrin wrote:
> On Mon, 17 Dec 2007, Kitty Lee wrote:
> 
> > Dear R-users,
> >
> > I use R to run spatial stuff and it takes up a lot of ram. Runs can take 
> > hours or days. I am thinking of getting a new desktop. Can R take advantage 
> > of the dual-core system?
> >
> > I have a dual-core computer at work. But it seems that right now R is using 
> > only one processor.
> >
> > The new computers feature quad core with 3GB of RAM. Can R take advantage 
> > of the 4 chips? Or am I better off getting a dual core with faster 
> > processing speed per chip?
> >
> > Thanks! Any advice would be really appreciated!
> >
> > K.
> 
> If I have my information right, R will use dual- or quad-cores if it's 
> doing two (or four) things at once. The second core will help a little bit 
> insofar as whatever else your machine is doing won't interfere with the 
> one core on which it's running, but generally things that take a single 
> thread will remain on a single core.
> 
> As for RAM, if you're doing memory-bound work you should certainly be 
> using a 64-bit machine and OS so you can utilize the larger memory space.
> 
> 
> --
> Andrew J Perrin - andrew_perrin (at) unc.edu - http://perrin.socsci.unc.edu
> Associate Professor of Sociology; Book Review Editor, _Social Forces_
> University of North Carolina - CB#3210, Chapel Hill, NC 27599-3210 USA
> 
> __
> R-help@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506 
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] Packages for Animal Models & QG analyses

2007-11-27 Thread Simon Blomberg
I don't think lme4 can handle user-specified correlation structures for
the residuals (yet), which are necessary for animal models.

Cheers,

Simon.

On Wed, 2007-11-28 at 07:50 +1000, David Duffy wrote:
> Deepa Senapathi asked:
> > 
> > I am looking to do some quantitative genetic analyses using animal models
> > and was wondering if someone could suggest an appropriate package in R.  It
> > would help if it was similar to the ASReml genetic analyses software.
> > 
> > Thanks,
> > 
> > Deepa Senapathi
> > 
> > Deepa Senapathi
> > Centre for Agri-Environmental Research (CAER)
> > School of Agriculture, Policy & Developement.
> > University of Reading
> > Earley Gate, Whiteknights Road,
> > Reading RG6 6AR.
> > Tel: +44 (0) 118 378  5467
> 
> See the R Genetics Task View.  I think kinship (which uses lme) and 
> perhaps regress packages.  For data amenable to an ANOVA/hierarchical 
> setup then lme4 as well (which does GLMMs nicely).  Have you tried Wombat 
> (non-R)?
> 
> David Duffy.
> 
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506 
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] Install repeated library

2007-11-25 Thread Simon Blomberg
The repeated package is on CRAN. I installed it successfully from there.

Simon.

On Sun, 2007-11-25 at 10:41 -1200, Becky Parker wrote:
> Hello -
> 
> I cannot get to
> www.alpha.luc.ac.be/~jlindsey/rcode.html<http://www.alpha.luc.ac.be/%7Ejlindsey/rcode.html>to
> obtain and install the repeated library for use of glmm().  Is the web
> page not active?  Can you give me an alternative location to obtain the
> repeated library?
> 
> Thank you,
> Becky Parker
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506 
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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 drawing a tree with "ape"?

2007-11-12 Thread Simon Blomberg
?edgelabels

On Sun, 2007-11-11 at 16:51 -0800, Hua Li wrote:
> Dear all,
> 
> I'm using the "ape" package in R and want to draw a
> phylogenetic tree with not only the tip labels but
> also some labels for the edges. e.g. Mark the edge AB
> as "m" in the tree ABC.  
> 
> Couldn't find a way to do that. Can someone help?
> 
> Thanks,
> 
> Hua
> 
> __
> R-help@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506 
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] R as a programming language

2007-11-07 Thread Simon Blomberg
Although Crawley is an ecologist, not a programmer or statistician. But
he is an FRS. Maybe that counts for something. ;-)

Simon.

On Thu, 2007-11-08 at 01:56 +0300, Alexy Khrabrov wrote:
> With all due respect to the great book -- of which I own 2 copies I  
> bought new -- it's not an "O'Reilly Programming in " book.  The  
> idea of a programming book like that is to thoroughly treat the  
> language from a programmer's standpoint, in a fairly standard way,  
> such as Ruby or Python.
> 
> As I'm learning more of statistics with R, I prefer to do it with the  
> book by Crawley.  Looks like most of R books are written by  
> statisticians who became programmers, not the other way.  Through all  
> those years I periodically follow R, I forget its programming spirit  
> in between, and there's no "Programming ..." book to help.   
> Statistics is hard to forget once you master it; syntax sugar melts  
> away...
> 
> "Programming with Data" is the closest to an O'Reilly, but more  
> advanced and esoteric than that.
> 
> Since R became a bona fide Open Source language with CRAN and all, an  
> O'Reilly book by a [Python and Ruby] programmer-turn-statistician is  
> long overdue!  If it systematically compares R with Ruby and Python,  
> its closest Open Source cousins, it would help even more.  RPy and  
> RRb are there to help, too.  Just my $0.01...
> 
> Cheers,
> Alexy
> 
> On Nov 7, 2007, at 7:46 PM, Bert Gunter wrote:
> 
> >>> (Will someone here please write an O'Reilly's "Programming in  
> >>> R"?  :)
> >
> > Someone already has ... see Venable and Ripley's S PROGRAMMING.
> >
> > **However** R is more than a general purpose programming language:  
> > it is a
> > programming language specifically designed for data analysis --  
> > including
> > statistical graphics -- and statistics. So, IMHO anyway, it's really
> > impossible to discuss it without reference to the data structures and
> > procedures underlying such tasks. Because it is targeted to do  
> > those sorts
> > of things well, it may handle poorly some things that general purpose
> > languages do well (minimizing storage with the use of references, for
> > example).
> >
> > My own experience is that one appreciates the power and beauty of the
> > language and the wisdom of the designers the more one uses it in real
> > applications. But I am not a computer scientist and have only a  
> > limited
> > exposure to standard CS concepts and algorithms, to say nothing of  
> > "real"
> > programming experience. So just my $.02.
> >
> > Best regards,
> >
> > Bert Gunter
> > Genentech Nonclinical Statistics
> >
> 
> __
> R-help@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506 
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] Elasticity in Leslie Matrix

2007-10-26 Thread Simon Blomberg
After a short exchange with the original questioner, I wrote the following 
function to calculate the elasticities of lower level variables in population 
transition matrices (Leslie matrices etc.) Perhaps it will be of use to others. 
There is no error-checking, so use with care. Users should consult Caswell 
(2001) for reference.

Cheers,

Simon.

# example values to construct leslie matrix

vl <- list(f1=1, f2=4, s0=.6, s=.4, v=.9, sigma=.5)

# Expressions for each matrix element
F1 <- expression(sigma*s0*f1)
F2 <- expression(sigma*s0*f2)
S <- expression(s)
V <- expression(v)
el <- c(F1, F2, S, V)

elas.var <- function (elements, varlist) {
  # elements should be a vector of expressions corresponding to the elements
  # of the leslie matrix, in terms of the variables in varlist

  require(demogR)
  res <- vector("list", length(varlist))
  deriv.funcs <- sapply(elements, deriv, namevec=names(varlist),
function.arg=TRUE)
  devs <- lapply(deriv.funcs, function (x) do.call(x, varlist))
  leslie.mat <-  matrix(as.numeric(devs), nrow=sqrt(length(elements)),
byrow=TRUE)
  eig <- eigen.analysis(leslie.mat)

  for (i in 1:length(varlist)) {
derivs <- matrix( as.numeric(lapply(devs, function (x)
[EMAIL PROTECTED])), nrow=sqrt(length(elements)), byrow=TRUE)
res[[i]] <- varlist[[i]]/eig$lambda1*sum(derivs*eig$sensitivities)
names(res)[i] <- names(varlist)[i]
  }
  res
}

# example output

> elas.var(el, vl)
$f1
[1] 0.06671376

$f2
[1] 0.2346064

$s0
[1] 0.3013201

$s
[1] 0.2346064

$v
[1] 0.4640735

$sigma
[1] 0.3013201


Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia 
T: +61 7 3365 2506 
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.










[[alternative HTML version deleted]]

__
R-help@r-project.org 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] Elasticity in Leslie Matrix

2007-10-22 Thread Simon Blomberg

On Mon, 2007-10-22 at 06:24 -0700, privalan wrote:
> Dear R-users,
> 
> I would like to calculate elasticities and sensitivities of each parameters
> involved in the following transition matrix:
> 
> A <- matrix(c(
> sigma*s0*f1,  sigma*s0*f2,
>s, v
> ), nrow=2, byrow=TRUE,dimnames=list(stage,stage))
> 
> 
> The command "eigen.analysis" avaliable in package "popbio" provides
> sensibility matrix and elasticity matrix (same dimension than A). I would
> like to know if there is a way to calculate separetely the elasticity of
> sigma, s0, f1, f2, s and v ?

You should first calculate the matrix element sensitivities, then
calculate the derivatives of the elements of your matrix with respect to
the parameter of interest. Then for each element in the matrix, the
sensitivity of the parameter is just the product of the derivative and
the appropriate element sensitivity, by the chain rule. Then add up all
the sensitivities, multiply by your parameter and divide by lambda. ie

plot(1:10, 1:10, type="n")

text(5,6, expression(e[s[0]]  == over(s[0],
lambda)~sum(~over(paste(partialdiff,~lambda),paste(partialdiff,~a[ij]))
%.% over(paste(partialdiff, ~a[ij]), paste(partialdiff, ~s[0])), ij)),
cex=2)

Be aware that these elasticities will in general not sum to unity, and
cannot be interpreted as "contributions" to lambda. See Caswell (2001),
page 232.

Cheers,

Simon.

> 
> Thanks and regards,
> 
> privalan
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506 
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] survreg's algorithm

2007-10-15 Thread Simon Blomberg
Did you look at the C source code? There are 4 different variants
(survregN.c, where N <- 2:5) , depending on whether the distribution is
built-in or not, and penalized likelihood is being used or not. They all
look like NR to me, but I confess I haven't read the code in extreme
detail. It is well commented, however.

Cheers,

Simon.

PS Try figuring out what 
is actually doing by reading the source code. Take that, large software
corporations! The future belongs to R!

On Tue, 2007-10-16 at 13:12 +1000, Gad Abraham wrote:
> Gad Abraham wrote:
> > Hi,
> > 
> > I'm using survreg() from the survival package for parametric survival 
> > regression (modelling inter-arrival times of patients to a waiting list 
> > as exponentially distributed, with various regressors such as queue size 
> > and season).
> > 
> > Does anyone know which algorithm survreg() uses for this?
> > 
> > Thanks,
> > Gad
> > 
> 
> Due diligence:
> 
> I have actually looked at ?survreg and friends, and at the source code; 
> except for a brief mention of a "sparse Newton-Rapshon algorithm" in the 
> frailty model code, I couldn't find anything substantive.
> 
> 
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506 
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] Rooting trees using ape

2007-10-10 Thread Simon Blomberg
Please supply enough information to allow us to reproduce the error.
Also, nirK.tree is a different object to nirk.tree, which might be
confusing things.

Simon.

On Wed, 2007-10-10 at 15:07 +0200, Chris Jones wrote:
> Hi all,
> 
> I seem to be having a difficult time using the 'ape' package in R  
> when it comes to rooting trees.  Here's a short screenshot:
> 
>  > nirK.tree
> 
> Phylogenetic tree with 23 tips and 21 internal nodes.
> 
> Tip labels:
>   Burkholder, Burkholde3, Burkholde1, Burkholde4, Burkholde5,  
> Ralstonia2, ...
>   Node labels:
>   , 100, 100, 100, 70, 91,...
> 
> Unooted; includes branch lengths.
>  > test<-root(nirk.tree, 4)
> Error in root(nirk.tree, 4) : subscript out of bounds
>  > test<-root(nirk.tree, "Burkholde4")
> Error in root(nirk.tree, "Burkholde4") : subscript out of bounds
>  >
> 
> I tried with the example tree provided in the package, and that  
> seemed to work ok.  Any suggestions?
> 
> Many thanks,
> Chris
> 
> __
> R-help@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506 
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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] Who uses R?

2007-09-25 Thread Simon Blomberg
See the "Members and Donors" section on the left-hand side of the R web
site.

Cheers,

Simon.

Note to self: Become a supporting member.

On Tue, 2007-09-25 at 11:59 +0100, Gesmann, Markus wrote:
> Dear Eleni,
> 
> Maybe the participants of the useR conferences are a good start, see
> e.g.
> http://www.r-project.org/useR-2006/participants.html
> 
> Kind regards,
> 
> Markus Gesmann 
> FPMA
> Lloyd's Market Analysis
> Lloyd's * One Lime Street * London * EC3M 7HA
> Telephone +44 (0)20 7327 6472
> Fax   +44 (0)20 7327 5718
> http://www.lloyds.com
> 
> SAVE PAPER - THINK BEFORE YOU PRINT
> 
> 
> 
> 
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> On Behalf Of Eleni Rapsomaniki
> Sent: 25 September 2007 11:46
> To: r-help@r-project.org
> Subject: [R] Who uses R?
> 
> 
> Dear R users,
> 
> I have started work in a Statistics government department and I am
> trying to
> convince my bosses to install R on our computers (I can't do proper
> stats in
> Excel!!). They asked me to prove that this is a widely used software
> (and not
> just another free-source, bug infected toy I found on the web!) by
> suggesting
> other big organisations that use it. Are you aware of any reputable
> places
> (academic or not) that use R? (e.g. maybe you work for them)
> 
> I would be really grateful for any advice on this. Also suggestions on
> arguments
> I could use to persuade them that R is so much better than Excel would
> be very
> much appreciated.
> 
> Many Thanks
> Eleni Rapsomaniki
> 
> __
> R-help@r-project.org 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.
> **
> The information in this E-Mail and in any attachments is CON...{{dropped}}
> 
> __
> R-help@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506 
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

__
R-help@r-project.org 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.