[R] How would you calculate this type of p-value using R?

2011-08-17 Thread RQuestion
Let's say you want to compare one observation with a sample, how would you
use R to get a p-value for that single observation itself?


To clarify what I'm asking: We know you use a one-sample t test to compare
an actual sample to a hypothetical value, and a Wilcoxon test if it's not
normally distributed, in R either t.test( ) or wilcox.test( ). However,
what do you use if you don't want a p-value for a sample itself, but instead
want to get a *p-value for the likelihood that just one observation could
have its distance from a sample just by chance*?



Context for my question: Many of us know about the Casey Anthony case, and
how the medical examiner said they looked at the records and 100% of all
drownings were reported within one hour. It wasn't until a month after when
it was finally reported to the police the girl was missing by the
grandmother and even longer after that when Casey finally claimed it was
really a drowning rather than a Zanny the Nanny kidnapping the little
girl.

So, I want to write the medical examiner to see if I can get a list of how
long it took for each of the drownings to be reported (she mentioned in
court), then calculate a standard deviation and based on the sample size
come up with a p-value for when Cindy Anthony finally reported the grand
daughter missing 31 days later. Then another p-value for when Casey Anthony
finally claimed it was a drowning years later.

How would you calculate a p-value for something like this? I'm guessing the
sample will probably not be normally distributed, so what would I use from R
if that's case?  I'm still quite new to R, so if at all possible don't make
your answer too technical.

Thanks so much!

--
View this message in context: 
http://r.789695.n4.nabble.com/How-would-you-calculate-this-type-of-p-value-using-R-tp3749115p3749115.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.


Re: [R] how to get the result in short cut manner?

2011-08-17 Thread Lao Meng
Yes, you remind me of this!
Thanks!


2011/8/16 Eik Vettorazzi e.vettora...@uke.uni-hamburg.de

 Hi Lao,
 you tried to reinvent the wheel. Have a look at ?tapply

 tapply(sleep$extra,sleep$group,mean)

 Cheers

 Am 16.08.2011 09:41, schrieb Lao Meng:
  Hi all:
  My data:data(sleep)
 
  If I wanna calculate each group's extra,what I can do is:
  #method1
  attach(sleep)
  mean(extra[group==1])
  mean(extra[group==1])
 
 
  #method2
  result-matrix(,0,2)
  g-split(sleep,sleep$group)
  for(i in 1:length(g))
  {
  result-rbind(result,data.frame(unique(g[[i]]$group),mean(g[[i]]$extra)))
  }
  colnames(result)-c(name,mean)
 
  But the above 2 method is a little bit tedious.Is there a short cut
 manner
  to get the same result?
 
  Thanks a lot!
 
  My best
 
