[R] survreg and cluster and frailty

2008-01-04 Thread Andrew Beckerman
6  490 5920
1315   64 11 120 56 26077  6  490 5920
1415   57 11 120 56 26077  6  490 5920
1515  100 01 170 43 168   104  7  409 3090
16 8  100 01  80128 65864  8 3360 3520
17 8   29 11  80128 65864  8 3360 3520
1815   29 11  80128 65864  8 3360 3520
1915   36 11  80128 65864  8 3360 3520
20 8  100 01 170 56 152   156  9  350 6040
  div nestide
1  0.6027874   1
2  0.6121574   2
3  0.8094382   3
4  0.7353479   4
5  0.7353479   4
6  0.7353479   4
7  0.7353479   4
8  0.8645524   5
9  0.8645524   5
10 0.8645524   5
11 0.8645524   5
12 0.6458459   6
13 0.6458459   6
14 0.6458459   6
15 0.2722860   7
16 0.8397355   8
17 0.8397355   8
18 0.8397355   8
19 0.8397355   8
20 0.7203888   9

-----
Dr. Andrew Beckerman
Department of Animal and Plant Sciences, University of Sheffield,
Alfred Denny Building, Western Bank, Sheffield S10 2TN, UK
ph +44 (0)114 222 0026; fx +44 (0)114 222 0002
http://www.beckslab.staff.shef.ac.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] Rscript on OSX

2008-01-09 Thread Andrew Beckerman
Ido -

R for OSX generally runs via an application, called R.app, which your  
colleague could find in their applications directory.  It can run  
scripts and has a rather nice script editor associated with it.

You can run R as you would in linux using X11.app, found in  
Applications->Utilities on OSX.  R is not designed to run from  
Terminal.app (actually, terminal does not do graphics well for R).
X11 provides the behaviour that you would be used to in Linux etc.

BTW - there is a R-Mac-help group as well for macintosh specific  
issues - [EMAIL PROTECTED]

Andrew

-
Dr. Andrew Beckerman
Department of Animal and Plant Sciences, University of Sheffield,
Alfred Denny Building, Western Bank, Sheffield S10 2TN, UK
ph +44 (0)114 222 0026; fx +44 (0)114 222 0002
http://www.beckslab.staff.shef.ac.uk/
--


On 9 Jan 2008, at 13:22, Ido M. Tamir wrote:

> Hi,
>
> I directed somebody to install R (2.6.1) on his OSX computer,
> following instructions from http://cran.r-project.org/bin/macosx.
> She can run R from the console.
> But plot(1:10) doesn't produce any output or open a window (as I am
> used to from linux).
>
> More importantly:
> Rscript is not in the path (minor problem ln -s is hopefully  
> doable). I tried
> to put a hardcoded path to Rscript into the shebang line but this  
> fails. And
> when I try to invoke it directly:
>
>> -bash: ./Rscript: cannot execute binary file
>
> On linux this works.
>
> I would like to send her some Rscripts, but how can we make them
> run on her system?
>
>
>
> thank you very much,
> ido
>
>
>
> imaclab3:/Library/Frameworks/R.framework/Resources/bin ru$ ls -l
>
> total 1008
> -rwxrwxr-x   1 root  admin1654 Nov 26 17:36 BATCH
> -rwxrwxr-x   1 root  admin2188 Nov 26 17:36 COMPILE
> -rwxrwxr-x   1 root  admin   34391 Nov 26 17:36 INSTALL
> -rwxrwxr-x   1 root  admin1593 Nov 26 17:36 LINK
> -rwxrwxr-x   1 root  admin7210 Nov 26 17:37 R
> -rwxrwxr-x   1 root  admin7210 Nov 26 17:37 R.orig
> -rw-rw-r--   1 root  admin 655 Nov 26 17:37 R.rej
> -rwxrwxr-x   1 root  admin2244 Nov 26 17:36 REMOVE
> -rwxrwxr-x   1 root  admin 928 Nov 26 17:36 Rcmd
> -rwxrwxr-x   1 root  admin9523 Nov 26 17:36 Rd2dvi
> -rwxrwxr-x   1 root  admin 842 Nov 26 17:36 Rd2txt
> -rwxrwxr-x   1 root  admin3237 Nov 26 17:36 Rdconv
> -rwxrwxr-x   1 root  admin1320 Nov 26 17:36 Rdiff
> -rwxrwxr-x   1 root  admin2854 Nov 26 17:36 Rprof
> -rwxrwxr-x   1 root  admin   18084 Nov 26 17:36 Rscript
> -rwxrwxr-x   1 root  admin4656 Nov 26 17:36 SHLIB
> -rwxrwxr-x   1 root  admin   16129 Nov 26 17:36 Sd2Rd
> -rwxrwxr-x   1 root  admin 730 Nov 26 17:36 Stangle
> -rwxrwxr-x   1 root  admin 726 Nov 26 17:36 Sweave
> -rwxrwxr-x   1 root  admin   21715 Nov 26 17:36 build
> -rwxrwxr-x   1 root  admin   78570 Nov 26 17:36 check
> -rwxrwxr-x   1 root  admin6927 Nov 26 17:36 config
> drwxrwxr-x   4 root  admin 136 Nov 26 17:36 exec
> -rwxrwxr-x   1 root  admin3613 Nov 26 17:36 f77_f2c
> -rwxrwxr-x   1 root  admin   10720 Nov 26 17:36 javareconf
> -rwxrwxr-x   1 root  admin  215101 Nov 26 17:36 libtool
> -rwxrwxr-x   1 root  admin3495 Nov 26 17:36 mkinstalldirs
> -rwxrwxr-x   1 root  admin 413 Nov 26 17:36 pager
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Omnibus main effects in summary.lme?