[[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.

 --
 Eik Vettorazzi
 Institut für Medizinische Biometrie und Epidemiologie
 Universitätsklinikum Hamburg-Eppendorf

 Martinistr. 52
 20246 Hamburg

 T ++49/40/7410-58243
 F ++49/40/7410-57790


[[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 about lm on t-test.

2011-08-17 Thread Lao Meng
Thanks Eik.
As to your words:The intercept in lm is tested against 0 (one sample
t-test)

So, I perform the following test:
t.test(extra[group==1],mu=0)

Since goup1 is regarded as reference,I do the 1-sample ttest based on
group1's mean vs 0.
But the result:
t value= 1.3257
p-value = 0.2176

And t value and p value of s1 is:
t value= 1.249
p value= 0.2276

So the t value and p value are different between 1-sample ttest of
group1'mean vs 0  and s1(lm's result).

What's the reason for the difference then?

Thanks a lot for your help.

My best.


2011/8/16 Eik Vettorazzi e.vettora...@uke.uni-hamburg.de

 Hi,
 you may have noticed, that your t-test and lm had not the same p-values
 for the difference in means, which is calculated for group2 when you use
 treatment contrasts and that is what R does by default (see
 ?contr.treatment). This is because R uses Welsh test by default. Pros
 and cons are beyond this post, but look at

 (t1-t.test(extra~group,data=sleep,var.equal=T))
 (s1-summary(lm(extra~group,data=sleep)))
 all.equal(s1$coef[group2,Pr(|t|)],t1$p.value)

 The intercept in lm is tested against 0 (one sample t-test),
 so the t-statistic is (mean-0)/sd, having n-k (sample size - number of
 parameters) degrees of freedom.

 cc-s1$coef[(Intercept),1:2]
 2*(1-pt(cc[1]/cc[2],df=18))


 hth.

 Am 16.08.2011 07:25, schrieb Lao Meng:
  Hi all:
  I have a question about lm on t-test.
 
  data(sleep)
 
  I wanna perform t-test to test the difference between the 2 groups:
 
  I can use:
  t.test(extra~group)
 
  The t.test result shows that:t = -1.8608; mean1=0.75,mean2=2.33
 
 
  But I still wanna use:
  summary(lm(extra~group))
 
  Intercept=0.75,which is mean1,just the same as t.test.
  group2=1.58 means the difference of the 2 groups,so
  mean2=1.58+0.75=2.33,just the same as t.test.
  And some parameters of group2(t value,Pr) are the same as t.test,since
  group2 is the difference of the 2 groups.
 
  My question is:
  How the t value of Intercept(group1 acturally) is calculated?
 
 
  Thanks a lot.
 
  My best
 
[[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.

 --
 Eik Vettorazzi
 Institut für Medizinische Biometrie und Epidemiologie
 Universitätsklinikum Hamburg-Eppendorf

 Martinistr. 52
 20246 Hamburg

 T ++49/40/7410-58243
 F ++49/40/7410-57790


[[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 inverse using matinv (Design)

2011-08-17 Thread Frank Paetzold
thank you all.

i have deliberately chosen matinv (although obviously 
an outdated version) because it uses the sweep operator.
i know of other methods to calculate generalized inverses.
however, it is also true that the sweep operator is capable of 
computing g2 generalized inverses. 

The ginv returns the Moore-Penrose inverse, which has nicer 
numerical properties if computed by svd, but it is just not 
what i want.
(besides, svd is very slow and should not be applied to the normal 
equations anyway)

so lets explain my peculiar interest in matinv:
i am trying get my head around the type III SS that 
SAS popularized. i know that those hypotheses are 
hated in the R community but they are the standard 
hypothesis given by all other statistics software.
i know how to compute type III SS and how to translate them 
to meaningful hypothesis of the cell means model.
but i do not have an intuitive understanding why 
they are computed as they are.

so i came across my matinv problem when i tried to 
to compute the generating matrix
  _  
H = (X'X)  X'X

used for the construction of estimable functions.
if the g2-inverse is used, then H has canonical form
which simpifies the interpretion. 
i just wanted to check if it is invariant to cell frequencies.

--
View this message in context: 
http://r.789695.n4.nabble.com/generalized-inverse-using-matinv-Design-tp3747337p3749373.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.


Re: [R] Constructing an additional key inside of a lattice panel

2011-08-17 Thread Fredrik Karlsson
Dear list,

following up on my own post, I have now started trying constructing a
legend argument to xyplot that would work, based on the examples in
Sarkar's book.

I'm now at a state where I have a legend that does not throw an error, but
no legend is displayed:


   legend=list(corner=list(
 fun=draw.key,
 args=list(
   key=list(text=
 list(myFactorLevels),
 lines=list(
   lty=1:length(myFactorLevels))
 ),
   draw=TRUE
   )
 ),x=0,y=1



Where myFactorLevels contains the levels I want displayed (e.i. the levels
of myGroups in my previous attempt).

Please, why is this legend not displayed?

/Fredrik

On Tue, Aug 16, 2011 at 1:05 PM, Fredrik Karlsson dargo...@gmail.comwrote:

 Hi,

 I would like to add an additional key inside of a panel based on a factor
 that is not the groups argument.
 I've tried using the panel.key function in latticeExtras, but I cannot get
 the line types the way I want it.

 Using my factor myGroups, I've tried this:

 panel.key(text=levels(myGroups),lines=TRUE,points=FALSE,corner =
 c(0,.98),key=list(lines=list(lty=1:length(levels(myGroups)

 I then get the key where I want it, the text is right, but line types are
 not correct (always lty=1, I think).

 Any ideas on how I could solve this?



 /Fredrik



 --
 Life is like a trumpet - if you don't put anything into it, you don't get
 anything out of it.




-- 
Life is like a trumpet - if you don't put anything into it, you don't get
anything out of it.

[[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 about lm on t-test.

2011-08-17 Thread Eik Vettorazzi
Hi Lao,
thats not the same test. The concept of linear regression applies here
(and you might take any introductory at your hand to refresh that
concept). The intercept is estimated from the whole sample not just
group==1, dfs are 20-2, not sum(group==1)-1!

best regards

Am 17.08.2011 09:57, schrieb Lao Meng:
 Thanks Eik.
 As to your words:The intercept in lm is tested against 0 (one sample
 t-test)
 
 So, I perform the following test:
 t.test(extra[group==1],mu=0)
 
 Since goup1 is regarded as reference,I do the 1-sample ttest based on
 group1's mean vs 0.
 But the result:
 t value= 1.3257
 p-value = 0.2176
 
 And t value and p value of s1 is:
 t value= 1.249
 p value= 0.2276
 
 So the t value and p value are different between 1-sample ttest of
 group1'mean vs 0  and s1(lm's result).
 
 What's the reason for the difference then?
 
 Thanks a lot for your help.
 
 My best.
 
 
 2011/8/16 Eik Vettorazzi e.vettora...@uke.uni-hamburg.de
 mailto:e.vettora...@uke.uni-hamburg.de
 
 Hi,
 you may have noticed, that your t-test and lm had not the same p-values
 for the difference in means, which is calculated for group2 when you use
 treatment contrasts and that is what R does by default (see
 ?contr.treatment). This is because R uses Welsh test by default. Pros
 and cons are beyond this post, but look at
 
 (t1-t.test(extra~group,data=sleep,var.equal=T))
 (s1-summary(lm(extra~group,data=sleep)))
 all.equal(s1$coef[group2,Pr(|t|)],t1$p.value)
 
 The intercept in lm is tested against 0 (one sample t-test),
 so the t-statistic is (mean-0)/sd, having n-k (sample size - number of
 parameters) degrees of freedom.
 
 cc-s1$coef[(Intercept),1:2]
 2*(1-pt(cc[1]/cc[2],df=18))
 
 
 hth.
 
 Am 16.08.2011 07:25, schrieb Lao Meng:
  Hi all:
  I have a question about lm on t-test.
 
  data(sleep)
 
  I wanna perform t-test to test the difference between the 2 groups:
 
  I can use:
  t.test(extra~group)
 
  The t.test result shows that:t = -1.8608; mean1=0.75,mean2=2.33
 
 
  But I still wanna use:
  summary(lm(extra~group))
 
  Intercept=0.75,which is mean1,just the same as t.test.
  group2=1.58 means the difference of the 2 groups,so
  mean2=1.58+0.75=2.33,just the same as t.test.
  And some parameters of group2(t value,Pr) are the same as t.test,since
  group2 is the difference of the 2 groups.
 
  My question is:
  How the t value of Intercept(group1 acturally) is calculated?
 
 
  Thanks a lot.
 
  My best
 
[[alternative HTML version deleted]]
 
  __
  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.
 
 --
 Eik Vettorazzi
 Institut für Medizinische Biometrie und Epidemiologie
 Universitätsklinikum Hamburg-Eppendorf
 
 Martinistr. 52
 20246 Hamburg
 
 T ++49/40/7410-58243
 F ++49/40/7410-57790
 
 

-- 
Eik Vettorazzi
Institut für Medizinische Biometrie und Epidemiologie
Universitätsklinikum Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/7410-58243
F ++49/40/7410-57790

__
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] PBSmapping, where is Ireland?!

2011-08-17 Thread Rubén Roa
Dear Ewan,

I faced this problem and solved it by contacting the package authors, John 
Schnute and Rowan Haigh, rowan.ha...@dfo-mpo.gc.ca.
Here is a function that solves the problem by displacing the Greenwich meridian 
to longitude 348 leaving Ireland to the right.
This longitude does not span any land mass within the limits of the map so it 
does not cause any disappearing land masses.
The function loads the GSHHS data in intermediate resolution, so it takes some 
time, less than 1 min in my standard laptop, to run.
Change the xlim and ylim values to get different fractions of Europe.
Last time I contacted them (October 2010), package authors were planning to add 
some comments about this in PBSmapping  user's guide.
So you may find more info by digging into the user's guide, or else, contact 
Rowan. 

HTH

Rubén


Dr. Ruben H. Roa-Ureta
Senior Researcher, AZTI Tecnalia,
Marine Research Division,
Txatxarramendi Ugartea z/g, 48395, Sukarrieta,
Bizkaia, Spain

library(PBSmapping)
Euromap - function(path=C:/Temp, cutLon=348) 
{
 fnam - paste(path,gshhs_f.b,sep=/);
   p1 - 
importGSHHS(fnam,xlim=c(-20,360),ylim=c(30,80),level=1,n=0,xoff=0);
   z - p1$XcutLon;
   p1$X[z] - p1$X[z]-360;
   NorthSeaHR - thinPolys(p1, tol=0.1, filter=3)
   .initPBS()
   clr - PBSval$PBSclr;
   xlim   - c(-18, 16)
   ylim   - c(32, 64)
   WEurope - clipPolys(NorthSeaHR, xlim=xlim, ylim=ylim)
   par(mfrow=c(1,1),omi=c(0,0,0,0))
   plotMap(WEurope, xlim=xlim, ylim=ylim, col=clr$land, 
bg=clr$sea, tck=-0.02,mgp=c(2,.75,0), cex=1.2, plt=c(.08,.98,.08,.98))
}
Euromap(cutLon=348)

-Mensaje original-
De: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] En 
nombre de Ewan Minter
Enviado el: martes, 16 de agosto de 2011 14:57
Para: r-help@r-project.org
Asunto: [R] PBSmapping, where is Ireland?!

Hi folks,

I've been using 'PBSmapping' to make a map of Europe with some labels. I've 
been using the 'worldLL' PolyData, as my computer is too slow to make my own 
from the GSHHS files.

The only p

__
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] A question about using getSrcDirectory() with R/Rscript

2011-08-17 Thread Cormac Long
Good morning R-help,

I have an idiot question: I would like to use getSrcDirectory()
and friends to allow me to identify where an R file has been
called from when invoked using Rscript. If I understand the
documentation correctly, the following example should work:

In file test.R:
   options(keep.source=T)
   fn-function(x){x-x+1}
   srcDir-getSrcDirectory(fn)
   print(srcDir)

I attempted the following invocations of Rscript:
   + Rscript test.R
   + Rscript full_path/test.R

I attempted the following invocations using R:
   + source(test.R)
   + Manually entering the function

In both attempts, the variable srcDir is a zero-length character
vector. Digging into the documentation, I notice that getSrcDirectory()
looks for a srcref attribute in the function body. In neither R
nor Rscript is this attribute set when declaring the function.

So: what am I missing?

Comments:
   + I have 'keep.source' option set to TRUE in both R and Rscript
 (irritatingly, it's default is TRUE in R and FALSE in Rscript
  - why is this?)
   + I have tested this with:
o R 2.13.1 on Ubuntu 10.10 (server)
o R 2.13.0 on Windows 7

Best wishes,
Cormac.

__
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] Wilcox test

2011-08-17 Thread bdeepthi
Hello,

I have used Wilcox test to find the p-value for hgua95 spiken data. It did
not give the required result, and instead gave me warnings like the values
are duplicated. Kindly suggest me how to overcome this problem as I am new
to R.


Thank you

Deepthi BM

__
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] How to apply a function to subsets of a data frame *and* obtain a data frame again?

2011-08-17 Thread Marius Hofert
Dear all,

First, let's create some data to play around:

set.seed(1)
(df - data.frame(Group=rep(c(Group1,Group2,Group3), each=10), 
 Value=c(rexp(10, 1), rexp(10, 4), rexp(10, 
10)))[sample(1:30,30),])

## Now we need the empirical distribution function:
edf - function(x) ecdf(x)(x) # empirical distribution function evaluated at x

## The big question is how one can apply the empirical distribution function to 
## each subset of df determined by Group, so how to apply it to Group1, then
## to Group2, and finally to Group3. You might suggest (?) to use tapply:

(edf. - tapply(df$Value, df$Group, FUN=edf))

## That's correct. But typically, one would like to obtain not only the values, 
## but a data.frame containing the original information and the new 
(edf-)values.
## What's a simple way to get this? (one would be required to first sort df 
## according to Group, then paste the values computed by edf to the sorted df; 
## seems a bit tedious). 
## A solution I have is the following (but I would like to know if there is a 
## simpler one):

(edf.. - do.call(rbind, lapply(unique(df$Group), function(strg){
subdata - subset(df, Group==strg) # sub-data
subdata - cbind(subdata, edf=edf(subdata$Value))
})) )


Cheers,

Marius
__
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 apply a function to subsets of a data frame *and* obtain a data frame again?

2011-08-17 Thread Nick Sabbe
You might want to look at package plyr and use ddply.

HTH,


Nick Sabbe
--
ping: nick.sa...@ugent.be
link: http://biomath.ugent.be
wink: A1.056, Coupure Links 653, 9000 Gent
ring: 09/264.59.36

-- Do Not Disapprove



 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Marius Hofert
 Sent: woensdag 17 augustus 2011 12:42
 To: Help R
 Subject: [R] How to apply a function to subsets of a data frame *and*
 obtain a data frame again?
 
 Dear all,
 
 First, let's create some data to play around:
 
 set.seed(1)
 (df - data.frame(Group=rep(c(Group1,Group2,Group3), each=10),
  Value=c(rexp(10, 1), rexp(10, 4), rexp(10,
 10)))[sample(1:30,30),])
 
 ## Now we need the empirical distribution function:
 edf - function(x) ecdf(x)(x) # empirical distribution function
 evaluated at x
 
 ## The big question is how one can apply the empirical distribution
 function to
 ## each subset of df determined by Group, so how to apply it to
 Group1, then
 ## to Group2, and finally to Group3. You might suggest (?) to use
 tapply:
 
 (edf. - tapply(df$Value, df$Group, FUN=edf))
 
 ## That's correct. But typically, one would like to obtain not only the
 values,
 ## but a data.frame containing the original information and the new
 (edf-)values.
 ## What's a simple way to get this? (one would be required to first
 sort df
 ## according to Group, then paste the values computed by edf to the
 sorted df;
 ## seems a bit tedious).
 ## A solution I have is the following (but I would like to know if
 there is a
 ## simpler one):
 
 (edf.. - do.call(rbind, lapply(unique(df$Group), function(strg){
 subdata - subset(df, Group==strg) # sub-data
 subdata - cbind(subdata, edf=edf(subdata$Value))
 })) )
 
 
 Cheers,
 
 Marius
 __
 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] How to apply a function to subsets of a data frame *and* obtain a data frame again?

2011-08-17 Thread Paul Hiemstra
 On 08/17/2011 11:24 AM, Nick Sabbe wrote:
 You might want to look at package plyr and use ddply.

The following example does what you want using ddply:

library(plyr)
edfPerGroup = ddply(df, .(Group), summarise, edf = edf(Value), Value =
Value)
 edfPerGroup
Group edf   Value
1  Group1 0.5 0.539682840
2  Group1 0.2 0.145706727
3  Group1 0.7 0.956567494
4  Group1 0.3 0.147045991
5  Group1 0.9 1.229562053
6  Group1 0.4 0.436068626
7  Group1 0.8 1.181642779
8  Group1 0.1 0.139795262
9  Group1 1.0 2.894968537
10 Group1 0.6 0.755181833

cheers,
Paul



 HTH,


 Nick Sabbe
 --
 ping: nick.sa...@ugent.be
 link: http://biomath.ugent.be
 wink: A1.056, Coupure Links 653, 9000 Gent
 ring: 09/264.59.36

 -- Do Not Disapprove



 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Marius Hofert
 Sent: woensdag 17 augustus 2011 12:42
 To: Help R
 Subject: [R] How to apply a function to subsets of a data frame *and*
 obtain a data frame again?

 Dear all,

 First, let's create some data to play around:

 set.seed(1)
 (df - data.frame(Group=rep(c(Group1,Group2,Group3), each=10),
  Value=c(rexp(10, 1), rexp(10, 4), rexp(10,
 10)))[sample(1:30,30),])

 ## Now we need the empirical distribution function:
 edf - function(x) ecdf(x)(x) # empirical distribution function
 evaluated at x

 ## The big question is how one can apply the empirical distribution
 function to
 ## each subset of df determined by Group, so how to apply it to
 Group1, then
 ## to Group2, and finally to Group3. You might suggest (?) to use
 tapply:

 (edf. - tapply(df$Value, df$Group, FUN=edf))

 ## That's correct. But typically, one would like to obtain not only the
 values,
 ## but a data.frame containing the original information and the new
 (edf-)values.
 ## What's a simple way to get this? (one would be required to first
 sort df
 ## according to Group, then paste the values computed by edf to the
 sorted df;
 ## seems a bit tedious).
 ## A solution I have is the following (but I would like to know if
 there is a
 ## simpler one):

 (edf.. - do.call(rbind, lapply(unique(df$Group), function(strg){
 subdata - subset(df, Group==strg) # sub-data
 subdata - cbind(subdata, edf=edf(subdata$Value))
 })) )


 Cheers,

 Marius
 __
 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.


-- 
Paul Hiemstra, Ph.D.
Global Climate Division
Royal Netherlands Meteorological Institute (KNMI)
Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39
P.O. Box 201 | 3730 AE | De Bilt
tel: +31 30 2206 494

http://intamap.geo.uu.nl/~paul
http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770

__
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 get the result in short cut manner?

2011-08-17 Thread Paul Hiemstra
 On 08/16/2011 07:56 AM, Eik Vettorazzi wrote:
 Hi Lao,
 you tried to reinvent the wheel. Have a look at ?tapply

 tapply(sleep$extra,sleep$group,mean)
or take a look at the plyr package:

library(plyr)
data(sleep)
ddply(sleep, .(group), summarise, m = mean(extra))

cheers,
Paul

 Cheers

 Am 16.08.2011 09:41, schrieb Lao Meng:
 Hi all:
 My data:data(sleep)

 If I wanna calculate each group's extra,what I can do is:
 #method1
 attach(sleep)
 mean(extra[group==1])
 mean(extra[group==1])


 #method2
 result-matrix(,0,2)
 g-split(sleep,sleep$group)
 for(i in 1:length(g))
 {
 result-rbind(result,data.frame(unique(g[[i]]$group),mean(g[[i]]$extra)))
 }
 colnames(result)-c(name,mean)

 But the above 2 method is a little bit tedious.Is there a short cut manner
 to get the same result?

 Thanks a lot!

 My best

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


-- 
Paul Hiemstra, Ph.D.
Global Climate Division
Royal Netherlands Meteorological Institute (KNMI)
Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39
P.O. Box 201 | 3730 AE | De Bilt
tel: +31 30 2206 494

http://intamap.geo.uu.nl/~paul
http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770

__
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 apply a function to subsets of a data frame *and* obtain a data frame again?

2011-08-17 Thread Hadley Wickham
 The following example does what you want using ddply:

 library(plyr)
 edfPerGroup = ddply(df, .(Group), summarise, edf = edf(Value), Value =
 Value)

Or slightly more succinctly:

ddply(df, .(Group), mutate, edf = edf(Value))

Hadley

-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

__
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 apply a function to subsets of a data frame *and* obtain a data frame again?

2011-08-17 Thread Marius Hofert
Dear all, 

thanks a lot for the quick help. 
Below is what I built with the hint of Nick.

Cheers,

Marius


library(plyr)

set.seed(1)
(df - data.frame(Group=rep(c(Group1,Group2,Group3), each=10), 
Value=c(rexp(10, 1), rexp(10, 4), rexp(10, 
10)))[sample(1:30,30),])
edf - function(x) ecdf(x)(x) 

ddply(df, .(Group), function(df.) cbind(df., edf=edf(df.$Value))) 


On 2011-08-17, at 13:38 , Hadley Wickham wrote:

 The following example does what you want using ddply:
 
 library(plyr)
 edfPerGroup = ddply(df, .(Group), summarise, edf = edf(Value), Value =
 Value)
 
 Or slightly more succinctly:
 
 ddply(df, .(Group), mutate, edf = edf(Value))
 
 Hadley
 
 -- 
 Assistant Professor / Dobelman Family Junior Chair
 Department of Statistics / Rice University
 http://had.co.nz/

__
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] packfor

2011-08-17 Thread COCCIA , CRISTINA


Good morning all,  

I'm trying to find the package packfor to install on my library in R, but I'm 
not available to find it online, so I would ask to you if you please let e know 
how I could find it and if I need a special R version to do it. 

Thanks a lot 

Regards 

Cristina 

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

2011-08-17 Thread Sidhu Sabeena (ROYAL SURREY COUNTY HOSPITAL NHS FOUNDATION TRUST)
I cannot seem to get this to work? I have weighted data points that I want to 
fit an sd-ellipse to, but the ellipse is not right? I have attached a .tiff of 
what I get.
I'm wondering if it's not looking at my actual data, but taking the data from 
the example? I ask this because I don't know where Title comes from in the 
graph?
Also, I want to put calcentre=FALSE, but if I do this I get the following error:
 Error in data.frame(..., check.names = FALSE) :
 arguments imply differing number of rows: 10, 0
I want the weighted mean centre of the ellipse, not the mean centre.
Can you tell me what is going on and why it isn't calculating the proper 
ellipse? I'm going to start crying soon.

Sabeena

library(xlsReadWrite)
Low - read.xls('LowEB.xls')
attach(Low)
Lwts - read.xls('LowWtsEB.xls')
attach(Lwts)
cE.add - c(0.16,1.00,0.42,0.17,0.11,0.49,0.28,0.20,0.45,0.23)
library(aspace)

x11()
plot(x =Low[,1], y = Low[,2], type = 'p', pch = 16, col = 'darkgoldenrod1', cex 
= 2*cE.add,xlim=c(2,10),ylim=c(40,105))

calc_sde(id=4, filename=EBLOW_Output.txt, centre.xy=NULL, calccentre=TRUE,
weighted=TRUE, weights=Lwts, points=Low, verbose=TRUE)

plot_sde(plotnew=FALSE, plotSDEaxes=FALSE, 
plotcentre=FALSE,plotweightedpts=FALSE,plotpoints=FALSE,sde.col='darkgoldenrod1',sde.lwd=2)







This message may contain confidential information. If you are not the intended 
recipient please inform the
sender that you have received the message in error before deleting it.
Please do not disclose, copy or distribute information in this e-mail or take 
any action in reliance on its contents:
to do so is strictly prohibited and may be unlawful.

Thank you for your co-operation.

NHSmail is the secure email and directory service available for all NHS staff 
in England and Scotland
NHSmail is approved for exchanging patient data and other sensitive information 
with NHSmail and GSi recipients
NHSmail provides an email address for your career in the NHS and can be 
accessed anywhere
For more information and to find out how you can switch, visit 
www.connectingforhealth.nhs.uk/nhsmail


__
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] Obtaining variable's names from a list of variables

2011-08-17 Thread Monsieur Do
Say I have a list of variables, 

listVar - list(age,sex)

I am looking for a way to either

1- create a vector c(age,sex) from it, or
2- get the names one by one in a for loop such as these

    a)  for (i in 1:length(listVar)) rownames(result)[i] - ???

    b)  for(i in listVar) print (variable's name)


Any help much appreciated.
[[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] multinomRob - error message

2011-08-17 Thread Danielle Martin

Hi,

I would like to use the multinomRob function to test election results.  
However, depending on which independent variables I include and how  
many categories I have in the dependent variable, the model cannot be  
estimated.


My data look like this (there are 68 observations):


head(database)

   RESTE09 GAUCHE09 PDC09 PLR09 UDC09 MCG09RESTE05  GAUCHE05  PDC05
D11455 5931  4726  7283  3611  5179 0.04487642 0.1707559 0.27561790
D2173610548  6905 27660  5430  5360 0.04487109 0.1797425 0.13782229
D3420812452  1721  8210  3179  8960 0.18580836 0.3218897 0.05659316
D42182 9208  7288 10654  2951  5205 0.08227831 0.2591124 0.19605699
D5612913909 12691 15560  3129 12551 0.10438878 0.2362780 0.23772964
D6302713517  4702 17899  5299  5758 0.10507522 0.2034102 0.07564233
   PLR05  UDC05  MCG05   dim1dim2dim3
D1 0.3006495 0.08555836 0.12254194  0.4327918 -0.37563170  0.23139759
D2 0.4879385 0.09903729 0.05058832  1.2723817  0.03128996 -0.10629471
D3 0.2296300 0.07822276 0.12785602 -0.8002237 -0.12194377  0.18147181
D4 0.3051325 0.06789533 0.08952449  0.4321835  0.11445829  0.24636903
D5 0.2811336 0.06624300 0.07422700  0.2560408  0.07019505  0.05611872
D6 0.4186317 0.10281440 0.09442613  0.4487914 -0.15539599 -0.04779844



I defined the model as follows:


mnr-multinomRob(list(

+ GAUCHE09~GAUCHE05+dim1+dim2+dim3,
+ PDC09~PDC05+dim1+dim2+dim3,
+ PLR09~PLR05+dim1+dim2+dim3,
+ UDC09~UDC05+dim1+dim2+dim3,
+ MCG09~MCG05+dim1+dim2+dim3,
+ RESTE09~0),database,print.level=0)


And the error message is:

Error in multinomT.foo$se$beta : $ operator is invalid for atomic vectors
In addition: There were 11 warnings (use warnings() to see them)


warnings()

Warning messages:
1: In optim(param, fn = mt.dev, method = method, control = control,  ... :
  unknown names in control: tol
2: In fn(par, ...) : value out of range in 'lgamma'
3: In fn(par, ...) : value out of range in 'lgamma'
4: In fn(par, ...) : value out of range in 'lgamma'
5: In fn(par, ...) : value out of range in 'lgamma'
6: In fn(par, ...) : value out of range in 'lgamma'
7: In fn(par, ...) : value out of range in 'lgamma'
8: In fn(par, ...) : value out of range in 'lgamma'
9: In fn(par, ...) : value out of range in 'lgamma'
10: In fn(par, ...) : value out of range in 'lgamma'
11: In fn(par, ...) : value out of range in 'lgamma'


Is my model uncorrectly defined?

many thanks,

danielle martin
graduate student
department of political science
university of michigan

__
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] interpreting interactions in a model

2011-08-17 Thread gaiarrido
Hi, 
I´ve got this model
 model-glm(prevalence~agesex+agesex:month,binomial)

and the output of anova is like that

 anova(model,test=Chisq)
  Df Deviance Resid. Df Resid. Dev P(|Chi|)   
NULL524 206.97 
agesex 2   9.9165   522 197.05  0.007025 **
agesex:month9  18.0899   513 178.96  0.034145 *

I don´t know how to interpret the interaction agesex:month, my mind doubt
between 2 options:
a) For a giving group of agesex there are differences between months
b)There are differences between groups of agesex in some months but not in
others.

Which option is correct?
Thanks very much

-
Mario Garrido Escudero
PhD student
Dpto. de Biología Animal, Ecología, Parasitología, Edafología y Qca. Agrícola
Universidad de Salamanca
--
View this message in context: 
http://r.789695.n4.nabble.com/interpreting-interactions-in-a-model-tp3749430p3749430.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.


[R] format, zero.print and NA

2011-08-17 Thread rexi
Hallo,

I need to print a matrix where zeros as well as NA occuring. The NA must be
keept and the zeros have to be converted to ..
I used format and zero.print, but as soon as the matrix contains NA format
gives an error message. Taking out the zero.print option or the NA's results
in no problems.
eg:

a-c(1,0,NA)
format(a,zero.print=.)

results in a error message

Is there any solution

Thanks

rexi

--
View this message in context: 
http://r.789695.n4.nabble.com/format-zero-print-and-NA-tp3749497p3749497.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.


[R] How to calculate residual mean deviance in rpart

2011-08-17 Thread Narayan Sharma
Hi,

I am doing a regression tree using the package 'rpart' but could not able to
calculate the residual mean deviance.

Please help.

Narayan

[[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] R-help Digest, Vol 102, Issue 18

2011-08-17 Thread fraenzi . korner
Wir sind bis am 20. August in den Ferien und werden keine e-mails beantworten. 
Bei dringenden Fällen melden Sie sich bei Stefanie von Felten 
steffi.vonfel...@oikostat.ch

We are on vacation until 20. August. In urgent cases, please contact Stefanie 
von Felten steffi.vonfel...@oikostat.ch

__
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 apply a function to subsets of a data frame *and* obtain a data frame again?

2011-08-17 Thread Paul Hiemstra
 On 08/17/2011 11:51 AM, Marius Hofert wrote:
 Dear all, 

 thanks a lot for the quick help. 
 Below is what I built with the hint of Nick.

 Cheers,

 Marius


 library(plyr)

 set.seed(1)
 (df - data.frame(Group=rep(c(Group1,Group2,Group3), each=10), 
 Value=c(rexp(10, 1), rexp(10, 4), rexp(10, 
 10)))[sample(1:30,30),])
 edf - function(x) ecdf(x)(x) 

 ddply(df, .(Group), function(df.) cbind(df., edf=edf(df.$Value))) 

Hadley's code is much shorter, I would use that syntax.

cheers,
Paul


 On 2011-08-17, at 13:38 , Hadley Wickham wrote:

 The following example does what you want using ddply:

 library(plyr)
 edfPerGroup = ddply(df, .(Group), summarise, edf = edf(Value), Value =
 Value)
 Or slightly more succinctly:

 ddply(df, .(Group), mutate, edf = edf(Value))

 Hadley

 -- 
 Assistant Professor / Dobelman Family Junior Chair
 Department of Statistics / Rice University
 http://had.co.nz/


-- 
Paul Hiemstra, Ph.D.
Global Climate Division
Royal Netherlands Meteorological Institute (KNMI)
Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39
P.O. Box 201 | 3730 AE | De Bilt
tel: +31 30 2206 494

http://intamap.geo.uu.nl/~paul
http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770

__
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 apply a function to subsets of a data frame *and* obtain a data frame again?

2011-08-17 Thread Dimitris Rizopoulos

Have a look at function ave(), e.g.,

set.seed(1)
(df - data.frame(Group=rep(c(Group1,Group2,Group3), each=10),
Value=c(rexp(10, 1), rexp(10, 4), rexp(10, 10)))[sample(1:30,30),])

edf - function(x) ecdf(x)(x)
df$edf - with(df, ave(Value, Group, FUN = edf))
df


I hope it helps.

Best,
Dimitris


On 8/17/2011 12:42 PM, Marius Hofert wrote:

Dear all,

First, let's create some data to play around:

set.seed(1)
(df- data.frame(Group=rep(c(Group1,Group2,Group3), each=10),
  Value=c(rexp(10, 1), rexp(10, 4), rexp(10, 
10)))[sample(1:30,30),])

## Now we need the empirical distribution function:
edf- function(x) ecdf(x)(x) # empirical distribution function evaluated at x

## The big question is how one can apply the empirical distribution function to
## each subset of df determined by Group, so how to apply it to Group1, then
## to Group2, and finally to Group3. You might suggest (?) to use tapply:

(edf.- tapply(df$Value, df$Group, FUN=edf))

## That's correct. But typically, one would like to obtain not only the values,
## but a data.frame containing the original information and the new 
(edf-)values.
## What's a simple way to get this? (one would be required to first sort df
## according to Group, then paste the values computed by edf to the sorted df;
## seems a bit tedious).
## A solution I have is the following (but I would like to know if there is a
## simpler one):

(edf..- do.call(rbind, lapply(unique(df$Group), function(strg){
 subdata- subset(df, Group==strg) # sub-data
 subdata- cbind(subdata, edf=edf(subdata$Value))
})) )


Cheers,

Marius
__
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.



--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014
Web: http://www.erasmusmc.nl/biostatistiek/

__
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] packfor

2011-08-17 Thread Ista Zahn
A google search for packfor r package will do it.

Best,
Ista

On Wed, Aug 17, 2011 at 3:49 AM, COCCIA , CRISTINA coc...@ebd.csic.es wrote:


 Good morning all,

 I'm trying to find the package packfor to install on my library in R, but 
 I'm not available to find it online, so I would ask to you if you please let 
 e know how I could find it and if I need a special R version to do it.

 Thanks a lot

 Regards

 Cristina


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




-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org

__
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] packfor

2011-08-17 Thread Raphael Saldanha
Here is: http://r-forge.r-project.org/R/?group_id=195

On Wed, Aug 17, 2011 at 9:08 AM, Ista Zahn iz...@psych.rochester.eduwrote:

 A google search for packfor r package will do it.

 Best,
 Ista

 On Wed, Aug 17, 2011 at 3:49 AM, COCCIA , CRISTINA coc...@ebd.csic.es
 wrote:
 
 
  Good morning all,
 
  I'm trying to find the package packfor to install on my library in R,
 but I'm not available to find it online, so I would ask to you if you please
 let e know how I could find it and if I need a special R version to do it.
 
  Thanks a lot
 
  Regards
 
  Cristina
 
 
 [[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.
 



 --
 Ista Zahn
 Graduate student
 University of Rochester
 Department of Clinical and Social Psychology
 http://yourpsyche.org

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




-- 
Atenciosamente,

Raphael Saldanha
saldanha.plan...@gmail.com

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

2011-08-17 Thread Gavin Simpson
On Wed, 2011-08-17 at 09:49 +0200, COCCIA , CRISTINA wrote:
 
 Good morning all,  
 
 I'm trying to find the package packfor to install on my library in
 R, but I'm not available to find it online, so I would ask to you if
 you please let e know how I could find it and if I need a special R
 version to do it. 

packfor is part of the *sedar* project on R-forge. You can get a binary
or sources from:

http://r-forge.r-project.org/R/?group_id=195

HTH

G


-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

__
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] Symbol Font Baseline, Cairo, Card Symbols

2011-08-17 Thread Gavin Simpson
On Tue, 2011-08-16 at 17:46 -0700, ivo welch wrote:
 I think I found a bug in the Cairo library, plus weird behavior in
 both the Cairo and the normal pdf device.  The baseline of the spades
 symbol seems to be off.  This is easier to show than it is to explain.
  The problem does not appear in the normal pdf device, which is why I
 am guessing this is a Cairo bug.  moreover, I cannot figure out why
 three of the card symbols seem to be transparent, but the fourth is
 not.  this is the case for both the Cairo and the ordinary pdf
 devices.
 
 I thought I would report it to the R wizards on this group...

Why? One is expressly asked to address such problems with the package
maintainer(s), especially if you feel there is a bug in the package.

And whilst Martin M is potentially indisposed at UseR! 2011, I will
mention that it is a *package* not a library when you refer to the R
package Cario. If you had identified a bug in the Cairo *library* you
should be reporting it upstream to the Cairo people:
http://www.cairographics.org/

G

 library(Cairo)
 
 clubs - expression(symbol('\247'))
 hearts - expression(symbol('\250'))
 diamonds - expression(symbol('\251'))
 spades - expression(symbol('\252'))
 csymbols - c(clubs, diamonds, hearts, spades)
 
 CairoPDF(file = cardsymbols.pdf)
 
 plot( 0, xlim=c(0,5), ylim=c(0,2), type=n )
 clr - c(black, red, red, black)
 for (i in 1:4) {
   hline - function( yloc, ... ) for (i in 1:length(yloc)) lines(
 c(-1,6), c(yloc[i],yloc[i]), col=gray)
   hline(0.9);  hline(1.0);   hline(1.1);   hline(1.2)
   text( i, 1, csymbols[i], col=clr[i], cex=5 )
   text( i, 0.5, csymbols[i], col=clr[i] )
 }
 
 dev.off()
 
 
 
 
 Ivo Welch (ivo.we...@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.

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

__
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] Obtaining variable's names from a list of variables

2011-08-17 Thread Eik Vettorazzi
Hi,
there is no direct way, since
listVar - list(age,sex)
creates a unnamed list, as can be seen by
names(listVar) #or
str(listVar)

You can do sth like
listVar - list(age=age,sex=sex) # or
listVar2 - list(age,sex)
names(listVar2)-c(age,sex)

and afterwards access them using names().

Or you write your own list function using its call to name the returned
object, as in

my.list-function(...){
 tmp-list(...)
 names(tmp)-all.names(match.call())[-1]
 tmp
}
attach(iris)
a-my.list(Sepal.Length,Sepal.Width)

hth.

Am 17.08.2011 08:46, schrieb Monsieur Do:
 Say I have a list of variables, 
 
 listVar - list(age,sex)
 
 I am looking for a way to either
 
 1- create a vector c(age,sex) from it, or
 2- get the names one by one in a for loop such as these
 
 a)  for (i in 1:length(listVar)) rownames(result)[i] - ???
 
 b)  for(i in listVar) print (variable's name)
 
 
 Any help much appreciated.
   [[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.

-- 
Eik Vettorazzi
Institut für Medizinische Biometrie und Epidemiologie
Universitätsklinikum Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/7410-58243
F ++49/40/7410-57790

__
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] Interpreting parameters of sigmoid fct

2011-08-17 Thread Anna Lee
Dear list,

I'm trying to fit a chapman-richards equation to my data, only I
cannot interpret the parameters a, b and d. I know that the parameter
b denotes the asymptote, but for the others I couldn't figure out. But
I do need to know this in order to set my starting values. Here's the
model:

modPoplar- nls(Diameter ~ d*(1-exp(-b *Age))^a ,start=list(a=20,b=0.9,d=33))

I attached the graph, too.

Hoping for your answers!

Best, Anna

-- 



Der Inhalt dieser E-Mail ist vertraulich. Sollte Ihnen die E-Mail
irrtümlich zugesandt worden sein, bitte ich Sie, mich unverzüglich zu
benachrichtigen und die E-Mail zu löschen.

This e-mail is confidential. If you have received it in error, please
notify me immediately and delete it from your system.
__
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] Obtaining variable's names from a list of variables

2011-08-17 Thread Marc Schwartz
On Aug 17, 2011, at 1:46 AM, Monsieur Do wrote:

 Say I have a list of variables, 
 
 listVar - list(age,sex)
 
 I am looking for a way to either
 
 1- create a vector c(age,sex) from it, or
 2- get the names one by one in a for loop such as these
 
 a)  for (i in 1:length(listVar)) rownames(result)[i] - ???
 
 b)  for(i in listVar) print (variable's name)
 
 
 Any help much appreciated.

Based upon the way in which you created 'listVar', there really is not a way to 
recover the variable names, since they are not retained:

age - 1:2
sex - c(M, F)
listVar - list(age, sex)

 listVar
[[1]]
[1] 1 2

[[2]]
[1] M F

 names(listVar)
NULL


On the other hand, if you use:

listVar - list(age = age, sex = sex)

 listVar
$age
[1] 1 2

$sex
[1] M F

 names(listVar)
[1] age sex

HTH,

Marc Schwartz

__
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] Constructing an additional key inside of a lattice panel

2011-08-17 Thread Deepayan Sarkar
On Tue, Aug 16, 2011 at 4:35 PM, Fredrik Karlsson dargo...@gmail.com wrote:
 Hi,

 I would like to add an additional key inside of a panel based on a factor
 that is not the groups argument.
 I've tried using the panel.key function in latticeExtras, but I cannot get
 the line types the way I want it.

 Using my factor myGroups, I've tried this:

 panel.key(text=levels(myGroups),lines=TRUE,points=FALSE,corner =
 c(0,.98),key=list(lines=list(lty=1:length(levels(myGroups)

 I then get the key where I want it, the text is right, but line types are
 not correct (always lty=1, I think).

 Any ideas on how I could solve this?

Well, trying to add undocumented arguments and hoping they will
magically work usually doesn't help.

panel.key() works using simpleKey(), which by design is simple but not
flexible. In particular, it will not allow you to set 'lty' directly,
and instead use the values from the theme currently in use.

You _can_ change the theme also, using a different argument; e.g.,

library(lattice)
library(latticeExtra)

xyplot(1 ~ 1,
   panel = function(...) {
   panel.xyplot(...)
   panel.key(text = month.name[1:2],lines=TRUE,points=FALSE,
 corner = c(0,.98))
   },
   par.settings = simpleTheme(lty = 1:2))

But I don't know if that interferes with the rest of your call.

If all else fails, panel.key() is not a very complicated function, so
you can take inspiration from it and write your own version that
replaces the line

key - simpleKey(text, ...)

with

key - something else

where something else describes the legend that you want.

-Deepayan

__
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] question regarding gregexpr and read.table

2011-08-17 Thread Jack Luo
Hi,

I have a silly question regarding the usage of two commands: read.table and
gregexpr:
For read.table, if I read a matrix and set header = T, I found that all the
dash (-) becomes dots (.)


A = read.table(Matrix.txt, sep = \t, header = F)
A[1,1]
# A-B-C-D.

A = read.table(Matrix.txt, sep = \t, header = T)
colnames(A)[1]
# A.B.C.D

Is there a way to use the header = T argument, but still keep the original
format A-B-C-D?

For gregexpr,
gregexpr(-,A-B-C-D)[[1]]
#[1] 2 4 6
#attr(,match.length)
#[1] 1 1 1


gregexpr(.,A.B.C.D)[[1]]
[1] 1 2 3 4 5 6 7
attr(,match.length)
[1] 1 1 1 1 1 1 1

Looks like dots means all the characters. Is there a way that I can extract
the position of the dots specifically?

Thanks,

-Jack

[[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] extract variables from model formula

2011-08-17 Thread Eik Vettorazzi
Hi Josh,
I think,

m - lm(mpg ~ factor(cyl)+I(mpg^2), data = mtcars)
nd-get_all_vars(m,data=mtcars)

is what you are after.

cheers.

Am 17.08.2011 04:27, schrieb Joshua Wiley:
 Hi All,
 
 I am writing a function to predict values based on a model.  It works
 fine as long as the formula just uses regular variable names.  I am
 having a problem when the variables are wrapped with a function call.
 For example:
 
 m - lm(mpg ~ factor(cyl), data = mtcars)
 ## I get the column names using
 as.character(attr(terms(m), variables))[-1L]
 ## which gives the same column names as in
 # m$model
 
 predict(m, m$model) # returns an error that 'cyl' is not found
 
 Is there an easy way to get just the variable names or a template data
 frame that I can populate with my own values from a model object?  My
 best idea right now is to use a regular expression to strip away
 everything before and after ().  This would break down for things like
 I(cyl^2), though.
 
 Any ideas or thoughts would be welcome.
 
 Thanks,
 
 Josh
 
 

-- 
Eik Vettorazzi
Institut für Medizinische Biometrie und Epidemiologie
Universitätsklinikum Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/7410-58243
F ++49/40/7410-57790

__
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] question regarding gregexpr and read.table

2011-08-17 Thread Eik Vettorazzi
Hi Jack,
yes there is. see ?read.table for option check.names

and to the 2nd task . is a special character in regular expressions,
so mask it or don't use regular expressions:

gregexpr([.],A.B.C.D) #or
gregexpr(.,A.B.C.D,fixed=T)

cheers.

Am 17.08.2011 15:03, schrieb Jack Luo:
 Hi,
 
 I have a silly question regarding the usage of two commands: read.table and
 gregexpr:
 For read.table, if I read a matrix and set header = T, I found that all the
 dash (-) becomes dots (.)
 
 
 A = read.table(Matrix.txt, sep = \t, header = F)
 A[1,1]
 # A-B-C-D.
 
 A = read.table(Matrix.txt, sep = \t, header = T)
 colnames(A)[1]
 # A.B.C.D
 
 Is there a way to use the header = T argument, but still keep the original
 format A-B-C-D?
 
 For gregexpr,
 gregexpr(-,A-B-C-D)[[1]]
 #[1] 2 4 6
 #attr(,match.length)
 #[1] 1 1 1
 
 
 gregexpr(.,A.B.C.D)[[1]]
 [1] 1 2 3 4 5 6 7
 attr(,match.length)
 [1] 1 1 1 1 1 1 1
 
 Looks like dots means all the characters. Is there a way that I can extract
 the position of the dots specifically?
 
 Thanks,
 
 -Jack
 
   [[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.

-- 
Eik Vettorazzi
Institut für Medizinische Biometrie und Epidemiologie
Universitätsklinikum Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/7410-58243
F ++49/40/7410-57790

__
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] too many var in lm

2011-08-17 Thread carol white
Hello,
It might be an easy question but if you have many variables to fit in the lm 
function, how do you take all without specifying var1+var2+...+var2100 in the 
terms parameter in response ~ terms?

Cheers,

Carol

__
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] too many var in lm

2011-08-17 Thread R. Michael Weylandt
The most elegant solution is going to depend on where you data comes from,
but one way to do it if you have a matrix of data:

D = cbind(rcauchy(100), matrix(runif(100*50),ncol=50)) # Some nonsense data
lm(D[,1] ~ D[,-1])

If you let us know how your data is set up, a more specific response can be
given.

Hope this helps,

Michael Weylandt

On Wed, Aug 17, 2011 at 9:23 AM, carol white wht_...@yahoo.com wrote:

 Hello,
 It might be an easy question but if you have many variables to fit in the
 lm function, how do you take all without specifying var1+var2+...+var2100 in
 the terms parameter in response ~ terms?

 Cheers,

 Carol

 __
 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] question regarding gregexpr and read.table

2011-08-17 Thread Raphael Saldanha
Hi!

You can try import the file with header = F, and after inform that the first
row is a header.

On this post is some idea:
http://stackoverflow.com/questions/2293131/reading-first-row-as-header-is-easy-what-gives-with-two-rows-being-the-header

On Wed, Aug 17, 2011 at 10:03 AM, Jack Luo jluo.rh...@gmail.com wrote:

 Hi,

 I have a silly question regarding the usage of two commands: read.table and
 gregexpr:
 For read.table, if I read a matrix and set header = T, I found that all the
 dash (-) becomes dots (.)


 A = read.table(Matrix.txt, sep = \t, header = F)
 A[1,1]
 # A-B-C-D.

 A = read.table(Matrix.txt, sep = \t, header = T)
 colnames(A)[1]
 # A.B.C.D

 Is there a way to use the header = T argument, but still keep the original
 format A-B-C-D?

 For gregexpr,
 gregexpr(-,A-B-C-D)[[1]]
 #[1] 2 4 6
 #attr(,match.length)
 #[1] 1 1 1


 gregexpr(.,A.B.C.D)[[1]]
 [1] 1 2 3 4 5 6 7
 attr(,match.length)
 [1] 1 1 1 1 1 1 1

 Looks like dots means all the characters. Is there a way that I can extract
 the position of the dots specifically?

 Thanks,

 -Jack

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




-- 
Atenciosamente,

Raphael Saldanha
saldanha.plan...@gmail.com

[[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] getting names of dimnames of xtabs into xtable latex output

2011-08-17 Thread Juliet Hannah
Thanks for the suggestion, Duncan.

However, I was trying to maintain the contingency
table/cross-classification structure of the original table.

My use of xtable on this table, maintains the structure I want, but
the labels for the rownames and colum names is lost.



On Tue, Aug 16, 2011 at 11:06 PM, Duncan Mackay mac...@northnet.com.au wrote:
 Hi

 Will this fix the problem?

 str(table2)
 xtable(data.frame(table2))
 % latex table generated in R 2.13.1 by xtable 1.5-6 package
 % Wed Aug 17 13:02:38 2011
 \begin{table}[ht]
 \begin{center}
 \begin{tabular}{rllr}
  \hline
   change\_diet  mydiet  Freq \\
  \hline
 1  Don't know  0  26.00 \\
  2  Somewhat likely  0  0.00 \\
  3  Somewhat unlikely  0  40.00 \\
  4  Very likely  0  0.00 \\
  5  Very unlikely  0  10.00 \\
  6  Don't know  1  0.00 \\
  7  Somewhat likely  1  188.00 \\
  8  Somewhat unlikely  1  0.00 \\
  9  Very likely  1  281.00 \\
  10  Very unlikely  1  0.00 \\
   \hline
 \end{tabular}
 \end{center}
 \end{table}

 Regards

 Duncan


 Duncan Mackay
 Department of Agronomy and Soil Science
 University of New England
 ARMIDALE NSW 2351
 Email: home mac...@northnet.com.au





 At 02:03 17/08/2011, you wrote:

 In R, the output of xtabs displays the names of the dimnames.  In the
 example below, these are change_diet and mydiet. Is there a way to
 have xtable incorporate these names directly into the latex output.
 Thanks for your help.

 table2 - structure(c(26, 0, 40, 0, 10, 0, 188, 0, 281, 0), .Dim = c(5L,
 2L), .Dimnames = structure(list(change_diet = c(Don't know,
 Somewhat likely, Somewhat unlikely, Very likely, Very unlikely
 ), mydiet = c(0, 1)), .Names = c(change_diet, mydiet
 )), class = c(xtabs, table))
 table2


 library(xtable)
 xtable(table2)



  sessionInfo()
 R version 2.13.1 (2011-07-08)
 Platform: i386-pc-mingw32/i386 (32-bit)

 locale:
 [1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United
 States.1252    LC_MONETARY=English_United States.1252 LC_NUMERIC=C
 [5] LC_TIME=English_United States.1252

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

 other attached packages:
 [1] xtable_1.5-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.

 __
 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] too many var in lm

2011-08-17 Thread Dimitris Rizopoulos

another approach is:

Df - as.data.frame(cbind(rcauchy(100), matrix(runif(100*50), ncol = 50)))
fit - lm(V1 ~ ., data = Df)
fit


I hope it helps.

Best,
Dimitris


On 8/17/2011 3:28 PM, R. Michael Weylandt wrote:

The most elegant solution is going to depend on where you data comes from,
but one way to do it if you have a matrix of data:

D = cbind(rcauchy(100), matrix(runif(100*50),ncol=50)) # Some nonsense data
lm(D[,1] ~ D[,-1])

If you let us know how your data is set up, a more specific response can be
given.

Hope this helps,

Michael Weylandt

On Wed, Aug 17, 2011 at 9:23 AM, carol whitewht_...@yahoo.com  wrote:


Hello,
It might be an easy question but if you have many variables to fit in the
lm function, how do you take all without specifying var1+var2+...+var2100 in
the terms parameter in response ~ terms?

Cheers,

Carol

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



--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014
Web: http://www.erasmusmc.nl/biostatistiek/

__
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] too many var in lm

2011-08-17 Thread Eik Vettorazzi
Hi Carol,
it might be another question if it is sensible to use 2100 regression
parameters, but you can use . to regress one response against all other
variables in a data frame as in:

lm(formula = mpg ~ ., data = mtcars)

and you can even exclude specific variables using -
lm(formula = mpg ~ . - wt, data = mtcars)

cheers.

Am 17.08.2011 15:23, schrieb carol white:
 Hello,
 It might be an easy question but if you have many variables to fit in the lm 
 function, how do you take all without specifying var1+var2+...+var2100 in the 
 terms parameter in response ~ terms?
 
 Cheers,
 
 Carol
 
 __
 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.

-- 
Eik Vettorazzi

Department of Medical Biometry and Epidemiology
University Medical Center Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/7410-58243
F ++49/40/7410-57790

__
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] too many var in lm

2011-08-17 Thread Doran, Harold
I'm not sure this is the most elegant way. See ?formula for the canonical way 
of doing this in R. However, I am hoping you're not fitting a model with more 
than 2,000 predictors, are you? If so, ummm, wow. 

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
 Behalf Of R. Michael Weylandt
 Sent: Wednesday, August 17, 2011 9:28 AM
 To: carol white
 Cc: r-h...@stat.math.ethz.ch
 Subject: Re: [R] too many var in lm
 
 The most elegant solution is going to depend on where you data comes from,
 but one way to do it if you have a matrix of data:
 
 D = cbind(rcauchy(100), matrix(runif(100*50),ncol=50)) # Some nonsense data
 lm(D[,1] ~ D[,-1])
 
 If you let us know how your data is set up, a more specific response can be
 given.
 
 Hope this helps,
 
 Michael Weylandt
 
 On Wed, Aug 17, 2011 at 9:23 AM, carol white wht_...@yahoo.com wrote:
 
  Hello,
  It might be an easy question but if you have many variables to fit in the
  lm function, how do you take all without specifying var1+var2+...+var2100 in
  the terms parameter in response ~ terms?
 
  Cheers,
 
  Carol
 
  __
  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.


[R] Lattice: problem with setting space between plot and legend

2011-08-17 Thread mike1989
Dear R Users, 

I am writing code to present my output data (I'm using Lattice Package).
However, it's essential for me to control space between barchart and legend.
I've read the package's specification, but unfortunately I haven't spot the
information how to do this. Here's the code I've written:

barchart(mymatrix[,1:ncol(mymatrix)],horizontal=FALSE, 
box.width=1,stack=TRUE,border=FALSE,par.settings = simpleTheme(col
=my_colors),lty=dotted,lend=butt,key=list(space=bottom,columns=ncol(mymatrix),points=FALSE,text=list(colnames(mymatrix)),rectangles=list(border=FALSE,size=2,col=my_colors[1:ncol(mymatrix)]),border=FALSE,rows=1,between=0.25))


Thank you for any assistance. 

--
View this message in context: 
http://r.789695.n4.nabble.com/Lattice-problem-with-setting-space-between-plot-and-legend-tp3749919p3749919.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.


Re: [R] exponential model with decreasing

2011-08-17 Thread Komine
Thank you  bbolker for your help and advice about guide. 
Komine


--
View this message in context: 
http://r.789695.n4.nabble.com/exponential-model-with-decreasing-tp3747572p3749933.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.


Re: [R] Lattice: problem with setting space between plot and legend

2011-08-17 Thread Raphael Saldanha
Hi,

Maybe this post can help you:
http://tolstoy.newcastle.edu.au/R/e2/help/06/10/2735.html

On Wed, Aug 17, 2011 at 10:15 AM, mike1989 mihau@gmail.com wrote:

 Dear R Users,

 I am writing code to present my output data (I'm using Lattice Package).
 However, it's essential for me to control space between barchart and
 legend.
 I've read the package's specification, but unfortunately I haven't spot the
 information how to do this. Here's the code I've written:

 barchart(mymatrix[,1:ncol(mymatrix)],horizontal=FALSE,
 box.width=1,stack=TRUE,border=FALSE,par.settings = simpleTheme(col

 =my_colors),lty=dotted,lend=butt,key=list(space=bottom,columns=ncol(mymatrix),points=FALSE,text=list(colnames(mymatrix)),rectangles=list(border=FALSE,size=2,col=my_colors[1:ncol(mymatrix)]),border=FALSE,rows=1,between=0.25))


 Thank you for any assistance.

 --
 View this message in context:
 http://r.789695.n4.nabble.com/Lattice-problem-with-setting-space-between-plot-and-legend-tp3749919p3749919.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.




-- 
Atenciosamente,

Raphael Saldanha
saldanha.plan...@gmail.com

[[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] Problems installing SJava

2011-08-17 Thread Uwe Ligges

Are you sure rJava is not fine for you?

Uwe Ligges

On 16.08.2011 17:16, Luis Felipe Parra wrote:

Hello, I am trying to install SJava but I haven't been able to complete it
successfully. I have tried to install it from bioconductor using the
followin code and got the following output:


source(http://www.bioconductor.org/biocLite.R;)

BioC_mirror = http://bioconductor.org
Change using chooseBioCmirror().

 biocLite(SJava)

Using R version 2.12.2, biocinstall version 2.7.7.
Installing Bioconductor version 2.7 packages:
[1] SJava
Please wait...

Installing package(s) into ‘C:\Users\Hp\Documents/R/win-library/2.12’
(as ‘lib’ is unspecified)
Mensajes de aviso perdidos
In getDependencies(pkgs, dependencies, available, lib) :
   package ‘SJava’ is not available


And I have also tried the instructions: found in
http://www.omegahat.org/RSJava/.

cd *$RHOME*/src/library
unzip SJava_0.69-0.zip
cd SJava
./configure.win $RHOME
cd *$RHOME*/src/gnuwin32
make pkg-SJava

But when I tried the line unzip SJava_0.69-0.zip it tells me the command
cannot be recognized. If I unzip the file manually and then try the
line ./configure.win
$RHOME I get . ccannot be recognized. Does somebody know what might I be
doing wrong. Or which is an easier way to install this package?

My computer is on Window 7 professional (32 bits)

Thank you

Felipe Parra

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


Re: [R] Problems installing SJava

2011-08-17 Thread Luis Felipe Parra
Uggs, as I understand rJava is for calling Java from within R and what I
need is to call R within Java. Am I wrong?

2011/8/17 Uwe Ligges lig...@statistik.tu-dortmund.de

 Are you sure rJava is not fine for you?

 Uwe Ligges


 On 16.08.2011 17:16, Luis Felipe Parra wrote:

 Hello, I am trying to install SJava but I haven't been able to complete it
 successfully. I have tried to install it from bioconductor using the
 followin code and got the following output:

  
 source(http://www.**bioconductor.org/biocLite.Rhttp://www.bioconductor.org/biocLite.R
 )

 BioC_mirror = http://bioconductor.org
 Change using chooseBioCmirror().

 biocLite(SJava)

 Using R version 2.12.2, biocinstall version 2.7.7.
 Installing Bioconductor version 2.7 packages:
 [1] SJava
 Please wait...

 Installing package(s) into ‘C:\Users\Hp\Documents/R/win-**library/2.12’
 (as ‘lib’ is unspecified)
 Mensajes de aviso perdidos
 In getDependencies(pkgs, dependencies, available, lib) :
   package ‘SJava’ is not available


 And I have also tried the instructions: found in
 http://www.omegahat.org/**RSJava/ http://www.omegahat.org/RSJava/.

 cd *$RHOME*/src/library
unzip SJava_0.69-0.zip
cd SJava
./configure.win $RHOME
cd *$RHOME*/src/gnuwin32
make pkg-SJava

 But when I tried the line unzip SJava_0.69-0.zip it tells me the command
 cannot be recognized. If I unzip the file manually and then try the
 line ./configure.win
 $RHOME I get . ccannot be recognized. Does somebody know what might I be
 doing wrong. Or which is an easier way to install this package?

 My computer is on Window 7 professional (32 bits)

 Thank you

 Felipe Parra

[[alternative HTML version deleted]]




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




-- 

Este mensaje de correo electrónico es enviado por Quantil S.A.S y puede
contener información confidencial o privilegiada.

This e-mail is sent by Quantil S.A.S and may contain confidential or
privileged information

[[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] Chi square test on data frame

2011-08-17 Thread Bansal, Vikas
Is there anyone who can help me with chi square test on data frame.I am 
struggling from last 2 days.I will be very  thankful to you.

Dear all,

I have been working on this problem from so many hours but did not find any 
solution.
I have a data frame with 8 columns-
   V1   V2   V3   V4  W1   W2W3   W4
1 084   22   10   0  84  0  0
2358400 22  84  0  0
3 0 0  0  48   0   00 48
4 04800   0  48   0  0
5 08400   0  84   0  0
6 0 00   48   0   00 48

from first four columns, for each row I have to take two largest values. and 
these two values will be considered as observed values.And from last four 
column we will get the expected values.So i have to perform chi square test for 
each row to get p values.

example for first row is-

first two largest values are 84(in V2) and 22 (in V3).so these are considered 
as observed values.Now if the largest values are in V2 and V3,we have to pick 
expected values from W2 and W3 which are 84 and 0.I know for chi square test 
values should not be 0 but we will ignore the warning.
Now as we have observed value as well as expected we have to perform chi square 
test to get p values for each row in a new column.


So far I was working as returning the index for two largest value with-
sort.int(df,index.return=TRUE)$ix[c(4,3)]
 but it does not accept data frame.

Can you please give some idea how to do this,because it is very tricky and 
after studying a lot, I am not able to perform.Please help.



Thanking you,
Warm Regards
Vikas Bansal
Msc Bioinformatics
Kings College London
__
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] Lattice: problem with setting space between plot and legend

2011-08-17 Thread David Winsemius


On Aug 17, 2011, at 9:15 AM, mike1989 wrote:


Dear R Users,

I am writing code to present my output data (I'm using Lattice  
Package).
However, it's essential for me to control space between barchart and  
legend.
I've read the package's specification, but unfortunately I haven't  
spot the

information how to do this. Here's the code I've written:



require(lattice)


barchart(mymatrix[,1:ncol(mymatrix)], horizontal=FALSE,
box.width=1, stack=TRUE, border=FALSE, par.settings =  
simpleTheme(col=my_colors), lty=dotted, lend=butt,



key=list(space=bottom,
columns=ncol(mymatrix),
points=FALSE,
text=list(colnames(mymatrix)),
rectangles=list(border=FALSE,size=2, col=my_colors[1:ncol(mymatrix)]),
border=FALSE, rows=1, between=0.25))


a) You ought to use spaces and linefeeds for readability
b) It appears you are using the key option so the documentation is in  
the .../key section regarding placement:


Alternatively, [and this comes just after the description of the  
space= options] the key can be positioned inside the plot region by  
specifying components x, y and corner. x and y determine the location  
of the corner of the key given by corner, which is usually one of  
c(0,0), c(1,0), c(1,1) and c(0,1), which denote the corners of the  
unit square. Fractional values are also allowed, in which case xand y  
determine the position of an arbitrary point inside (or outside for  
values outside the unit interval) the key.


Now I will admit that I did not understand what that last sentence  
regarding an arbitrary point inside the key might mean on the first  
three readings. I'm hoping it means a user-determined point inside  
the _plot_. I also cannot figure out from that paragraph or the one  
that follows which corner of the key is being located.


Lack of an included example triggers my do-no-more rule regarding such  
posts.


--
David.



Thank you for any assistance.

--
View this message in context: 
http://r.789695.n4.nabble.com/Lattice-problem-with-setting-space-between-plot-and-legend-tp3749919p3749919.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.


David Winsemius, MD
West Hartford, CT

__
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] too many var in lm

2011-08-17 Thread carol white
Thanks for your all replies.
 
Actually, I have more than this number of variables. I want to make a selection 
of variables with anova and I thought that I can apply anova to the object 
obtained by lm. The purpose is to select the genes discriminting control 
samples from disease.
 
Best,

Carol

- Original Message -
From: Eik Vettorazzi e.vettora...@uke.uni-hamburg.de
To: carol white wht_...@yahoo.com
Cc: r-h...@stat.math.ethz.ch r-h...@stat.math.ethz.ch
Sent: Wednesday, August 17, 2011 3:39 PM
Subject: Re: [R] too many var in lm

Hi Carol,
it might be another question if it is sensible to use 2100 regression
parameters, but you can use . to regress one response against all other
variables in a data frame as in:

lm(formula = mpg ~ ., data = mtcars)

and you can even exclude specific variables using -
lm(formula = mpg ~ . - wt, data = mtcars)

cheers.

Am 17.08.2011 15:23, schrieb carol white:
 Hello,
 It might be an easy question but if you have many variables to fit in the lm 
 function, how do you take all without specifying var1+var2+...+var2100 in the 
 terms parameter in response ~ terms?
 
 Cheers,
 
 Carol
 
 __
 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.

-- 
Eik Vettorazzi

Department of Medical Biometry and Epidemiology
University Medical Center Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/7410-58243
F ++49/40/7410-57790


__
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] too many var in lm

2011-08-17 Thread David Winsemius


On Aug 17, 2011, at 10:39 AM, carol white wrote:


Thanks for your all replies.

Actually, I have more than this number of variables. I want to make  
a selection of variables with anova and I thought that I can apply  
anova to the object obtained by lm. The purpose is to select the  
genes discriminting control samples from disease.




You need to consult a statistician with experience in this area.

--
David.


Best,

Carol

- Original Message -
From: Eik Vettorazzi e.vettora...@uke.uni-hamburg.de
To: carol white wht_...@yahoo.com
Cc: r-h...@stat.math.ethz.ch r-h...@stat.math.ethz.ch
Sent: Wednesday, August 17, 2011 3:39 PM
Subject: Re: [R] too many var in lm

Hi Carol,
it might be another question if it is sensible to use 2100 regression
parameters, but you can use . to regress one response against all  
other

variables in a data frame as in:

lm(formula = mpg ~ ., data = mtcars)

and you can even exclude specific variables using -
lm(formula = mpg ~ . - wt, data = mtcars)

cheers.

Am 17.08.2011 15:23, schrieb carol white:

Hello,
It might be an easy question but if you have many variables to fit  
in the lm function, how do you take all without specifying  
var1+var2+...+var2100 in the terms parameter in response ~ terms?


Cheers,

Carol

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


--
Eik Vettorazzi

Department of Medical Biometry and Epidemiology
University Medical Center Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/7410-58243
F ++49/40/7410-57790


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


David Winsemius, MD
West Hartford, CT

__
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] postscript( does not save the plot

2011-08-17 Thread Alaios
The problem is a bit weird.

This does not work:

ps.options=setEPS()
postscript(file=exponcoverapprox.eps)
boxplot(test[30,1:500],test[90,1:500],test[150,1:500],test[210,1:500],test[270,1:500],test[330,1:500],test[390,1:500],names=c(1,3,5,8,10,13,1),outline=FALSE,ylim=c(0.01,50),log=y,
 xlab = xvalue,ylab=yvalue,boxwex=0.5, pars 
=list(whisklwd=0,staplelwd=0))
dev.off()




This works
postscript(file=exponcoverapprox.eps)
boxplot(test[30,1:500],test[90,1:500],test[150,1:500],test[210,1:500],test[270,1:500],test[330,1:500],test[390,1:500],names=c(1,3,5,8,10,13,1),outline=FALSE,ylim=c(0.01,50),log=y,
 xlab = xvalue,ylab=yvalue,boxwex=0.5)
dev.off()
 


To not bother you with the details, the only difference is the pars 
=list(whisklwd=0,staplelwd=0) at the end of the boxplot , which I use to remove 
the whiskers fromt he blot.

B.R




From: Marc Schwartz marc_schwa...@me.com

Cc: R-help@r-project.org R-help@r-project.org
Sent: Tuesday, August 16, 2011 7:38 PM
Subject: Re: [R] postscript( does not save the plot

On Aug 16, 2011, at 12:32 PM, Alaios wrote:

 Dear all,
 I am using the following code to write the plot to an eps format
 
 postscript(file=test.eps,horizontal=FALSE)
 
 boxplot(test[30,1:500],test[90,1:500],test[150,1:500],test[210,1:500],test[270,1:500],test[330,1:500],test[390,1:500],names=c(1,3,5,8,10,13,1),outline=FALSE,ylim=c(0.01,50),log=y,
  xlab = xvalue,ylab=yvalue,boxwex=0.5, pars =list(whisklwd=0,staplelwd=0))
 
 dev.off()
 
 
 This creates a 6kb eps file, that can not be opened by any program. I tired 
 with photoshop gimp, acrobat reader. This is the normal process I follow to 
 save my plots.
 
 dev.off always returns 1.
 
 and the boxplot function succesfullu does the plot in the screen.
 
 What might be the problem?
 
 I would like to thank you in advance for your help
 
 B.R
 Alex



You did not create an EPS file. See ?postscript and pay attention to the fourth 
paragraph under Details:

The postscript produced for a single R plot is EPS (Encapsulated PostScript) 
compatible, and can be included into other documents, e.g., into LaTeX, using 
\includegraphics{filename}. For use in this way you will probably want to use 
setEPS() to set the defaults as horizontal = FALSE, onefile = FALSE, paper = 
special. Note that the bounding box is for the device region: if you find the 
white space around the plot region excessive, reduce the margins of the figure 
region viapar(mar=).


HTH,

Marc Schwartz
[[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] Symbol Font Baseline, Cairo, Card Symbols

2011-08-17 Thread ivo welch
hi gavin---I am not even sure that it is a cairo bug, much less do I
know about the details where it sits.  for all I know, it could be an
Apple problem. the possible bug report was not only for the cairo
package (what's the difference between a package and a library?  in my
user R code, I invoke it as library(cairo)), but also for others who
may use it and be surprised when they run into the same issue,
wondering if it is their code, or a more general issue..

/iaw


Ivo Welch (ivo.we...@gmail.com)





On Wed, Aug 17, 2011 at 5:18 AM, Gavin Simpson gavin.simp...@ucl.ac.uk wrote:
 On Tue, 2011-08-16 at 17:46 -0700, ivo welch wrote:
 I think I found a bug in the Cairo library, plus weird behavior in
 both the Cairo and the normal pdf device.  The baseline of the spades
 symbol seems to be off.  This is easier to show than it is to explain.
  The problem does not appear in the normal pdf device, which is why I
 am guessing this is a Cairo bug.  moreover, I cannot figure out why
 three of the card symbols seem to be transparent, but the fourth is
 not.  this is the case for both the Cairo and the ordinary pdf
 devices.

 I thought I would report it to the R wizards on this group...

 Why? One is expressly asked to address such problems with the package
 maintainer(s), especially if you feel there is a bug in the package.

 And whilst Martin M is potentially indisposed at UseR! 2011, I will
 mention that it is a *package* not a library when you refer to the R
 package Cario. If you had identified a bug in the Cairo *library* you
 should be reporting it upstream to the Cairo people:
 http://www.cairographics.org/

 G

 library(Cairo)

 clubs - expression(symbol('\247'))
 hearts - expression(symbol('\250'))
 diamonds - expression(symbol('\251'))
 spades - expression(symbol('\252'))
 csymbols - c(clubs, diamonds, hearts, spades)

 CairoPDF(file = cardsymbols.pdf)

 plot( 0, xlim=c(0,5), ylim=c(0,2), type=n )
 clr - c(black, red, red, black)
 for (i in 1:4) {
   hline - function( yloc, ... ) for (i in 1:length(yloc)) lines(
 c(-1,6), c(yloc[i],yloc[i]), col=gray)
   hline(0.9);  hline(1.0);   hline(1.1);   hline(1.2)
   text( i, 1, csymbols[i], col=clr[i], cex=5 )
   text( i, 0.5, csymbols[i], col=clr[i] )
 }

 dev.off()



 
 Ivo Welch (ivo.we...@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.

 --
 %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
  Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
  ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
  Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
  Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
  UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
 %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%



__
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] How to use PC1 of PCA and dim1 of MCA as a predictor in logistic regression model for data reduction

2011-08-17 Thread khosoda
Hi all,

I'm trying to do model reduction for logistic regression. I have 13
predictor (4 continuous variables and 9 binary variables). Using subject
matter knowledge, I selected 4 important variables. Regarding the rest 9
variables, I tried to perform data reduction by principal component
analysis (PCA). However, 8 of 9 variables were binary and only one
continuous. I transformed the data by transcan of rms package and did
PCA with princomp. PC1 explained only 20% of the variance. Still, I used
the PC1 as a predictor of the logistic model and obtained some results.

Then, I tried multiple correspondence analysis (MCA). The only one
continuous variable was age. I transformed age variable to age_Q
factor variable as the followings.

 quantile(mydata.df$age)
   0%   25%   50%   75%  100%
53.00 66.75 72.00 76.25 85.00
 age_Q - cut(x17.df$age, right=TRUE, breaks=c(-Inf, 66, 72, 76, Inf),
labels=c(53-66, 67-72, 73-76, 77-85))
 table(age_Q)
age_Q
53-66 67-72 73-76 77-85
   26272526

Then, I used mjca of ca pacakge for MCA.

 mjca1 -  mjca(mydata.df[, c(age_Q,sex,symptom, HT, DM,
IHD,smoking,DL, Statin)])

 summary(mjca1)

Principal inertias (eigenvalues):

 dimvalue  %   cum%   scree plot
 1  0.009592  43.4  43.4  *
 2  0.003983  18.0  61.4  **
 3  0.001047   4.7  66.1  **
 4  0.000367   1.7  67.8
 -
 Total: 0.022111

The dimension 1 explained 43% of the variance. Then, I was wondering
which values I could use like PC1 in PCA. I explored in mjca1 and found
rowcoord.

 mjca1$rowcoord
  [,1]  [,2][,3] [,4]
  [1,]  0.07403748  0.8963482181  0.10828273  1.581381849
  [2,]  0.92433996 -1.1497911361  1.28872517  0.304065865
  [3,]  0.49833354  0.6482940556 -2.4314  0.365023261
  [4,]  0.18998290 -1.4028117048 -1.70962159  0.451951744
  [5,] -0.13008173  0.2557656854  1.16561601 -1.012992485
.
.
[101,] -1.86940216  0.5918128751  0.87352987 -1.118865117
[102,] -2.19096615  1.2845448725  0.25227354 -0.938612155
[103,]  0.77981265 -1.1931087587  0.23934034  0.627601413
[104,] -2.37058237 -1.4014005013 -0.73578248 -1.455055095

Then, I used mjca1$rowcoord[, 1] as the followings.

 mydata.df$NewScore - mjca1$rowcoord[, 1]

I used this NewScore as one of the predictors for the model instead of
original 9 variables.

The final logistic model obtained by use of MCA was similar to the one
obtained by use of PCA.

My questions are;

1. Is it O.K. to perform PCA for data consisting of 1 continuous
variable and 8 binary variables?

2. Is it O.K to perform transformation of age from continuous variable
to factor variable for MCA?

3. Is mjca1$rowcoord[, 1] the correct values as a predictor of
logistic regression model like PC1 of PCA?

I would appreciate your help in advance.

--
Kohkichi Hosoda

__
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] Lattice: problem with setting space between plot and legend

2011-08-17 Thread Bert Gunter
(Note: Posted at the suggetsion of David Winsemius, to whom I already
sent a private reply).

Inline Below.

On Wed, Aug 17, 2011 at 7:34 AM, David Winsemius dwinsem...@comcast.net wrote:

 On Aug 17, 2011, at 9:15 AM, mike1989 wrote:

 Dear R Users,

 I am writing code to present my output data (I'm using Lattice Package).
 However, it's essential for me to control space between barchart and
 legend.
 I've read the package's specification, but unfortunately I haven't spot
 the
 information how to do this. Here's the code I've written:


 require(lattice)

 barchart(mymatrix[,1:ncol(mymatrix)], horizontal=FALSE,
 box.width=1, stack=TRUE, border=FALSE, par.settings =
 simpleTheme(col=my_colors), lty=dotted, lend=butt,

 key=list(space=bottom,
 columns=ncol(mymatrix),
 points=FALSE,
 text=list(colnames(mymatrix)),
 rectangles=list(border=FALSE,size=2, col=my_colors[1:ncol(mymatrix)]),
 border=FALSE, rows=1, between=0.25))

 a) You ought to use spaces and linefeeds for readability
 b) It appears you are using the key option so the documentation is in the
 .../key section regarding placement:

 Alternatively, [and this comes just after the description of the space=
 options] the key can be positioned inside the plot region by specifying
 components x, y and corner. x and y determine the location of the corner of
 the key given by corner, which is usually one of c(0,0), c(1,0), c(1,1) and
 c(0,1), which denote the corners of the unit square. Fractional values are
 also allowed, in which case xand y determine the position of an arbitrary
 point inside (or outside for values outside the unit interval) the key.

 Now I will admit that I did not understand what that last sentence regarding
 an arbitrary point inside the key might mean on the first three readings.
 I'm hoping it means a user-determined point inside the _plot_. I also
 cannot figure out from that paragraph or the one that follows which corner
 of the key is being located.
 David.


I don't think so. Here's my translation of the Help file:

There are 2 coordinate systems at play here, that of the plot and that
of the key. The plot's coordinate system is native, and is used by the
x and y components of the space component of key. The key's coordinate
system is 0 to 1 on both axes and specifies the key coordinate that is
placed at the x and y plot location. Hence, space = list (x=10, y =
2,corner = c(1,0)) says place the right lower corner of the key at
plot location (10,2).  Replacing the corner component by c(.5,.5)
means place the center of the key at that location on the plot.

Cheers,
Bert
-- 
Men by nature long to get on to the ultimate truths, and will often
be impatient with elementary studies or fight shy of them. If it were
possible to reach the ultimate truths without the elementary studies
usually prefixed to them, these would not be preparatory studies but
superfluous diversions.

-- Maimonides (1135-1204)

Bert Gunter
Genentech Nonclinical Biostatistics

__
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] Lattice: problem with setting space between plot and legend

2011-08-17 Thread David Winsemius


On Aug 17, 2011, at 11:19 AM, Bert Gunter wrote:


(Note: Posted at the suggetsion of David Winsemius, to whom I already
sent a private reply).

Inline Below.

On Wed, Aug 17, 2011 at 7:34 AM, David Winsemius dwinsem...@comcast.net 
 wrote:


On Aug 17, 2011, at 9:15 AM, mike1989 wrote:


Dear R Users,

I am writing code to present my output data (I'm using Lattice  
Package).

However, it's essential for me to control space between barchart and
legend.
I've read the package's specification, but unfortunately I haven't  
spot

the
information how to do this. Here's the code I've written:



require(lattice)


barchart(mymatrix[,1:ncol(mymatrix)], horizontal=FALSE,
box.width=1, stack=TRUE, border=FALSE, par.settings =
simpleTheme(col=my_colors), lty=dotted, lend=butt,



key=list(space=bottom,
columns=ncol(mymatrix),
points=FALSE,
text=list(colnames(mymatrix)),
rectangles=list(border=FALSE,size=2,  
col=my_colors[1:ncol(mymatrix)]),

border=FALSE, rows=1, between=0.25))


a) You ought to use spaces and linefeeds for readability
b) It appears you are using the key option so the documentation is  
in the

.../key section regarding placement:

Alternatively, [and this comes just after the description of the  
space=
options] the key can be positioned inside the plot region by  
specifying
components x, y and corner. x and y determine the location of the  
corner of
the key given by corner, which is usually one of c(0,0), c(1,0),  
c(1,1) and
c(0,1), which denote the corners of the unit square. Fractional  
values are
also allowed, in which case xand y determine the position of an  
arbitrary
point inside (or outside for values outside the unit interval) the  
key.


Now I will admit that I did not understand what that last sentence  
regarding
an arbitrary point inside the key might mean on the first three  
readings.
I'm hoping it means a user-determined point inside the _plot_. I  
also
cannot figure out from that paragraph or the one that follows which  
corner

of the key is being located.
David.




I don't think so. Here's my translation of the Help file:

There are 2 coordinate systems at play here, that of the plot and that
of the key. The plot's coordinate system is native, and is used by the
x and y components of the space component of key. The key's coordinate
system is 0 to 1 on both axes and specifies the key coordinate that is
placed at the x and y plot location. Hence, space = list (x=10, y =
2,corner = c(1,0)) says place the right lower corner of the key at
plot location (10,2).  Replacing the corner component by c(.5,.5)
means place the center of the key at that location on the plot.


Thanks, Bert;

That did clarify for me that the x and y arguments were specifying the  
plot coordinates (expressed in data variable units) of a particular  
point of the key box (specified in unit key-coordinates). Thanks for  
lessening my overall confusion.