2008-01-10 Thread Andrew Beckerman
Adam -

Without resorting to the rather rich lmer/lme4 discussion realm, you  
need to base anova() comparisons of lme models with different fixed  
effects on maximum liklihood estimates rather tham REML.

anova(update(l2,method="ML"),update(l2,~.-useful:nusience,method="ML"))

should avoid the error and give a conservative estimate of the  
significance of your interaction.

see also:
http://tolstoy.newcastle.edu.au/R/e2/help/06/10/3565.html

and related posts.

A

-----
Dr. Andrew Beckerman
Department of Animal and Plant Sciences, University of Sheffield,
Alfred Denny Building, Western Bank, Sheffield S10 2TN, UK
ph +44 (0)114 222 0026; fx +44 (0)114 222 0002
http://www.beckslab.staff.shef.ac.uk/
--


On 10 Jan 2008, at 22:32, Adam D. I. Kramer wrote:

> Hello,
>
>   I've been running some HLMs using the lme function quite happily; it
> does what I want and I'm pretty sure I understand it.
>
>   The issue is that I'm currently trying to estimate a model with a
> 14-level "nusiance" factor as an independent variable...which makes  
> the
> output quite ugly. All I'm really interested in is the question of  
> whether
> these factor as a whole (and its interactions with other factors) are
> significant.
>
>   The summary.aov function provides this sort of aggregation for lm
> objects, but does not run on lme objects. I've also tried estimating  
> the
> full model and restricted model, leaving out a main effect or  
> interaction
> term and then using anova.lme to compare the models, but these  
> models appear
> to be being fit differently. Say I have l2, and then
>
> l3 <- update(l2, .~.-useful:nusience)
> anova.lme(l3,l2)
>
> ...to see whether the interaction term is significant, produces the  
> error,
> "Fitted objects with different fixed effects. REML comparisons are not
> meaningful." Upon examination using summary(l3), it seems that the  
> fixed
> factors are indeed different.
>
>   So, my question is this: How do I estimate omnibus main effects for
> multi-level factors and multi-level factor interactions in lme models?
>
> Many thanks,
> Adam D. I. Kramer
> Ph.D. Student, Social and Personality Psychology
> University of Oregon
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] survreg and pweibull

2008-11-26 Thread Andrew Beckerman

Dear all -

I have followed the thread the reply to which was lead by Thomas  
Lumley about using pweibull to generate fitted survival curves for  
survreg models.


http://tolstoy.newcastle.edu.au/R/help/04/11/7766.html

Using the lung data set,

data(lung)
lung.wbs <- survreg( Surv(time, status)~ 1, data=lung, dist='weibull')
curve(pweibull(x, scale=exp(coef(lung.wbs)), shape=1/lung.wbs 
$scale,lower.tail=FALSE),from=0, to=max(lung$time))

lines(survfit(Surv(time,status)~1, data=lung), col="red")

Assuming this is correct, why does the inflection point of this curve  
not match up to the exp(scale parameter)?  Am I wrong in assuming that  
the scale represents the inflection, and the shape adjusts the shape  
around this point?  I think I am perhaps confusing the scale and  
the median with the inflection point calcuation?


One can visualise the mismatch with:

abline(v=exp(coef(lung.wbs)),lty=2)
abline(h=0.5,lty=2)

Many thanks for the clarification

R version 2.8.0 (2008-10-20)
i386-apple-darwin8.11.1
locale:
en_GB.UTF-8/en_GB.UTF-8/C/C/en_GB.UTF-8/en_GB.UTF-8
attached base packages:
[1] splines   datasets  utils stats graphics  grDevices  
methods   base

other attached packages:
[1] survival_2.34-1 Hmisc_3.4-3 lattice_0.17-15 MASS_7.2-44
loaded via a namespace (and not attached):
[1] cluster_1.11.11 grid_2.8.0  tools_2.8.0

Andrew

---------
Dr. Andrew Beckerman
Department of Animal and Plant Sciences, University of Sheffield,
Alfred Denny Building, Western Bank, Sheffield S10 2TN, UK
ph +44 (0)114 222 0026; fx +44 (0)114 222 0002
http://www.beckslab.staff.shef.ac.uk/

http://www.flickr.com/photos/apbeckerman/
http://www.warblefly.co.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] survreg and pweibull solved for any distribution

2008-11-27 Thread Andrew Beckerman

Dear all -

Following up my own post, having found a Terry Therneau post about the  
value of predict(model,type="quantile"),


http://tolstoy.newcastle.edu.au/R/e4/help/08/03/5335.html

the following code ammendment produces what I was intending to see.   
It clear that the 0.5 quantile is the inflection point.  And predict()  
has the value of being distribution independent, and producing valid  
SE estimates.


data(lung)
lung.wbs <- survreg( Surv(time, status)~ 1, data=lung, dist='weibull')

curve(pweibull(x, scale=exp(coef(lung.wbs)), shape=1/lung.wbs 
$scale,lower.tail=FALSE),from=0, to=max(lung$time))

lines(survfit(Surv(time,status)~1, data=lung), col="red")

abline(h=0.5,lty=2)
abline(v=unique(predict(lung.wbs,type="quantile",p=0.5)),lty=2,col=4)

However, one last technical question.  In an intercept only model, how  
do you specify newdata to get just a single estimate?  In the above  
example I used unique against the model predictions evaluated at every  
datapoint.  But with no terms on the RHS of the model, how do you (can  
you) specify new data?


Best wishes,
Andrew



On 26 Nov 2008, at 16:27, Andrew Beckerman wrote:


Dear all -

I have followed the thread the reply to which was lead by Thomas  
Lumley about using pweibull to generate fitted survival curves for  
survreg models.


http://tolstoy.newcastle.edu.au/R/help/04/11/7766.html

Using the lung data set,

data(lung)
lung.wbs <- survreg( Surv(time, status)~ 1, data=lung, dist='weibull')
curve(pweibull(x, scale=exp(coef(lung.wbs)), shape=1/lung.wbs 
$scale,lower.tail=FALSE),from=0, to=max(lung$time))

lines(survfit(Surv(time,status)~1, data=lung), col="red")

Assuming this is correct, why does the inflection point of this  
curve not match up to the exp(scale parameter)?  Am I wrong in  
assuming that the scale represents the inflection, and the shape  
adjusts the shape around this point?  I think I am perhaps  
confusing the scale and the median with the inflection point  
calcuation?


One can visualise the mismatch with:

abline(v=exp(coef(lung.wbs)),lty=2)
abline(h=0.5,lty=2)

Many thanks for the clarification

R version 2.8.0 (2008-10-20)
i386-apple-darwin8.11.1
locale:
en_GB.UTF-8/en_GB.UTF-8/C/C/en_GB.UTF-8/en_GB.UTF-8
attached base packages:
[1] splines   datasets  utils stats graphics  grDevices  
methods   base

other attached packages:
[1] survival_2.34-1 Hmisc_3.4-3 lattice_0.17-15 MASS_7.2-44
loaded via a namespace (and not attached):
[1] cluster_1.11.11 grid_2.8.0  tools_2.8.0

Andrew

-----
Dr. Andrew Beckerman
Department of Animal and Plant Sciences, University of Sheffield,
Alfred Denny Building, Western Bank, Sheffield S10 2TN, UK
ph +44 (0)114 222 0026; fx +44 (0)114 222 0002
http://www.beckslab.staff.shef.ac.uk/

http://www.flickr.com/photos/apbeckerman/
http://www.warblefly.co.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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 contourplot line types

2009-02-22 Thread Andrew Beckerman

Dear all -