--

David Winsemius, MD
West Hartford, CT

__
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 variables from model formula

2011-08-17 Thread Joshua Wiley
Hi Eik,

Thanks, that got me on the right track.  After looking at how
get_all_vars() works, I am using:

all.vars(as.formula(m))

which works great.

Thanks again,

Josh

On Wed, Aug 17, 2011 at 6:14 AM, Eik Vettorazzi
e.vettora...@uke.uni-hamburg.de wrote:
 Hi Josh,
 I think,

 m - lm(mpg ~ factor(cyl)+I(mpg^2), data = mtcars)
 nd-get_all_vars(m,data=mtcars)

 is what you are after.

 cheers.

 Am 17.08.2011 04:27, schrieb Joshua Wiley:
 Hi All,

 I am writing a function to predict values based on a model.  It works
 fine as long as the formula just uses regular variable names.  I am
 having a problem when the variables are wrapped with a function call.
 For example:

 m - lm(mpg ~ factor(cyl), data = mtcars)
 ## I get the column names using
 as.character(attr(terms(m), variables))[-1L]
 ## which gives the same column names as in
 # m$model

 predict(m, m$model) # returns an error that 'cyl' is not found

 Is there an easy way to get just the variable names or a template data
 frame that I can populate with my own values from a model object?  My
 best idea right now is to use a regular expression to strip away
 everything before and after ().  This would break down for things like
 I(cyl^2), though.

 Any ideas or thoughts would be welcome.

 Thanks,

 Josh



 --
 Eik Vettorazzi
 Institut für Medizinische Biometrie und Epidemiologie
 Universitätsklinikum Hamburg-Eppendorf

 Martinistr. 52
 20246 Hamburg

 T ++49/40/7410-58243
 F ++49/40/7410-57790




-- 
Joshua Wiley
Ph.D. Student, Health Psychology
Programmer Analyst II, ATS Statistical Consulting Group
University of California, Los Angeles
https://joshuawiley.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.


Re: [R] question regarding gregexpr and read.table

2011-08-17 Thread Jack Luo
Thank, Eik, it works!

-Jack

On Wed, Aug 17, 2011 at 9:19 AM, Eik Vettorazzi 
e.vettora...@uke.uni-hamburg.de wrote:

 Hi Jack,
 yes there is. see ?read.table for option check.names

 and to the 2nd task . is a special character in regular expressions,
 so mask it or don't use regular expressions:

 gregexpr([.],A.B.C.D) #or
 gregexpr(.,A.B.C.D,fixed=T)

 cheers.

 Am 17.08.2011 15:03, schrieb Jack Luo:
  Hi,
 
  I have a silly question regarding the usage of two commands: read.table
 and
  gregexpr:
  For read.table, if I read a matrix and set header = T, I found that all
 the
  dash (-) becomes dots (.)
 
 
  A = read.table(Matrix.txt, sep = \t, header = F)
  A[1,1]
  # A-B-C-D.
 
  A = read.table(Matrix.txt, sep = \t, header = T)
  colnames(A)[1]
  # A.B.C.D
 
  Is there a way to use the header = T argument, but still keep the
 original
  format A-B-C-D?
 
  For gregexpr,
  gregexpr(-,A-B-C-D)[[1]]
  #[1] 2 4 6
  #attr(,match.length)
  #[1] 1 1 1
 
 
  gregexpr(.,A.B.C.D)[[1]]
  [1] 1 2 3 4 5 6 7
  attr(,match.length)
  [1] 1 1 1 1 1 1 1
 
  Looks like dots means all the characters. Is there a way that I can
 extract
  the position of the dots specifically?
 
  Thanks,
 
  -Jack
 