I would like to adjust the line type of specific contours in  
contourplot from the lattice package, but it seems like lty does not  
take a list in the call.


Here is my call to contourplot:

contourplot(preds~size+trt|Size.Name,
data=pred.dat,layout=c(2,4),
at=c(0.025,0.5,0.975),
par.strip.text=list(cex=1.2),
scales=list(cex=0.5),
xlab=list("Size",cex=1.2),
ylab=list("Treatment",cex=1.2),
panel=function(x,y,z,...){
panel.contourplot(x,y,z,lwd=1,...)
panel.grid(h=-1,v=-1,col="grey",...)})

I would like to specify lty=c(2,1,2) corresponding to the  
at=c(0.025,0.5,0.975), and have tried this in both the core part of  
the call, and in panel.countourplot.  However, it only recognises the  
first type.


If there is no straightforward answer, I can provide the data.

Best wishes,
Andrew

R version 2.8.1 (2008-12-22)
i386-apple-darwin8.11.1

locale:
en_GB.UTF-8/en_GB.UTF-8/C/C/en_GB.UTF-8/en_GB.UTF-8

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

other attached packages:
[1] MASS_7.2-45 lattice_0.17-17

loaded via a namespace (and not attached):
[1] grid_2.8.1

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 contourplot line types

2009-02-22 Thread Andrew Beckerman

Sundar -

Thanks for the help!  Here is my modified code.  Just what I wanted.   
However, it is odd that the at= call in contourplot won't take a  
single value - I have had to trick it into plotting the "0" contour  
along with the 0.5 to make this work.


contourplot(preds~size+trt|Size.Name,
data=pred.dat,layout=c(2,4),
par.strip.text=list(cex=1.2),
scales=list(cex=0.5),
xlab=list("Size",cex=1.2),
ylab=list("Treatment",cex=1.2),
panel=function(at,lty,...){
at.1<-c(0,0.5)
at.2<-c(0.025,0.975)
panel.contourplot(at=at.1,lty=1,...)
panel.contourplot(at=at.2,lty=2,...)
panel.grid(h=-1,v=-1,col="grey",...)})

Andrew

On 22 Feb 2009, at 21:25, Sundar Dorai-Raj wrote:


The only way I can figure out to do this is to use two calls to
panel.contourplot:

library(lattice)
x <- seq(-2, 2, length = 20)
y <- seq(-2, 2, length = 20)
grid <- expand.grid(x=x, y=y)
grid$z <- dnorm(grid$x) * dnorm(grid$y)
contourplot(z ~ x * y, grid,
   panel = function(at, lty, col, ...) {
 at.o <- at[seq(1, length(at), 2)]
 at.e <- at[seq(2, length(at), 2)]
 panel.contourplot(at = at.o, lty = 1, col = "blue", ...)
 panel.contourplot(at = at.e, lty = 4, col = "red", ...)
   },
   at = pretty(grid$z, 10))

HTH,

--sundar

On Sun, Feb 22, 2009 at 12:45 PM, Andrew Beckerman
 wrote:

Dear all -

I would like to adjust the line type of specific contours in  
contourplot
from the lattice package, but it seems like lty does not take a  
list in the

call.

Here is my call to contourplot:

contourplot(preds~size+trt|Size.Name,
  data=pred.dat,layout=c(2,4),
  at=c(0.025,0.5,0.975),
  par.strip.text=list(cex=1.2),
  scales=list(cex=0.5),
  xlab=list("Size",cex=1.2),
  ylab=list("Treatment",cex=1.2),
  panel=function(x,y,z,...){
  panel.contourplot(x,y,z,lwd=1,...)
  panel.grid(h=-1,v=-1,col="grey",...)})

I would like to specify lty=c(2,1,2) corresponding to the
at=c(0.025,0.5,0.975), and have tried this in both the core part of  
the
call, and in panel.countourplot.  However, it only recognises the  
first

type.

If there is no straightforward answer, I can provide the data.

Best wishes,
Andrew

R version 2.8.1 (2008-12-22)
i386-apple-darwin8.11.1

locale:
en_GB.UTF-8/en_GB.UTF-8/C/C/en_GB.UTF-8/en_GB.UTF-8

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

other attached packages:
[1] MASS_7.2-45 lattice_0.17-17

loaded via a namespace (and not attached):
[1] grid_2.8.1

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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. Andrew Beckerman
Department of Animal and Plant Sciences
University of Sheffield
Sheffield S10 2TN
UK

a.becker...@sheffield.ac.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.