[[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.

 --
 Eik Vettorazzi
 Institut für Medizinische Biometrie und Epidemiologie
 Universitätsklinikum Hamburg-Eppendorf

 Martinistr. 52
 20246 Hamburg

 T ++49/40/7410-58243
 F ++49/40/7410-57790


[[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] postscript( does not save the plot

2011-08-17 Thread Marc Schwartz
Not sure what output you get in the first case. You don't need:

  ps.options=setEPS()

just:

  setEPS()


Using:

set.seed(1)
test - matrix(runif(500*500), 500)

setEPS()

postscript(file = exponcoverapprox.eps)

boxplot(test[30, 1:500], test[90, 1:500], test[150, 1:500], test[210, 1:500],
test[270, 1:500], test[330, 1:500], test[390, 1:500],
names = c(1, 3, 5, 8, 10, 13, 1), outline = FALSE,
ylim=c(0.01, 50), log = y, xlab = xvalue, ylab = yvalue,
boxwex=0.5, pars = list(whisklwd = 0, staplelwd = 0))

dev.off()


I get the attached output which seems to be OK.

Marc


On Aug 17, 2011, at 10:02 AM, Alaios wrote:

 The problem is a bit weird.
 
 This does not work:
 
 ps.options=setEPS()
 postscript(file=exponcoverapprox.eps)
 boxplot(test[30,1:500],test[90,1:500],test[150,1:500],test[210,1:500],test[270,1:500],test[330,1:500],test[390,1:500],names=c(1,3,5,8,10,13,1),outline=FALSE,ylim=c(0.01,50),log=y,
  xlab = xvalue,ylab=yvalue,boxwex=0.5, pars 
 =list(whisklwd=0,staplelwd=0))
 dev.off()
 
 
 
 
 This works
 postscript(file=exponcoverapprox.eps)
 boxplot(test[30,1:500],test[90,1:500],test[150,1:500],test[210,1:500],test[270,1:500],test[330,1:500],test[390,1:500],names=c(1,3,5,8,10,13,1),outline=FALSE,ylim=c(0.01,50),log=y,
  xlab = xvalue,ylab=yvalue,boxwex=0.5)
 dev.off()
 
 
 
 To not bother you with the details, the only difference is the pars 
 =list(whisklwd=0,staplelwd=0) at the end of the boxplot , which I use to 
 remove the whiskers fromt he blot.
 
 B.R
 
 
 
 
 From: Marc Schwartz marc_schwa...@me.com
 
 Cc: R-help@r-project.org R-help@r-project.org
 Sent: Tuesday, August 16, 2011 7:38 PM
 Subject: Re: [R] postscript( does not save the plot
 
 On Aug 16, 2011, at 12:32 PM, Alaios wrote:
 
 Dear all,
 I am using the following code to write the plot to an eps format
 
 postscript(file=test.eps,horizontal=FALSE)
 
 boxplot(test[30,1:500],test[90,1:500],test[150,1:500],test[210,1:500],test[270,1:500],test[330,1:500],test[390,1:500],names=c(1,3,5,8,10,13,1),outline=FALSE,ylim=c(0.01,50),log=y,
  xlab = xvalue,ylab=yvalue,boxwex=0.5, pars 
 =list(whisklwd=0,staplelwd=0))
 
 dev.off()
 
 
 This creates a 6kb eps file, that can not be opened by any program. I tired 
 with photoshop gimp, acrobat reader. This is the normal process I follow to 
 save my plots.
 
 dev.off always returns 1.
 
 and the boxplot function succesfullu does the plot in the screen.
 
 What might be the problem?
 
 I would like to thank you in advance for your help
 
 B.R
 Alex
 
 
 
 You did not create an EPS file. See ?postscript and pay attention to the 
 fourth paragraph under Details:
 
 The postscript produced for a single R plot is EPS (Encapsulated PostScript) 
 compatible, and can be included into other documents, e.g., into LaTeX, using 
 \includegraphics{filename}. For use in this way you will probably want to 
 use setEPS() to set the defaults as horizontal = FALSE, onefile = FALSE, 
 paper = special. Note that the bounding box is for the device region: if 
 you find the white space around the plot region excessive, reduce the margins 
 of the figure region viapar(mar=).
 
 
 HTH,
 
 Marc Schwartz

__
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] Symbol Font Baseline, Cairo, Card Symbols

2011-08-17 Thread Gavin Simpson
On Wed, 2011-08-17 at 08:06 -0700, ivo welch wrote:
 hi gavin---I am not even sure that it is a cairo bug, much less do I
 know about the details where it sits.  for all I know, it could be an
 Apple problem. the possible bug report was not only for the cairo
 package (what's the difference between a package and a library?  in my
 user R code, I invoke it as library(cairo)), but also for others who
 may use it and be surprised when they run into the same issue,
 wondering if it is their code, or a more general issue..

In the real world, libraries contain books. In the R world, libraries
contain packages. In the same way that in the real world it would be
silly and wrong to call a book a library, it is wrong to call an R
package a library.

The thing that resides on CRAN is the R *package* named Cairo. It
works by making use of a general purpose *software* *library* called
Cairo, details of which can be found here
http://www.cairographics.org/ .

I appreciate that the name of the `library()` function used to load
packages for use is somewhat counter-intuitive, but there you go. There
is talk of moving to a `use()` function to replace `library()`; when/if
that happens, perhaps it will lessen the confusion.

Even if you are not sure, the general advice is to email the
maintainers. If there is nothing wrong and this is a quirk of
fonts/system/OS etc then your archived email lives on via Google and may
confuse others in the future. Giving package authors a chance to look at
the problem is also common courtesy. The Posting Guide is clear in this
regard:

If the question relates to a contributed package , e.g., one downloaded
from CRAN, try contacting the package maintainer first.

Many people ignore this however.

G

 /iaw
 
 
 Ivo Welch (ivo.we...@gmail.com)
 
 
 
 
 
 On Wed, Aug 17, 2011 at 5:18 AM, Gavin Simpson gavin.simp...@ucl.ac.uk 
 wrote:
  On Tue, 2011-08-16 at 17:46 -0700, ivo welch wrote:
  I think I found a bug in the Cairo library, plus weird behavior in
  both the Cairo and the normal pdf device.  The baseline of the spades
  symbol seems to be off.  This is easier to show than it is to explain.
   The problem does not appear in the normal pdf device, which is why I
  am guessing this is a Cairo bug.  moreover, I cannot figure out why
  three of the card symbols seem to be transparent, but the fourth is
  not.  this is the case for both the Cairo and the ordinary pdf
  devices.
 
  I thought I would report it to the R wizards on this group...
 
  Why? One is expressly asked to address such problems with the package
  maintainer(s), especially if you feel there is a bug in the package.
 
  And whilst Martin M is potentially indisposed at UseR! 2011, I will
  mention that it is a *package* not a library when you refer to the R
  package Cario. If you had identified a bug in the Cairo *library* you
  should be reporting it upstream to the Cairo people:
  http://www.cairographics.org/
 
  G
 
  library(Cairo)
 
  clubs - expression(symbol('\247'))
  hearts - expression(symbol('\250'))
  diamonds - expression(symbol('\251'))
  spades - expression(symbol('\252'))
  csymbols - c(clubs, diamonds, hearts, spades)
 
  CairoPDF(file = cardsymbols.pdf)
 
  plot( 0, xlim=c(0,5), ylim=c(0,2), type=n )
  clr - c(black, red, red, black)
  for (i in 1:4) {
hline - function( yloc, ... ) for (i in 1:length(yloc)) lines(
  c(-1,6), c(yloc[i],yloc[i]), col=gray)
hline(0.9);  hline(1.0);   hline(1.1);   hline(1.2)
text( i, 1, csymbols[i], col=clr[i], cex=5 )
text( i, 0.5, csymbols[i], col=clr[i] )
  }
 
  dev.off()
 
 
 
  
  Ivo Welch (ivo.we...@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.
 
  --
  %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
   Dr. Gavin Simpson [t] +44 (0)20 7679 0522
   ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
   Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
   Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
   UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
  %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 
 

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

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

Re: [R] Problems installing SJava

2011-08-17 Thread Uwe Ligges



On 17.08.2011 16:27, Luis Felipe Parra wrote:

Uggs, as I understand rJava is for calling Java from within R and what I
need is to call R within Java. Am I wrong?


Partly: rJava contains JRI these days, see:
http://www.rforge.net/rJava/

Uwe Ligges



2011/8/17 Uwe Liggeslig...@statistik.tu-dortmund.de


Are you sure rJava is not fine for you?

Uwe Ligges


On 16.08.2011 17:16, Luis Felipe Parra wrote:


Hello, I am trying to install SJava but I haven't been able to complete it
successfully. I have tried to install it from bioconductor using the
followin code and got the following output:

  
source(http://www.**bioconductor.org/biocLite.Rhttp://www.bioconductor.org/biocLite.R

)


BioC_mirror = http://bioconductor.org
Change using chooseBioCmirror().


 biocLite(SJava)


Using R version 2.12.2, biocinstall version 2.7.7.
Installing Bioconductor version 2.7 packages:
[1] SJava
Please wait...

Installing package(s) into ‘C:\Users\Hp\Documents/R/win-**library/2.12’
(as ‘lib’ is unspecified)
Mensajes de aviso perdidos
In getDependencies(pkgs, dependencies, available, lib) :
   package ‘SJava’ is not available


And I have also tried the instructions: found in
http://www.omegahat.org/**RSJava/http://www.omegahat.org/RSJava/.

cd *$RHOME*/src/library
unzip SJava_0.69-0.zip
cd SJava
./configure.win $RHOME
cd *$RHOME*/src/gnuwin32
make pkg-SJava

But when I tried the line unzip SJava_0.69-0.zip it tells me the command
cannot be recognized. If I unzip the file manually and then try the
line ./configure.win
$RHOME I get . ccannot be recognized. Does somebody know what might I be
doing wrong. Or which is an easier way to install this package?

My computer is on Window 7 professional (32 bits)

Thank you

Felipe Parra

[[alternative HTML version deleted]]




__**
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/**
posting-guide.htmlhttp://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.


__
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] Getting vastly different results when running GLMs

2011-08-17 Thread Luke Duncan
Dear R gurus

I am analysing data from a study of behaviour and shade utilization of
chimpanzees. I am using GLMs in R (version 2.13.0) to test whether shade/sun
utilization is predicted by behaviour observed. I am thus interested in
whether an interaction of behaviour (as a predictor) and presence in the
sun/shade (also predictor) predicts the counts I have for the respective
categories.

I have my data organised as such:

 behaviour location specific total  Travel Sun 131 303  Travel Shade 172 303
Foraging Sun 248 651  Foraging Shade 403 651  Vigilance Sun 97 224
Vigilance Shade 127 224  Rest Sun 502 1143  Rest Shade 641 1143  Abnormal
Sun 33 58  Abnormal Shade 25 58  Play Sun 58 173  Play Shade 115 173
SelfGrooming Sun 183 595  SelfGrooming Shade 412 595  SocialGrooming Sun 59
358  SocialGrooming Shade 299 358  Other Sun 4 39  Other Shade 35 39  Hidden
Sun 120 656  Hidden Shade 536 656

I have coded the response variable as a specific count of the times
individuals were in the sun or shade, for each behaviour, out of a total
number of times a specific behaviour was observed (regardless of location
[sun/shade]). These are represented by the columns 'specific' and 'total'
respectively. I had originally coded these values as a proportion variable,
but had similar mismatch problems between R and Statistica (as described
below). The GLM I am running is a binomial one (as my count response
variables are divided dichotomously by the sun/shade predictor variable)
with a logit link function. My problem is this: I originally ran the data
through another stats program (Statistica) and got significant effects for
all first- and second-order effects. When I examined the raw data, the
patterns seen in the raw data suggested that these outcomes (of the GLM)
conformed to the raw data (i.e. confirmed the GLM results). I then ran the *
same* data through R using the following code:

 behdata-read.csv(behaviourshade.csv,header=TRUE)
 behdata #Just to check that everything is there and working...
 behav-behdata$behaviour
 loc-behdata$location
 prop-behdata$proportion
 spec-behdata$specific
 total-behdata$total
 model-glm((cbind(spec,total))~behav*loc,family=binomial,data=behdata)
 summary(model)
Call:
glm(formula = (cbind(spec, total)) ~ behav * loc, family = binomial,
data = behdata)
Deviance Residuals:
 [1]  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
Coefficients:
Estimate Std. Error z value Pr(|z|)
(Intercept)  -0.8416 0.2393  -3.517 0.000436 ***
behavForagingfeeding  0.3620 0.2475   1.463 0.143585
behavHidden   0.6395 0.2462   2.597 0.009396 **
behavOther0.7334 0.3338   2.197 0.028044 *
behavPlay 0.4332 0.2678   1.618 0.105739
behavRest 0.2632 0.2443   1.077 0.281320
behavSelfGrooming 0.4740 0.2477   1.914 0.055644 .
behavSocialGrooming   0.6615 0.2518   2.627 0.008602 **
behavTravel   0.2753 0.2576   1.069 0.285142
behavVigilance0.2741 0.2638   1.039 0.298732
locSun0.2776 0.3237   0.858 0.391077
behavForagingfeeding:locSun  -0.7631 0.3382  -2.257 0.024036 *
behavHidden:locSun   -1.7743 0.3436  -5.164 2.41e-07 ***
behavOther:locSun-2.4467 0.6593  -3.711 0.000206 ***
behavPlay:locSun -0.9621 0.3772  -2.551 0.010752 *
behavRest:locSun -0.5221 0.3318  -1.573 0.115615
behavSelfGrooming:locSun -1.0892 0.3406  -3.197 0.001387 **
behavSocialGrooming:locSun   -1.9005 0.3615  -5.258 1.46e-07 ***
behavTravel:locSun   -0.5499 0.3533  -1.556 0.119597
behavVigilance:locSun-0.5471 0.3632  -1.506 0.131952
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance:  4.5553e+02  on 19  degrees of freedom
Residual deviance: -1.3700e-13  on  0  degrees of freedom
  (19 observations deleted due to missingness)
AIC: 165.12
Number of Fisher Scoring iterations: 3
When I ran it through R I got VERY different results. The R GLM suggested
that behaviour and the behaviour*location interactions were significant
predictors of the counts but the location (sun/shade) was not. In addition,
within each factor, where differences lay were very different between tests.
While I understand that it is entirely possible to have significant 2nd
order interactions when 1st order effects may not be significant, these
patterns described seem to defy apparently obvious patterns in the raw data.

To further complicate things, I was reading through Crawley's R book where
he describes the relationships between orthogonal and non-orthogonal studies
and the order of factor entry; how order can complicate GLM type analyses
for non-orthogonal studies. My data are orthogonal, yet the order in which I
enter variables into the 

[R] questions about metafor package

2011-08-17 Thread Emilie MAILLARD
Hello,
 
I would like to do a meta-analysis with the package « metafor ». Ideally I 
would like to use a mixed model because I’m interested to see the effect of 
some moderators. But the data set I managed to collect from literature presents 
two limits. 
 
-         Firstly, for each observation, I have means for a treatment 
and for a control, but I don’t always have corresponding standard deviations 
(52 of a total of 93 observations don’t have standard deviations). 
Nevertheless I have the sample sizes for all observations so I wonder if it was 
possible to weight observations by sample size in the package « metafor ».
-         Secondly, some observations are probably not independent as I 
have sometimes several relevant observations for a same design. More precisely, 
for these cases, the control mean is identical but treatment means varied. 
Ideally, I would not like to do a weighted average for these non-independent 
observations because these observations represent levels of a moderator. I know 
that the package « metafor » is not designed for the analysis of correlated 
outcomes. What are the dangers of using the package even if observations are 
not really independent ?  
 
Thank you for your help,
 
Émilie.
[[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] Selecting section of matrix

2011-08-17 Thread mdvaan
That worked great, thanks! Now that I have created list h (see below), I
would like to use the selections made in h to make new selections in list c
(see below). List c needs to get the exact same shape as h, so that `8026`in
1997 (c$`1997`$`8026`) looks like this: 

$`1997`$`8026`
  B
B  8025 8026 8029
  8025   1.000 0.7739527 0.9656091
  8026   0.7739527 1.000 0.7202771
  8029   0.9656091 0.7202771 1.000

Thank you very much for your help!

library(zoo) 

DF1 = data.frame(read.table(textConnection(B  C  D  E  F  G 
8025  1995  0  4  1  2 
8025  1997  1  1  3  4 
8026  1995  0  7  0  0 
8026  1996  1  2  3  0 
8026  1997  1  2  3  1 
8026  1998  6  0  0  4 
8026  1999  3  7  0  3 
8027  1997  1  2  3  9 
8027  1998  1  2  3  1 
8027  1999  6  0  0  2 
8028  1999  3  7  0  0 
8029  1995  0  2  3  3 
8029  1998  1  2  3  2 
8029  1999  6  0  0  1),head=TRUE,stringsAsFactors=FALSE)) 
 
a - read.zoo(DF1, split = 1, index = 2, FUN = identity) 
sum.na - function(x) if (any(!is.na(x))) sum(x, na.rm = TRUE) else NA 
b - rollapply(a, 3,  sum.na, align = right, partial = TRUE) 
newDF - lapply(1:nrow(b), function(i) 
  prop.table(na.omit(matrix(b[i,], nc = 4, byrow = TRUE, 
dimnames = list(unique(DF1$B), names(DF1)[-1:-2]))), 1)) 
names(newDF) - time(a) 
c-lapply(newDF, function(mat) tcrossprod(mat / sqrt(rowSums(mat^2 

DF2 = data.frame(read.table(textConnection(  A  B  C
80  8025  1995
80  8026  1995
80  8029  1995
81  8026  1996
82  8025  1997
82  8026  1997
83  8025  1997
83  8027  1997
90  8026  1998
90  8027  1998
90  8029  1998
84  8026  1999
84  8027  1999
85  8028  1999
85  8029  1999),head=TRUE,stringsAsFactors=FALSE))
 
e - function(y) crossprod(table(DF2[DF2$C %in% y, 1:2]))
years - sort(unique(DF2$C))
f - as.data.frame(embed(years, 3))
g-lapply(split(f, f[, 1]), e)
h-lapply(g, function (x) ifelse(x0,1,0))

years-c(1997:1999)
for (t in 1:length(years))
{
year=as.character(years[t])
h[[year]]-sapply(colnames(h[[year]]), function(var)
h[[year]][h[[year]][,var]0, h[[year]][var,]0])
}


David Winsemius wrote:
 
 On Aug 15, 2011, at 6:09 AM, mdvaan wrote:
 
 Hi,

 I have a question concerning the selection of data. Let's say that  
 given
 list h created below, I would like to select a section of the 1999  
 matrix.
 For a case (rownames and colnames) I would like to select the cells  
 that
 have a value  0. So for case 8025

   8025 8026 8027
 8025111
 8026111
 8027111

   tst - h$`1999`
   tst[tst[,8025]0, tst[8025,]0]
B
 B  8025 8026 8027
8025111
8026111
8027111
 
 

 And for case 8028

   8028 8029
 802811
 802911
 
   tst[tst[,8028]0, tst[8028,]0]
B
 B  8028 8029
802811
802911
 
 And to do it programmatically:
 
 sapply( colnames(tst), function(var) tst[tst[,var]0, tst[var,]0])
 
 -- 
 David.



 DF2 = data.frame(read.table(textConnection(  A  B  C
 80  8025  1995
 80  8026  1995
 80  8029  1995
 81  8026  1996
 82  8025  1997
 82  8026  1997
 83  8025  1997
 83  8027  1997
 90  8026  1998
 90  8027  1998
 90  8029  1998
 84  8026  1999
 84  8027  1999
 85  8028  1999
 85  8029  1999),head=TRUE,stringsAsFactors=FALSE))

 e - function(y) crossprod(table(DF2[DF2$C %in% y, 1:2]))
 years - sort(unique(DF2$C))
 f - as.data.frame(embed(years, 3))
 g-lapply(split(f, f[, 1]), e)
 h-lapply(g, function (x) ifelse(x0,1,0))# These are the adjacency  
 matrices
 per year
 h

 Thanks very much!

 --
 View this message in context:
 http://r.789695.n4.nabble.com/Selecting-section-of-matrix-tp3744570p3744570.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.
 
 David Winsemius, MD
 Heritage Laboratories
 West Hartford, CT
 
 __
 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.
 


--
View this message in context: 
http://r.789695.n4.nabble.com/Selecting-section-of-matrix-tp3744570p3750246.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.


[R] Fatal Error after install of R 2.13.1

2011-08-17 Thread tcentofanti
I tried to install R 2.13.1 this morning on a Windows XP SP3 machine. I have
the 2 previous versions of R running flawlessly. However when I try to open
R from my Programs, I get an error and then R crashes. I've seen a few posts
with this error but none of the fixes work (rename .RDATA, run as
--no-restore). I did the uninstall/reinstall also.

Any suggestions as to a solution?

Error:  Fatal Error: unable to restore saved data in .RDATA

--
View this message in context: 
http://r.789695.n4.nabble.com/Fatal-Error-after-install-of-R-2-13-1-tp3750279p3750279.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.


[R] Using require() vs. library()

2011-08-17 Thread Nordlund, Dan (DSHS/RDA)
A recent post prompts me to ask this question.  Is there any reason to prefer 
using library() over require()?  I tend to use require() instead of library() 
to load packages, but I wonder if there are situations where it would be better 
to use library().  

Enquiring minds would like to know,

Dan

Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA 98504-5204

__
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] trouble installing packages on OpenSuse 11.4

2011-08-17 Thread Dinesh
Thanks for the idea Rolf, it helped me isolate the cause. FWIW I still 
wanted to get the automatic dependencies check that install.packages() 
provides - an incredibly powerful incentive.

I found the following workaround to be effective for me.

repos = getOptions(repos)
repos[CRAN] = http://cran.r-project.org;;
#and then install each package one by one, just to figure out any 
external dependencies:
install.packages( x, repo=repos)

It turns out I had to install both gcc and fortran, but using zypper 
that was easy.

Regards
Dinesh

On 8/17/2011 3:08 AM, Rolf Turner wrote:

 I don't know from OpenSuse, but your R CMD INSTALL syntax doesn't
 look right to me.  It certainly wouldn't be right under Ubuntu.

 What I would do under Ubuntu is:

 * download the package from CRAN; this is in the form of a gzipped
 tar file ``fImport_2110.79.tar.gz''.

 * R CMD INSTALL fImport_2110.79.tar.gz -l Rlib

 where Rlib is the name of the directory where I keep my personal
 library of R packages.  (So there is no ``sudo'' required.)

 This doesn't actually work; it squawks about needing the timeDate and
 timeSeries packages --- which I don't have.  So you need to download
 the source for these:  timeDate_2130.93.tar.gz and  
 timeSeries_2130.92.tar.gz.

 Then do the R CMD INSTALL bizzo for these two.  You need to do 
 timeDate first.

 There appears to be no compiling of code involved, so you don't need 
 gcc --- yet.
 But you undoubtedly will very soon, so you might as well get it 
 installed.

 HTH.

 cheers,

 Rolf Turner

 On 17/08/11 06:38, Dinesh wrote:
 Hi,

 I am trying to install a bunch of packages via command line and can use
 some help in getting it right. My env is a freshly setup OpenSuse 11.4
 on an amd desktop. I have not yet installed gcc (Will I need gcc to
 install packages? I have installed make, assuming R might need it.). I
 have tried it both under R2.12 and R2.13. I have a list of packages to
 install such as fImport, fGarch, zoo, and several more. I am logged in
 as root because I want the packages to be visible to all users

 a) R CMD INSTALL fImport
 This produces no results.

 b) sudo R CMD INSTALL fImport
 This downloads timeDate and gets stuck there. (I did sudo based on my
 experience on Win7 where I had to start R as administrator to update the
 common package library regardless of how I was logged in.)

 c) R
 then,
 install.packages( fImport, repo=|http://cran.r-project.org; );
 If I executed via command R then it furnishes a listbox of mirrors, I
 select a mirror and then it hangs. If I executed via command sudo R
 then it furnishes a 24x80 style (not tk) list of choices, I select a
 mirror and then it hangs.

 I will appreciate your help in figuring this out. Ideally,  I would
 ideally to run R CMD INSTALL or R CMD BATCH with a short command file so
 that I can configure a new machine via a script.

 I also tried to download the tarballs - but then figuring out all the
 dependencies gets very messy. Besides, that would be, like, reinventing
 the wheel!

 |--


-- 

Regards,
Dinesh K. Somani
--
/Improving Your Odds/


[[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] Using require() vs. library()

2011-08-17 Thread Ista Zahn
Hi Dan,
Is there something you would like to know that is not covered by help(library) ?

Best,
Ista

On Wed, Aug 17, 2011 at 12:40 PM, Nordlund, Dan (DSHS/RDA)
nord...@dshs.wa.gov wrote:
 A recent post prompts me to ask this question.  Is there any reason to prefer 
 using library() over require()?  I tend to use require() instead of library() 
 to load packages, but I wonder if there are situations where it would be 
 better to use library().

 Enquiring minds would like to know,

 Dan

 Daniel J. Nordlund
 Washington State Department of Social and Health Services
 Planning, Performance, and Accountability
 Research and Data Analysis Division
 Olympia, WA 98504-5204

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




-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org

__
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] questions about metafor package

2011-08-17 Thread Viechtbauer Wolfgang (STAT)
Dear Emilie,

Regarding your questions:

1) It's not the weighting that is the main issue when you do not have the SDs. 
The problem is that you need the SDs to calculate the sampling variances of the 
mean differences (I assume that this is your outcome measure for the 
meta-analysis). Those are needed to calculate the standard errors of the model 
coefficients.

There are two possible routes to take. The first would be to try your hardest 
to get your hands on as many of the missing SDs as possible. Whatever is left 
missing could be imputed, using a sensible range of values and checking for the 
robustness of the findings.

The other approach would be to choose some other weights (e.g., sample size 
weights), then fit the model by WLS, and then estimate the standard errors of 
the model coefficients using a robust method (e.g., using a sandwich 
estimator).

2) Difficult to say. I haven’t had a chance to read this article, but this will 
probably tell you more:

Ishak, K. J., Platt, R. W., Joseph, L.,  Hanley, J. A. (2008). Impact of 
approximating or ignoring within-study covariances in multivariate 
meta-analyses. Statistics in Medicine, 27(5), 670-686.

Best,

-- 
Wolfgang Viechtbauer 
Department of Psychiatry and Neuropsychology 
School for Mental Health and Neuroscience 
Maastricht University, P.O. Box 616 
6200 MD Maastricht, The Netherlands 
Tel: +31 (43) 368-5248 
Fax: +31 (43) 368-8689 
Web: http://www.wvbauer.com 


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Emilie MAILLARD
 Sent: Wednesday, August 17, 2011 17:21
 To: r-help@r-project.org
 Subject: [R] questions about metafor package
 
 Hello,
 
 I would like to do a meta-analysis with the package « metafor ». Ideally I
 would like to use a mixed model because I’m interested to see the effect
 of some moderators. But the data set I managed to collect from literature
 presents two limits.
 
 - Firstly, for each observation, I have means for a treatment and
 for a control, but I don’t always have corresponding standard deviations
 (52 of a total of 93 observations don’t have standard deviations).
 Nevertheless I have the sample sizes for all observations so I wonder if
 it was possible to weight observations by sample size in the package
 « metafor ».
 - Secondly, some observations are probably not independent as I
 have sometimes several relevant observations for a same design. More
 precisely, for these cases, the control mean is identical but treatment
 means varied. Ideally, I would not like to do a weighted average for these
 non-independent observations because these observations represent levels
 of a moderator. I know that the package « metafor » is not designed for
 the analysis of correlated outcomes. What are the dangers of using the
 package even if observations are not really independent ?
 
 Thank you for your help,
 
 Émilie.

__
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] questions about metafor package

2011-08-17 Thread Jeremy Miles
.

 - Firstly, for each observation, I have means for a treatment and for 
 a control, but I don’t always have corresponding standard deviations (52 of a 
 total of 93 observations don’t have standard deviations). Nevertheless I have 
 the sample sizes for all observations so I wonder if it was possible to 
 weight observations by sample size in the package « metafor ».

Following what Wolfgang said, do you have some other information, such
as p-values, or standard errors of the difference, or confidence
intervals, which would allow you to calculate (or approximate) the
pooled SD?

jeremy

__
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] question regarding headers with space in the names

2011-08-17 Thread Jack Luo
Hi,

After I read an xlsx file into the work space:
A - read.xlsx(B.xls, header = T, check.names = F)
There are several headers with the names like:
colnames(A) [1:4]
# [1] A 1B
 [3] C 2  D
I can get the content of column 2 and column 4 easily by
A$B or A$D

However, I can not type something like
A$A 1 (cause there is a space in between)

Obviously, you can get around this by using something like
A[,colnames(A) == A 1]
The other way to get around is to read it by using check.names = T
A - read.xlsx(B.xls, header = T, check.names = T)
and type something like
A$A.1

But I am wondering if I stick using check.names = F, if there is anything
that is as easy as
A$A 1
that works.

Thanks,

-Jack

[[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] Using require() vs. library()

2011-08-17 Thread Nordlund, Dan (DSHS/RDA)
 -Original Message-
 From: istaz...@gmail.com [mailto:istaz...@gmail.com] On Behalf Of Ista
 Zahn
 Sent: Wednesday, August 17, 2011 10:12 AM
 To: Nordlund, Dan (DSHS/RDA)
 Cc: r-help@r-project.org
 Subject: Re: [R] Using require() vs. library()
 
 Hi Dan,
 Is there something you would like to know that is not covered by
 help(library) ?
 
 Best,
 Ista
 
 On Wed, Aug 17, 2011 at 12:40 PM, Nordlund, Dan (DSHS/RDA)
 nord...@dshs.wa.gov wrote:
  A recent post prompts me to ask this question.  Is there any reason
 to prefer using library() over require()?  I tend to use require()
 instead of library() to load packages, but I wonder if there are
 situations where it would be better to use library().
 

Well, I guess when I read that require is designed for use inside other 
functions... I wasn't sure if that meant there might be times when it would be 
better to use library when not inside other functions.  But maybe it was more 
generally a question about style, prompted by a post responding to the common 
confusion between the terms 'package' and 'library' amongst those new to R.  To 
me, it always seemed more natural type require(my.package) than 
library(my.package).  I just wanted to make sure I wasn't missing something 
that might make me regret that choice.

Dan  

Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA 98504-5204


__
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] question regarding headers with space in the names

2011-08-17 Thread Ista Zahn
Hi Jack,
You need to quote non-syntactic names.

A$`A 1`
A$'A 1'
A$A 1

should all work, with the first form being the recommended one.

Best,
Ista


On Wed, Aug 17, 2011 at 1:45 PM, Jack Luo jluo.rh...@gmail.com wrote:
 Hi,

 After I read an xlsx file into the work space:
 A - read.xlsx(B.xls, header = T, check.names = F)
 There are several headers with the names like:
 colnames(A) [1:4]
 # [1] A 1                        B
  [3] C 2                          D
 I can get the content of column 2 and column 4 easily by
 A$B or A$D

 However, I can not type something like
 A$A 1 (cause there is a space in between)

 Obviously, you can get around this by using something like
 A[,colnames(A) == A 1]
 The other way to get around is to read it by using check.names = T
 A - read.xlsx(B.xls, header = T, check.names = T)
 and type something like
 A$A.1

 But I am wondering if I stick using check.names = F, if there is anything
 that is as easy as
 A$A 1
 that works.

 Thanks,

 -Jack

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




-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org

__
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] interpreting interactions in a model

2011-08-17 Thread Dennis Murphy
Hi:

On Wed, Aug 17, 2011 at 1:56 AM, gaiarrido gaiarr...@usal.es wrote:
 Hi,
 I´ve got this model
 model-glm(prevalence~agesex+agesex:month,binomial)

 and the output of anova is like that

 anova(model,test=Chisq)
                          Df Deviance Resid. Df Resid. Dev P(|Chi|)
 NULL                            524     206.97
 agesex                 2   9.9165       522     197.05  0.007025 **
 agesex:month        9  18.0899       513     178.96  0.034145 *

Where is the month main effect? Even if it's 'not significant', it
belongs in the model (principle of marginality).

 I don´t know how to interpret the interaction agesex:month, my mind doubt
 between 2 options:
 a) For a giving group of agesex there are differences between months
 b)There are differences between groups of agesex in some months but not in
 others.

 Which option is correct?

In the absence of a reproducible example, no one can say, but it's
within the realm of possibility that either or both could be correct.
The significance test for interaction indicates *whether* an
interaction effect exists - it doesn't tell you *what type* of
interaction exists. Conditional on the inference that an interaction
effect is present, the next step of the analysis is to investigate the
nature of the interaction. This could involve planned contrasts,
multiple comparisons, graphics, etc. The car, effects, multcomp and HH
packages can be useful for these types of investigations.

HTH,
Dennis

 Thanks very much

 -
 Mario Garrido Escudero
 PhD student
 Dpto. de Biología Animal, Ecología, Parasitología, Edafología y Qca. Agrícola
 Universidad de Salamanca
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/interpreting-interactions-in-a-model-tp3749430p3749430.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.


__
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 test on data frame

2011-08-17 Thread R. Michael Weylandt
I think everything below is right, but it's all a little helter-skelter so
take it with a grain of salt:

First things first, make your data with dput() for the list.

Y = structure(c(0, 35, 0, 0, 0, 0, 84, 84, 0, 48, 84, 0, 22, 0, 0,
0, 0, 0, 10, 0, 48, 0, 0, 48, 0, 22, 0, 0, 0, 0, 84, 84, 0, 48,
84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 48, 0, 0, 48), .Dim = c(6L, 8L
), .Dimnames = list(c(1, 2, 3, 4, 5, 6), c(V1,
V2, V3, V4, W1, W2, W3, W4)))

Now,

Y1 = Y[,1:4]
Y2 = Y[,-(1:4)]

id = apply(Y1,1,order,decreasing=T)[1:2,]
# This has the columns you want in each row, but it's not directly
appropriate for subsetting
# Specifically, the problem is that the row information is implicit in where
the col index is in id
# We directly extract and force into a 2-col vector that gives rows and
columns for each data point
id = cbind(as.vector(col(id)),as.vector(id))

Now you can take

Y1[id] as the observed values and Y2[id] as the expected.

But, to be honest, it sounds like you have more problems in using a chi-sq
test than anything else. Beyond all the zeros, you should note that you
always have #obs = #expected because Y1= Y2. I'll leave that up to you
though.

Hope this helps and please make sure you can take my code apart piece by
piece to understand it: there's some odd data manipulation that takes
advantage of R's way of coercing matrices to vectors and if your actual data
isn't like the provided example, you may have to modify.

Michael Weylandt

On Wed, Aug 17, 2011 at 10:26 AM, Bansal, Vikas vikas.ban...@kcl.ac.ukwrote:

 Is there anyone who can help me with chi square test on data frame.I am
 struggling from last 2 days.I will be very  thankful to you.

 Dear all,

 I have been working on this problem from so many hours but did not find any
 solution.
 I have a data frame with 8 columns-
   V1   V2   V3   V4  W1   W2W3   W4
 1 084   22   10   0  84  0  0
 2358400 22  84  0  0
 3 0 0  0  48   0   00 48
 4 04800   0  48   0  0
 5 08400   0  84   0  0
 6 0 00   48   0   00 48

 from first four columns, for each row I have to take two largest values.
 and these two values will be considered as observed values.And from last
 four column we will get the expected values.So i have to perform chi square
 test for each row to get p values.

 example for first row is-

 first two largest values are 84(in V2) and 22 (in V3).so these are
 considered as observed values.Now if the largest values are in V2 and V3,we
 have to pick expected values from W2 and W3 which are 84 and 0.I know for
 chi square test values should not be 0 but we will ignore the warning.
 Now as we have observed value as well as expected we have to perform chi
 square test to get p values for each row in a new column.


 So far I was working as returning the index for two largest value with-
 sort.int(df,index.return=TRUE)$ix[c(4,3)]
  but it does not accept data frame.

 Can you please give some idea how to do this,because it is very tricky and
 after studying a lot, I am not able to perform.Please help.



 Thanking you,
 Warm Regards
 Vikas Bansal
 Msc Bioinformatics
 Kings College London
 __
 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.


[[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] Using require() vs. library()

2011-08-17 Thread Uwe Ligges
Actually require() is a wrapper around library() with more error 
handling to be used inside other functions. Just type require(), you can 
read the few lines of code quickly.


Uwe Ligges



On 17.08.2011 19:57, Nordlund, Dan (DSHS/RDA) wrote:

-Original Message-
From: istaz...@gmail.com [mailto:istaz...@gmail.com] On Behalf Of Ista
Zahn
Sent: Wednesday, August 17, 2011 10:12 AM
To: Nordlund, Dan (DSHS/RDA)
Cc: r-help@r-project.org
Subject: Re: [R] Using require() vs. library()

Hi Dan,
Is there something you would like to know that is not covered by
help(library) ?

Best,
Ista

On Wed, Aug 17, 2011 at 12:40 PM, Nordlund, Dan (DSHS/RDA)
nord...@dshs.wa.gov  wrote:

A recent post prompts me to ask this question.  Is there any reason

to prefer using library() over require()?  I tend to use require()
instead of library() to load packages, but I wonder if there are
situations where it would be better to use library().



Well, I guess when I read that require is designed for use inside other 
functions... I wasn't sure if that meant there might be times when it would be 
better to use library when not inside other functions.  But maybe it was more generally a 
question about style, prompted by a post responding to the common confusion between the 
terms 'package' and 'library' amongst those new to R.  To me, it always seemed more 
natural type require(my.package) than library(my.package).  I just wanted to make sure I 
wasn't missing something that might make me regret that choice.

Dan

Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA 98504-5204


__
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] Fatal Error after install of R 2.13.1

2011-08-17 Thread Uwe Ligges



On 17.08.2011 17:17, tcentofanti wrote:

I tried to install R 2.13.1 this morning on a Windows XP SP3 machine. I have
the 2 previous versions of R running flawlessly. However when I try to open
R from my Programs, I get an error and then R crashes. I've seen a few posts
with this error but none of the fixes work (rename .RDATA, run as
--no-restore). I did the uninstall/reinstall also.

Any suggestions as to a solution?

Error:  Fatal Error: unable to restore saved data in .RDATA


AFter you renamed/deleted your saved workspace (.Rdata), you should be 
able to start. If that does not work: You renamed / deleted ne that was 
not used by your new version of R.


Uwe Ligges




--
View this message in context: 
http://r.789695.n4.nabble.com/Fatal-Error-after-install-of-R-2-13-1-tp3750279p3750279.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.


__
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 require() vs. library()

2011-08-17 Thread Nordlund, Dan (DSHS/RDA)
 -Original Message-
 From: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de]
 Sent: Wednesday, August 17, 2011 11:14 AM
 To: Nordlund, Dan (DSHS/RDA)
 Cc: r-help@r-project.org
 Subject: Re: [R] Using require() vs. library()
 
 Actually require() is a wrapper around library() with more error
 handling to be used inside other functions. Just type require(), you
 can
 read the few lines of code quickly.
 
 Uwe Ligges
 
 
 

Thanks Uwe,

I will do that.

Dan

Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA 98504-5204


__
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] dotchart vs. dotplot ... groups

2011-08-17 Thread mkzodet
I'm trying to create a dotplot with some grouping. 

I've been able to create what I want using dotchart (basic graphics), but can't 
quite get it using dotplot (lattice). I prefer to use lattice (or ggplot2) 
because I think it's a bit easier to control some other aspects of the plot 
appearance. 

Basically, w/ lattice I've not been able to get the y-axis label to include the 
group variable. 

I'd like... 

A 
1 
2 
B 
1 
2 
3 
4 
C 
1 
2 
3 

I'm getting... 
1 
2 
1 
2 
3 
4 
1 
2 
3 

The following example code illustrates 

set.seed(18) 
dta - data.frame(var1=factor(c(A, A, B, B, B, B, C, C, C)), 
var2=c(1,2,1,2,3,4,1,2,3), 
var3=round(runif(9,1,10),1), 
plotorder=9:1) 

dta 

windows(3,3) 
dotchart(dta$var3[order(dta$var1, -dta$var2)], groups=dta$var1, 
labels=dta$var2[order(dta$var1, -dta$var2)], cex=.75, 
gcolor=c(blue, red, dark green), 
col=c(rep(blue,2), rep(red,4), rep(dark green,3)), 
axes=NULL) 


windows(3,3) 
dotplot(data=dta, plotorder~var3, groups=var1, col=c(blue, red, dark 
green), 
scales=list(y=list(labels=dta$var2[order(dta$plotorder)]))) 

Thanks. 

Marc 
R 2.13.0 (2011-04-13) 
Windows XP 


[[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 apply a function to subsets of a data frame *and* obtain a data frame again?

2011-08-17 Thread Dennis Murphy
Hi:

I would agree with Paul Hiemstra about using Hadley's code instead;
see ?plyr:::mutate for details. It would also make sense to sort the
data and edf by group - this does it in one line:

arrange(ddply(df, .(Group), mutate, edf = edf(Value)), Group, edf)

HTH,
Dennis

On Wed, Aug 17, 2011 at 4:51 AM, Marius Hofert m_hof...@web.de wrote:
 Dear all,

 thanks a lot for the quick help.
 Below is what I built with the hint of Nick.

 Cheers,

 Marius


 library(plyr)

 set.seed(1)
 (df - data.frame(Group=rep(c(Group1,Group2,Group3), each=10),
                Value=c(rexp(10, 1), rexp(10, 4), rexp(10, 
 10)))[sample(1:30,30),])
 edf - function(x) ecdf(x)(x)

 ddply(df, .(Group), function(df.) cbind(df., edf=edf(df.$Value)))


 On 2011-08-17, at 13:38 , Hadley Wickham wrote:

 The following example does what you want using ddply:

 library(plyr)
 edfPerGroup = ddply(df, .(Group), summarise, edf = edf(Value), Value =
 Value)

 Or slightly more succinctly:

 ddply(df, .(Group), mutate, edf = edf(Value))

 Hadley

 --
 Assistant Professor / Dobelman Family Junior Chair
 Department of Statistics / Rice University
 http://had.co.nz/

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


[R] Case-by-case tolerance needed for successful integrate()

2011-08-17 Thread Delphine Pessoa
Hello,

We are trying to use R to simulate a model based on some parameters 'a' and
'b'.
This involves the following integration:

model-function(s,x,a,b)(exp(-s*x*10^-5.5)*(s^(a-1)*(1-s)^(b-1)))
g- function(x,a,b){
 out-c()
 for (i in 1:length(x)){
   out[i]-1- (integrate(model,0,1,x[i],a,b)$value / beta(a,b))
 }
 out
 }
x- 10^seq(0,10,by=0.01)
y- g(x,a=0.8,b=0.5)

This gives the error

Error in integrate(model, 0, 1, x[i], a, b) :   the integral is
probably divergent


Changing the relative or absolute tolerance solves this issue, but a certain
tolerance only works with a certain set of 'a' and 'b'.
For example, and abs.tol=10^-9 will make it work with a=0.8 and b=0.5 but
fail with a=0.3 and b=0.9.
We need this code to work for any reasonable value of 'a' and 'b' - as
seen by the shape of the distribution Beta(a,b).

We have tried using a different number of subdivisions without any luck.
The same integration in MATLAB works without any problem (using quad).

Anyone has an idea of why these problems occur and how to avoid them?

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


Re: [R] Chi square test on data frame

2011-08-17 Thread Bansal, Vikas
Dear Michael,

Thanks a lot for your reply and for your help.I was struggling so much but your 
suggestion showed me a path to the solution of my problem.I have tried your 
code on my data frame step wise and it looks fine to me.But when i tried chi 
square test-

res=chisq.test(y1[id],p=y2[id],rescale.p=T)

Chi-squared test for given probabilities

data:  y1[id] 
X-squared = NaN, df = 19997, p-value = NA

Warning message:
In chisq.test(y1[id], p = y2[id], rescale.p = T) :
  Chi-squared approximation may be incorrect

It is not giving p value.Then i checked observed and expected values,it is 
taking all numbers under consideration.but as i mentioned earlier i want p 
value for each row and therefore degree of freedom will be 1. example-

I have a data frame with 8 columns-
  V1   V2   V3   V4  W1   W2W3   W4
1 084   22   10   0  84  0  0
2358400 22  84  0  0
3 0 0  0  48   0   00 48
4 04800   0  48   0  0
5 08400   0  84   0  0
6 0 00   48   0   00 48

example for first row is-

first two largest values are 84(in V2) and 22 (in V3).so these are considered 
as observed values.Now if the largest values are in V2 and V3,we have to pick 
expected values from W2 and W3 which are 84 and 0.I know for chi square test 
values should not be 0 but we will ignore the warning.

now it should generate p value for next row taking 35 and 84 (v1 and v2) as 
observed and 22 and 84 (w1 and w2) as expected.so here it will do chi square 
test for all 6 rows and will generate 6 p values.My data frame has lot of 
rows(approx. ).

Can you please help me with this.



Thanking you,
Warm Regards
Vikas Bansal
Msc Bioinformatics
Kings College London

From: R. Michael Weylandt [michael.weyla...@gmail.com]
Sent: Wednesday, August 17, 2011 7:11 PM
To: Bansal, Vikas
Cc: r-help@r-project.org
Subject: Re: [R] Chi square test on data frame

I think everything below is right, but it's all a little helter-skelter so take 
it with a grain of salt:

First things first, make your data with dput() for the list.

Y = structure(c(0, 35, 0, 0, 0, 0, 84, 84, 0, 48, 84, 0, 22, 0, 0,
0, 0, 0, 10, 0, 48, 0, 0, 48, 0, 22, 0, 0, 0, 0, 84, 84, 0, 48,
84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 48, 0, 0, 48), .Dim = c(6L, 8L
), .Dimnames = list(c(1, 2, 3, 4, 5, 6), c(V1,
V2, V3, V4, W1, W2, W3, W4)))

Now,

Y1 = Y[,1:4]
Y2 = Y[,-(1:4)]

id = apply(Y1,1,order,decreasing=T)[1:2,]
# This has the columns you want in each row, but it's not directly appropriate 
for subsetting
# Specifically, the problem is that the row information is implicit in where 
the col index is in id
# We directly extract and force into a 2-col vector that gives rows and columns 
for each data point
id = cbind(as.vector(col(id)),as.vector(id))

Now you can take

Y1[id] as the observed values and Y2[id] as the expected.

But, to be honest, it sounds like you have more problems in using a chi-sq test 
than anything else. Beyond all the zeros, you should note that you always have 
#obs = #expected because Y1= Y2. I'll leave that up to you though.

Hope this helps and please make sure you can take my code apart piece by piece 
to understand it: there's some odd data manipulation that takes advantage of 
R's way of coercing matrices to vectors and if your actual data isn't like the 
provided example, you may have to modify.

Michael Weylandt

On Wed, Aug 17, 2011 at 10:26 AM, Bansal, Vikas 
vikas.ban...@kcl.ac.ukmailto:vikas.ban...@kcl.ac.uk wrote:
Is there anyone who can help me with chi square test on data frame.I am 
struggling from last 2 days.I will be very  thankful to you.

Dear all,

I have been working on this problem from so many hours but did not find any 
solution.
I have a data frame with 8 columns-
  V1   V2   V3   V4  W1   W2W3   W4
1 084   22   10   0  84  0  0
2358400 22  84  0  0
3 0 0  0  48   0   00 48
4 04800   0  48   0  0
5 08400   0  84   0  0
6 0 00   48   0   00 48

from first four columns, for each row I have to take two largest values. and 
these two values will be considered as observed values.And from last four 
column we will get the expected values.So i have to perform chi square test for 
each row to get p values.

example for first row is-

first two largest values are 84(in V2) and 22 (in V3).so these are considered 
as observed values.Now if the largest values are in V2 and V3,we have to pick 
expected values from 

[R] Obtain beta regression estimation for betareg and VGAM package

2011-08-17 Thread justin bem
Dear all,

I'm trying to estimate beta regression with the betareg package and VGAM package

With the betareg package (Cribari-Neto and Zeilis) I use this code

betareg(formula, data) 


In my mind it possible with VGAM function vglm as 


vglm(formula,betaff, data) 


But betaff have two shapes and all coefficients are doubled in the second 
estimation. Is it possible to obtain the same estimation with the two packages ?

 
Justin BEM
BP 1917 Yaoundé
Tél (237) 76043774

__
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] Re : Obtain beta regression estimation for betareg and VGAM package

2011-08-17 Thread justin bem
I have found the solution 


betareg(formula, data) is equivalent to vglm(formula,betaff(zero=2),data)

Sorry for the previous post.

 
Justin BEM
BP 1917 Yaoundé
Tél (237) 76043774


- Mail original -
De : justin bem justin_...@yahoo.fr
À : R Maillist r-h...@stat.math.ethz.ch
Cc : 
Envoyé le : Mercredi 17 Août 2011 20h30
Objet : [R] Obtain beta regression estimation for betareg and VGAM package

Dear all,

I'm trying to estimate beta regression with the betareg package and VGAM package

With the betareg package (Cribari-Neto and Zeilis) I use this code

betareg(formula, data) 


In my mind it possible with VGAM function vglm as 


vglm(formula,betaff, data) 


But betaff have two shapes and all coefficients are doubled in the second 
estimation. Is it possible to obtain the same estimation with the two packages ?

 
Justin BEM
BP 1917 Yaoundé
Tél (237) 76043774

__
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] vglm regression with weibull distribution

2011-08-17 Thread justin bem
Dear all,

I'm facing a problem in estimation of glm model with weibull distribution. I 
run this :

eqn0-formula(fdh~cup1+cup2+cup3+cup4+fin1+vd1+cm2+cm4+milieu+cpro1+cpro2+cpro3a+cpro3b+schef+log(y))
regWeib0-vglm(eqn0,family=weibull,subset(br, fdh1))

I have en estimation but there is a message saying that regularity conditions 
are violated :

Message d'avis :
In eval(expr, envir, enclos) :
  MLE regularity conditions are violated(shape = 2) at the final iteration


Then I haved try to apply solution provide in help of the package that 
consisted to use lschape=logoff and eschape=list(offset=-2)

regWeib0-vglm(eqn0,family=weibull(lshape='logoff',eshape=list(offset=-2)),subset(br,
 fdh1))


Erreur dans if ((temp - sum(wz[, 1:M, drop = FALSE]  wzepsilon))) 
warning(paste(temp,  : 
  l'argument n'est pas interprétable comme une valeur logique
De plus : Message d'avis :
In log(theta + offset) : production de NaN


Finaly i use the above function to find initial value for shape (a) and scale 
(b) 

weibullPar-function(x){
 f-function(p,mu=mean(x), sig=((length(x)-1)*var(x))/length(x)){
  n-length(x)
  a-p[1]
  b-p[2]
  t1-(mu-b*gamma(1+1/a))^2
  t2-(sig-((b^2)*gamma(1+2/a)-mu^2))^2
  rval-t1+t2
  rval
  }
  optim(c(1,1),f)$par
}

With the founded initial values I have I have the message. But When try great 
initial value for ishape and iscale I have this 


regWeib0-vglm(eqn0,family=weibull(lshape='logoff',lscale='loge',eshape=list(offset=-2),ishape=22,iscale=6),subset(br,
 fdh1))
Messages d'avis :
1: In checkwz(wz, M = M, trace = trace, wzeps = control$wzepsilon) :
  1525 elements replaced by 1.819e-12
2: In checkwz(wz, M = M, trace = trace, wzeps = control$wzepsilon) :
  1525 elements replaced by 1.819e-12
3: In checkwz(wz, M = M, trace = trace, wzeps = control$wzepsilon) :
  1525 elements replaced by 1.819e-12
4: In checkwz(wz, M = M, trace = trace, wzeps = control$wzepsilon) :
  1525 elements replaced by 1.819e-12
5: In checkwz(wz, M = M, trace = trace, wzeps = control$wzepsilon) :
  1525 elements replaced by 1.819e-12
6: In checkwz(wz, M = M, trace = trace, wzeps = control$wzepsilon) :
  1525 elements replaced by 1.819e-12
7: In checkwz(wz, M = M, trace = trace, wzeps = control$wzepsilon) :
  1525 elements replaced by 1.819e-12
8: In checkwz(wz, M = M, trace = trace, wzeps = control$wzepsilon) :
  1525 elements replaced by 1.819e-12
9: In eval(expr, envir, enclos) :
  MLE regularity conditions are violated(shape = 2) at the final iteration


MLE regularity condition are still violated but a solution is find !



Can some one help me ? 



Justin BEM
BP 1917 Yaoundé
Tél (237) 76043774 

__
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] [statEt] Rmpi problem in Eclipse statEt

2011-08-17 Thread m.marcinmichal
Hi, 
I try use  Rmpi package to my compute. In my work I'm using eclipse version
3.6.2 and statEt version 0.10.0 (launch Rterm or RJ). Actually I observed
strange behavior, when I try loading Rmpi directly I don't have any problem
i.e.:

library(Rmpi)
mpi.spawn.Rslaves()

  8 slaves are spawned successfully. 0 failed.
master (rank 0, comm 1) of size 9 is running on: marcin-HP 
slave1 (rank 1, comm 1) of size 9 is running on: marcin-HP 
slave2 (rank 2, comm 1) of size 9 is running on: marcin-HP 
slave3 (rank 3, comm 1) of size 9 is running on: marcin-HP 

mpi.remote.exec(paste(I am,mpi.comm.rank(),of,mpi.comm.size()))

$slave1
[1] I am 1 of 9

$slave2
[1] I am 2 of 9

$slave3
[1] I am 3 of 9

$slave4
[1] I am 4 of 9

$slave5
[1] I am 5 of 9

$slave6
[1] I am 6 of 9

$slave7
[1] I am 7 of 9

$slave8
[1] I am 8 of 9

When I try run this same commands into statEt (launch Rterm or RJ) my
console suspend i.e.:
library(Rmpi)
mpi.spawn.Rslaves()
...
After mpi.spawn.Rslaves() I can't send any comand. Why? What's happen?

Best

Marcin M.

--
View this message in context: 
http://r.789695.n4.nabble.com/statEt-Rmpi-problem-in-Eclipse-statEt-tp3750738p3750738.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.


Re: [R] [statEt] Rmpi problem in Eclipse statEt

2011-08-17 Thread m.marcinmichal
I try loading Rmpi directly I don't have any problem i.e. I loading Rmpi by R
x64 2.12.2 (GUI)

--
View this message in context: 
http://r.789695.n4.nabble.com/statEt-Rmpi-problem-in-Eclipse-statEt-tp3750738p3750743.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.


[R] How to rotate a contour?

2011-08-17 Thread kokavolchkov
Hello!

I have a contour and I need *to rotate* it 180 degrees counterclockwise and
180 degrees around the x-axis.

This is a code. I get all the values from the ncdf file:

A = get.var.ncdf(nc, air, start=c(1,1,1,1), count=c(144,73,1,1))
contour(A)

Thank you!

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-rotate-a-contour-tp3750710p3750710.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.


Re: [R] Obtaining variable's names from a list of variables

2011-08-17 Thread Monsieur Do
Thank you for your answers. Problem solved. Eik's cue to 
all.names(match.call())[-1] was particularly enlightning!

Do
 

 De : Eik Vettorazzi
[mailto:e.vettora...@uke.uni-hamburg.de]
 Envoyé : 17 août 2011 08:46
 À : Monsieur Do
 Cc : r-help@r-project.org
 Objet : Re: [R] Obtaining variable's names
from a list of variables
 
 Hi,
 there is no
direct way, since
 listVar
- list(age,sex)
 creates a
unnamed list, as can be seen by
 names(listVar)
#or
 str(listVar)
 
 You can do
sth like
 listVar
- list(age=age,sex=sex) # or
 listVar2
- list(age,sex)
 names(listVar2)-c(age,sex)
 
 and
afterwards access them using names().
 
 Or you
write your own list function using its call to name the returned object,
 as in
 
 my.list-function(...){
  tmp-list(...)
  names(tmp)-all.names(match.call())[-1]
  tmp
 }
 attach(iris)
 a-my.list(Sepal.Length,Sepal.Width)
 
 hth.
 
 Am
17.08.2011 08:46, schrieb Monsieur Do:
  Say I
have a list of variables,
 
 
listVar - list(age,sex)
 
  I am
looking for a way to either
 
  1-
create a vector c(age,sex) from it, or
  2- get
the names one by one in a for loop such as these
 
  a)  for (i in 1:length(listVar)) rownames(result)[i] - ???
 
  b)  for(i in listVar) print (variable's name)
 
 
  Any
help much appreciated.
      [[alternative HTML version deleted]]
 
 
 
 
 
__
  R-help@r-project.orgmailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE
do read the posting guide
  http://www.R-project.org/posting-guide.html
  and
provide commented, minimal, self-contained, reproducible code.
 
 --
 Eik
Vettorazzi
 Institut
für Medizinische Biometrie und Epidemiologie Universitätsklinikum
 Hamburg-Eppendorf
 
 Martinistr.
52
 20246
Hamburg
 
 T
++49/40/7410-58243
 F
++49/40/7410-57790

__
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] Labelling all variables at once (using Hmisc label)

2011-08-17 Thread Monsieur Do
I did read the help page before posting, but didn't find the direct way... My 
function here works fine. But just for learning purposes, I'd like to be able 
to avoid the loop...

with.labels - function(x, labels=NULL, csvfile=NULL) {
if(!is.null(csvfile)) labels - read.csv(csvfile, sep=\t, header=F, 
stringsAsFactors=F)[,1]
for(i in 1:length(x)) label(x[,i]) - labels[i]
if(length(labels) != length(x)) cat(Warning: data and labels are not of same 
length\n)
return(x)
}

Thanks

 Message: 11
 Date: Tue, 16 Aug 2011 04:22:07 -0700 (PDT)
 From:
Frank Harrell f.harr...@vanderbilt.edu
 To:
r-help@r-project.org
 Subject:
Re: [R] Labelling all variables at once (using Hmisc label)
 Message-ID:
1313493727519-3746928.p...@n4.nabble.com
 Content-Type:
text/plain; charset=UTF-8
 
 Do
require(Hmisc); ?label to see the help file for label.  It will show you
 how to
do this:
  
 Monsieur
Do wrote:
 
I have a dataset and a list of labels. I simply want

  to
apply the labels to the variables, all at once. The only way I was able
  to do
it was using a loop:
 
  for (i in 1:length(data)) label(data[,i]) -data.labels[i]
 
  I'd like to find the non-loop way to do it, using

 
apply or the like... Any help appreciated.
 
 -

 Frank
Harrell
 Department
of Biostatistics, Vanderbilt University
[[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] Convert week value to date

2011-08-17 Thread Folkes, Michael
Hello all,
I'm hoping to convert a decimal value for week of the year back to a date 
object.
Eg:
strptime(paste(2010,1:52,sep= ),format=%Y %W)

I expected (hoped?) this would give me the date for Monday of each week.  
Instead, it's giving me 52 values of today's date.

Where am I erring?
Thanks
Michael

___
Michael Folkes
Salmon Stock Assessment
Canadian Dept. of Fisheries  Oceans 
Pacific Biological Station
3190 Hammond Bay Rd.
Nanaimo, B.C., Canada
V9T-6N7
Ph (250) 756-7264 Fax (250) 756-7053  michael.fol...@dfo-mpo.gc.ca


[[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] Getting vastly different results when running GLMs

2011-08-17 Thread Mark Difford
On Aug 17, 2011; 5:43pm Luke Duncan wrote:

Hi Luke,

The differences you are seeing are almost certainly due to different
contrast codings: Statistica probably uses sum-to-zero contrasts whereas R
uses treatment (Dunnett) contrasts by default. You would be well advised to
consult a local statistician for a deeper understanding.

For some immediate insight do the following:

## Fits your model with different contrasts + a few other things.
##
library(car)
?contrast
?contr.treatment
model1 - glm((cbind(spec,total)) ~ behav * loc, family=binomial,
data=behdata, contrasts=list(behav=contr.treatment,
loc=contr.treatment))
model2 - glm((cbind(spec,total)) ~ behav * loc, family=binomial,
data=behdata, contrasts=list(behav=contr.sum, loc=contr.sum))

summary(model1)
summary(model2)
anova(model1, model2)  ## see: models seem different but are identical

## Type I SS
anova(model1)
anova(model2)

## Type II SS
library(car)
Anova(model1, type=II)
Anova(model2, type=II)

Regards, Mark.

-
Mark Difford (Ph.D.)
Research Associate
Botany Department
Nelson Mandela Metropolitan University
Port Elizabeth, South Africa
--
View this message in context: 
http://r.789695.n4.nabble.com/Getting-vastly-different-results-when-running-GLMs-tp3750496p3751115.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.


[R] prcomp

2011-08-17 Thread Rosario Garcia Gil
Hello

I am trying to run a PCA on the attached file, but I get this error message:

pc-prcomp(data[,-(1:2)],scale=T)$x
Error in svd(x, nu = 0) : infinite or missing values in 'x'

Thanks in advance
/R x y x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14
1 25.49 45.62 125 156 165 130 179 152 82 165 130 155 171 136 128 142
2 25.45 45.64 123 157 165 131 180 153 81 165 129 154 171 136 128 142
3 25.43 45.62 124 156 165 130 179 151 82 164 129 154 171 136 128 145
4 25.42 45.62 124 156 165 131 180 151 82 164 129 154 171 136 128 146
5 25.37 45.64 123 156 164 129 178 150 81 163 130 154 169 136 128 146
6 25.40 45.62 124 156 165 130 179 151 82 153 129 154 170 136 128 145
7 25.47 45.71 124 156 165 130 179 152 82 166 129 155 170 136 129 142
8 25.41 45.71 124 156 164 130 179 152 82 164 129 155 171 136 127 143
9 25.42 45.70 124 156 164 130 179 150 82 165 129 154 171 136 129 146
10 25.35 45.73 123 156 165 130 179 151 81 164 129 154 170 136 127 144
11 25.48 45.69 124 157 164 130 179 153 82 164 129 155 170 136 128 144
12 25.35 45.61 124 156 165 130 179 153 82 165 129 154 170 136 128 143
13 25.37 45.62 125 156 165 130 179 151 83 165 128 154 170 136 128 141
14 25.43 45.67 123 156 165 130 179 151 82 164 129 155 171 136 128 145
15 25.45 45.72 124 156 164 130 179 150 82 163 129 154 170 136 127 143
16 25.43 45.63 123 156 165 130 179 152 81 164 129 155 170 136 128 145
17 25.45 45.62 124 156 165 131 180 152 82 165 129 155 170 136 128 147
18 21.86 45.19 124 156 165 130 179 153 82 165 129 154 169 136 128 144
19 22.03 45.21 124 156 165 129 178 151 82 164 129 155 170 137 128 145
20 21.88 45.21 124 156 165 130 179 152 82 164 129 155 170 136 128 144
21 21.98 45.11 124 156 164 130 179 151 82 165 129 155 171 136 127 143
22 22.04 45.22 124 156 165 129 178 151 82 164 129 154 170 136 127 143
23 21.94 45.20 124 156 164 130 179 150 82 164 129 155 170 136 127 145
24 21.88 45.15 124 156 164 131 180 152 82 165 129 155 170 136 128 144
25 22.01 45.20 127 156 165 131 179 151 84 166 130 155 171 136 129 144
26 21.94 45.14 124 156 164 132 180 151 81 165 130 155 171 136 129 146
27 22.01 45.11 124 156 165 131 179 152 81 165 130 155 171 136 128 145
28 21.95 45.21 125 156 165 131 179 153 82 165 130 155 171 136 128 142
29 21.87 45.17 125 156 165 131 178 151 82 164 129 155 171 136 128 142
30 22.04 45.11 125 156 165 131 179 150 82 165 130 155 171 136 128 144
31 21.90 45.18 125 156 165 132 180 151 82 165 129 155 171 136 129 142
32 21.91 45.21 125 156 165 130 178 153 82 166 129 155 171 136 129 143
33 21.92 45.14 125 156 165 130 178 150 82 164 129 155 171 136 128 144
34 22.05 45.20 125 156 165 131 179 152 82 164 129 155 169 136 127 142
35 21.93 45.19 124 156 165 130 179 151 80 164 128 154 169 136 128 145
36 22.00 45.23 125 156 165 131 179 150 82 165 129 155 170 136 129 145
37 21.87 45.11 125 156 165 131 179 152 82 160 128 155 170 136 127 143
38 23.21 45.53 124 157 164 131 179 151 81 164 129 155 170 136 128 146
39 23.14 45.55 125 156 165 131 179 151 82 165 129 155 170 136 128 144
40 23.17 45.52 156 165 131 179 153 82 166 129 155 169 136 129 143 NA
41 23.32 45.62 125 156 165 130 179 152 81 164 129 155 171 136 128 144
42 23.23 45.56 125 156 165 131 179 151 82 165 129 155 170 136 129 144
43 23.23 45.60 125 156 164 131 179 151 82 164 129 155 169 136 128 144
44 23.33 45.52 125 156 166 132 180 151 82 165 129 155 170 136 128 143
45 23.23 45.55 125 156 165 131 179 150 82 165 129 155 170 136 128 144
46 23.18 45.60 124 156 164 132 180 151 81 165 129 155 170 136 128 146
47 23.25 45.53 124 156 165 131 179 150 81 164 128 154 170 136 128 143
48 23.21 45.63 125 156 164 131 179 152 82 165 129 155 169 136 129 145
49 23.24 45.50 124 156 166 130 179 153 82 164 128 154 171 136 128 144
50 23.26 45.54 124 156 165 130 179 152 82 164 129 154 NA 136 128 144
51 23.26 45.52 124 156 164 130 179 151 82 164 128 154 171 136 128 143
52 23.24 45.63 124 156 164 130 179 152 82 164 128 154 171 136 128 142
53 23.29 45.56 124 156 165 130 179 153 82 163 127 154 171 136 128 144
54 23.16 45.54 123 156 164 130 179 151 81 164 128 154 171 136 128 145
55 23.15 45.60 124 156 165 130 179 150 82 164 129 154 171 136 128 144
56 23.26 45.58 125 156 164 130 179 151 83 164 129 154 171 136 128 143
57 17.78 45.14 123 156 165 130 179 152 83 166 130 154 171 136 130 143
58 17.81 45.19 125 156 165 130 179 152 82 164 129 154 170 136 128 144
59 17.78 45.18 124 156 165 130 179 152 82 164 129 154 171 136 128 144
60 17.80 45.14 124 156 164 130 179 151 82 164 128 154 170 136 128 144
61 17.87 45.18 124 156 NA NA 179 151 82 164 129 154 170 136 128 144
62 17.90 45.12 124 156 166 130 179 152 81 164 129 155 170 135 128 143
63 17.78 45.11 123 156 164 130 179 151 82 164 129 154 170 136 129 143
64 17.79 45.19 124 156 165 130 179 152 82 165 129 154 170 136 128 144
65 17.88 45.21 124 156 165 130 179 153 82 164 128 154 170 136 128 142
66 17.85 45.22 124 156 165 131 180 153 82 163 128 154 170 136 127 145
67 17.92 45.21 124 156 165 130 179 152 82 163 127 154 170 NA 127 143
68 17.81 45.18 124 156 165 130 179 152 82 164 128 154 170 136 128 148

Re: [R] Convert week value to date

2011-08-17 Thread David Winsemius


On Aug 17, 2011, at 4:52 PM, Folkes, Michael wrote:


Hello all,
I'm hoping to convert a decimal value for week of the year back to a  
date object.

Eg:
strptime(paste(2010,1:52,sep= ),format=%Y %W)


Yeah, agree that seems as though it should have been successful. I  
cannot get any of my invocations using %W to work.


 strptime(Sys.Date(), %Y-%m-%d-%W)
[1] NA
 strptime(Sys.Date(), %Y-%m-%d)
[1] 2011-08-17
 strptime(Sys.Date(), %Y-%m-%d %W)
[1] NA

Oh well.

seq.POSIXt(as.POSIXlt(2010-01-01), by=week, length=52)



I expected (hoped?) this would give me the date for Monday of each  
week.  Instead, it's giving me 52 values of today's date.


Where am I erring?
Thanks
Michael



David Winsemius, MD
West Hartford, CT

__
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] contrast package with interactions in gls model

2011-08-17 Thread Marylin Bejarano
Hi!

I try to explain the efffect of (1)  forest where i took samples's soils (*
Lugar*: categorical variable with three levels), (2) nitrogen addition
treatments (*Tra*: categorical variable with two levels) on total carbon
concentration's soil samples (*C: *continue* *variable) during four months
of sampling (*Time:* categorical and ordered variable with four levels).

I fitted the following final model with gls function:

var1-varIdent(form=~ 1| Lugar* factor(Time))
FINAL-gls(C ~  Tra+ Lugar+ Time + Time*Tra + Tra*Lugar, data=datos,
weights=var1, method=REML)

the summary function resulted in this first data's set (I omit correlation's
matrix):

Generalized least squares fit by REML
  Model: C ~ Tra + Lugar + Time + Time * Tra + Tra * Lugar
  Data: datos
   AIC  BIClogLik
  1129.458 1191.982 -540.7291

Variance function:
 Structure: Different standard deviations per stratum
 Formula: ~1 | Lugar * factor(Time)
 Parameter estimates:
Chixchulub*0   Xmatkuil*0Hobonil*0 Chixchulub*2   Xmatkuil*2
 Hobonil*2 Chixchulub*3
   1.0000.77593240.53008110.96405590.8200742
 0.29665450.9553168
  Xmatkuil*3Hobonil*3 Chixchulub*4   Xmatkuil*4Hobonil*4
   1.73502900.34302860.62416580.95739220.4651515

Coefficients:
 Value Std.Errort-value
p-value
(Intercept) 260.48540  16.48991  15.796653  0.
Tra0  -9.38703  23.74893  -0.395261  0.6935
LugarChixchulub   -0.15377  19.60260  -0.007845  0.9938
Lugar Hobonil-173.21354  15.89736 -10.895741  0.
Time2-14.74999  14.55909  -1.013112  0.3135
Time3 14.42177  15.64594   0.921758  0.3589
Time4 14.77803  16.72367   0.883659  0.3790
Tra0:Time2 17.93859  20.78257   0.863156  0.3901
Tra0:Time3-48.77118  22.17628  -2.199250  0.0302
Tra0:Time4-52.63611  23.20192  -2.268610  0.0254
Tra0:LugarChixchulub   74.43956  28.11275   2.647893  0.0094
Tra0:Lugar Hobonil 43.03416  23.32391   1.845066  0.0680

anova function generated this table:

 enom. DF: 100
numDF   F-value p-value
(Intercept) 1 1693.1234  .0001
Tra 15.3225  0.0231
Lugar   2  247.7047  .0001
 Time30.4767  0.6992
Tra:Time36.0531  0.0008
Tra:Lugar   23.5061  0.0338

I want to detetect differences between levels of Tra:Lugar interaction. For
example:

1. Tra0:LugarChixchulub vs Tra1:LugarChixchulub  (between treatment levels
for same forest) or,
2. Tra0:LugarChixchulub vs Tra0:LugarHobonil(for same treatment
among forests levels)

I used function contrast (package contrast) whit following script to probe
the hypotesis 1.:

con-contrast(FINAL, list(Lugar= 'Xmatkuil', Tra=1), list(Lugar='Xmatkuil',
Tra = 0))

but i found this error message:

Error en gendata.default(fit = list(modelStruct = list(varStruct =
c(-0.253689933940456,  :
  not enough factors

I would be grateful if somebody tell me I'm doing wrong with my contrast
function script.

Thanks in advance,


Marylin Bejarano
PHd candidate in Ecology Institute of Mexico's National Autonomous
University

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

2011-08-17 Thread David Winsemius


On Aug 17, 2011, at 5:19 PM, Rosario Garcia Gil wrote:


Hello

I am trying to run a PCA on the attached file, but I get this error  
message:


pc-prcomp(data[,-(1:2)],scale=T)$x
Error in svd(x, nu = 0) : infinite or missing values in 'x'


What part of missing values in 'x' is unclear in that error message?

--
David Winsemius, MD
West Hartford, CT

__
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] contrast package with interactions in gls model

2011-08-17 Thread Frank Harrell
You did not follow the posting guide.  You did not specify which packages you
were using.  It appears that you are mixing the rms package with some other
functions such as gls.  If you want to use rms, use the Gls function instead
of gls, and type ?contrast.rms to see examples of the use of contrast().
Frank

Marylin Bejarano wrote:
 
 Hi!
 
 I try to explain the efffect of (1)  forest where i took samples's soils
 (*
 Lugar*: categorical variable with three levels), (2) nitrogen addition
 treatments (*Tra*: categorical variable with two levels) on total carbon
 concentration's soil samples (*C: *continue* *variable) during four months
 of sampling (*Time:* categorical and ordered variable with four levels).
 
 I fitted the following final model with gls function:
 
 var1-varIdent(form=~ 1| Lugar* factor(Time))
 FINAL-gls(C ~  Tra+ Lugar+ Time + Time*Tra + Tra*Lugar, data=datos,
 weights=var1, method=REML)
 
 the summary function resulted in this first data's set (I omit
 correlation's
 matrix):
 
 Generalized least squares fit by REML
   Model: C ~ Tra + Lugar + Time + Time * Tra + Tra * Lugar
   Data: datos
AIC  BIClogLik
   1129.458 1191.982 -540.7291
 
 Variance function:
  Structure: Different standard deviations per stratum
  Formula: ~1 | Lugar * factor(Time)
  Parameter estimates:
 Chixchulub*0   Xmatkuil*0Hobonil*0 Chixchulub*2   Xmatkuil*2
  Hobonil*2 Chixchulub*3
1.0000.77593240.53008110.96405590.8200742
  0.29665450.9553168
   Xmatkuil*3Hobonil*3 Chixchulub*4   Xmatkuil*4Hobonil*4
1.73502900.34302860.62416580.95739220.4651515
 
 Coefficients:
  Value Std.Error   
 t-value
 p-value
 (Intercept) 260.48540  16.48991  15.796653  0.
 Tra0  -9.38703  23.74893  -0.395261  0.6935
 LugarChixchulub   -0.15377  19.60260  -0.007845  0.9938
 Lugar Hobonil-173.21354  15.89736 -10.895741  0.
 Time2-14.74999  14.55909  -1.013112  0.3135
 Time3 14.42177  15.64594   0.921758  0.3589
 Time4 14.77803  16.72367   0.883659  0.3790
 Tra0:Time2 17.93859  20.78257   0.863156  0.3901
 Tra0:Time3-48.77118  22.17628  -2.199250  0.0302
 Tra0:Time4-52.63611  23.20192  -2.268610  0.0254
 Tra0:LugarChixchulub   74.43956  28.11275   2.647893  0.0094
 Tra0:Lugar Hobonil 43.03416  23.32391   1.845066  0.0680
 
 anova function generated this table:
 
  enom. DF: 100
 numDF   F-value p-value
 (Intercept) 1 1693.1234  .0001
 Tra 15.3225  0.0231
 Lugar   2  247.7047  .0001
  Time30.4767  0.6992
 Tra:Time36.0531  0.0008
 Tra:Lugar   23.5061  0.0338
 
 I want to detetect differences between levels of Tra:Lugar interaction.
 For
 example:
 
 1. Tra0:LugarChixchulub vs Tra1:LugarChixchulub  (between treatment levels
 for same forest) or,
 2. Tra0:LugarChixchulub vs Tra0:LugarHobonil(for same treatment
 among forests levels)
 
 I used function contrast (package contrast) whit following script to probe
 the hypotesis 1.:
 
 con-contrast(FINAL, list(Lugar= 'Xmatkuil', Tra=1),
 list(Lugar='Xmatkuil',
 Tra = 0))
 
 but i found this error message:
 
 Error en gendata.default(fit = list(modelStruct = list(varStruct =
 c(-0.253689933940456,  :
   not enough factors
 
 I would be grateful if somebody tell me I'm doing wrong with my contrast
 function script.
 
 Thanks in advance,
 
 
 Marylin Bejarano
 PHd candidate in Ecology Institute of Mexico's National Autonomous
 University
 
   [[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.
 


-
Frank Harrell
Department of Biostatistics, Vanderbilt University
--
View this message in context: 
http://r.789695.n4.nabble.com/contrast-package-with-interactions-in-gls-model-tp3751255p3751269.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.


Re: [R] Labelling all variables at once (using Hmisc label)

2011-08-17 Thread Frank Harrell
I'm puzzled.  I provided a solution that did not require looping.
Frank

Monsieur Do wrote:
 
 I did read the help page before posting, but didn't find the direct way...
 My function here works fine. But just for learning purposes, I'd like to
 be able to avoid the loop...
 
 with.labels - function(x, labels=NULL, csvfile=NULL) {
 if(!is.null(csvfile)) labels - read.csv(csvfile, sep=\t, header=F,
 stringsAsFactors=F)[,1]
 for(i in 1:length(x)) label(x[,i]) - labels[i]
 if(length(labels) != length(x)) cat(Warning: data and labels are not of
 same length\n)
 return(x)
 }
 
 Thanks
 
 Message: 11
 Date: Tue, 16 Aug 2011 04:22:07 -0700 (PDT)
 From:
 Frank Harrell lt;f.harr...@vanderbilt.edugt;
 To:
 r-help@r-project.org
 Subject:
 Re: [R] Labelling all variables at once (using Hmisc label)
 Message-ID:
 1313493727519-3746928.p...@n4.nabble.com
 Content-Type:
 text/plain; charset=UTF-8
 
 Do
 require(Hmisc); ?label to see the help file for label.  It will show you
 how to
 do this:
  
 Monsieur
 Do wrote:
 
 I have a dataset and a list of labels. I simply want
 
  to
 apply the labels to the variables, all at once. The only way I was able
  to do
 it was using a loop:
 
  for (i in 1:length(data)) label(data[,i]) -data.labels[i]
 
  I'd like to find the non-loop way to do it, using
 
 
 apply or the like... Any help appreciated.
 
 -
 
 Frank
 Harrell
 Department
 of Biostatistics, Vanderbilt University
   [[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.
 


-
Frank Harrell
Department of Biostatistics, Vanderbilt University
--
View this message in context: 
http://r.789695.n4.nabble.com/Labelling-all-variables-at-once-using-Hmisc-label-tp3745660p3751273.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.


Re: [R] prcomp

2011-08-17 Thread David Winsemius


On Aug 17, 2011, at 5:47 PM, David Winsemius wrote:



On Aug 17, 2011, at 5:19 PM, Rosario Garcia Gil wrote:


Hello

I am trying to run a PCA on the attached file, but I get this error  
message:


pc-prcomp(data[,-(1:2)],scale=T)$x
Error in svd(x, nu = 0) : infinite or missing values in 'x'


What part of missing values in 'x' is unclear in that error message?


After looking further at the prcomp defaults I see that na.action  
defaults to na.omit so it may not be the missing data, but rather  
collinearity. Do these plotting and descriptive steps to see that your  
data is extremely clustered:


matplot(dat[,-(1:2)] )
 pairs(dat[-(1:2)])
summary(dat[-(1:2)])

So the effort to invert the data matrix is probably failing due to the  
application of inappropriate data reduction to variables which, though  
nominally numeric, are really categorical, and fairly strangely  
distributed ones at that. Also not this advice in ?prcomp:


Note that scale = TRUE cannot be used if there are zero or constant  
(for center = TRUE) variables. I cpunt four variables that violate  
that restriction. But removing scale=T still does not fix the problem.


--

David Winsemius, MD
West Hartford, CT

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


  1   2   >