Re: [R] cox.zph

2021-04-01 Thread Bendix Carstensen
Further to John Sorkin's post on the cox.zph:
You get test(s) of whether there is an interaction between a variable, say, 
sex, and time.

Suppose it is significant. You will have no clue whether the M/W hazard ratio 
is increasing or decreasing by time.

Suppose it is not significant. You will have no clue whether the 
(non-significant) M/W hazrad ratio exhibits a pattern that is worth looking 
further into or not.

In this sense the cox.zph is a perfect tool to allow you to write 'we checked 
for non proportionality' instead of 'we have no clue of how the M/W ratio 
varies by time'.

If you label it what it is, namely a test of interaction, you might realize 
that you should ESTIMATE the shape and size of the interaction before deriving 
a test, either ad-hoc by the Shoenfeld residuals or by proper modeling.

See for example pp 202 ff. in 'Epidemiology with R' by (surprise, surprise) me, 
published by OUP a few months ago.

b.r.
Bendix Carstensen
Senior Statistician
Steno Diabetes Center Copenhagen
Clinical Epidemiology
Niels Steensens Vej 2-4
DK-2820 Gentofte
Denmark
tel: +45 30 91 29 61
b...@bxc.dk
bendix.carsten...@regionh.dk
http://BendixCarstensen.com





Region Hovedstaden anvender de personoplysninger, du giver os i forbindelse med 
din henvendelse. Du kan læse mere om formålet med anvendelsen samt dine 
rettigheder på vores hjemmeside: www.regionh.dk/persondatapolitik

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


[R] ggpubr: order of non-numeric x-axis items

2019-10-27 Thread Bendix Carstensen
In the Epi package is a function, Relevel  (note the capital R), that does 
general reordering and combination of factor levels.
Bendix Carstensen
maintainer of Epi
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] xtabs ignores l.h.s. rows with NA in just one column - bug or facility?

2019-04-25 Thread Bendix Carstensen
Thanks for that, but the documentation also says that teh default behaviour is 
to use na.action=na.pass, which normally just ignores missing values, whereas 
xtabs seems to ignore the entire row...
/Bendix


From: David L Carlson 
Sent: 25 April 2019 15:55
To: Bendix Carstensen; r-help@r-project.org
Subject: RE: xtabs ignores l.h.s. rows with NA in just one column - bug or 
facility?

The documentation describes how to control the behavior of missing values:

> xtabs( cbind(xx,yy) ~ ff, addNA=TRUE)

ff  xx yy
  a 17
  b 55 66

But of course, now you do not get 26 in the (a, yy) cell because 26 + NA = NA.


David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77843-4352

-Original Message-
From: R-help  On Behalf Of Bendix Carstensen
Sent: Thursday, April 25, 2019 6:59 AM
To: r-help@r-project.org
Subject: [R] xtabs ignores l.h.s. rows with NA in just one column - bug or 
facility?

Here is an example showing that xtabs and cbind are not commutative, which at 
least I thought reading the help page for xtabs.

print( sessionInfo(), l=F )
xx <- c( 6,11,38,17)
yy <- c(NA,26,18,48)
ff <- c('a','a','b','b')
data.frame( xx, yy, ff )
xtabs( cbind(xx,yy) ~ ff )
cbind( xtabs(xx ~ ff ),
   xtabs(yy ~ ff ) )

Here is the result from my xomputer:

> print( sessionInfo(), l=F )
R version 3.5.3 (2019-03-11)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.6 LTS

Matrix products: default
BLAS: /usr/lib/openblas-base/libopenblas.so.0
LAPACK: /usr/lib/lapack/liblapack.so.3.0

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

loaded via a namespace (and not attached):
[1] compiler_3.5.3
> xx <- c( 6,11,38,17)
> yy <- c(NA,26,18,48)
> ff <- c('a','a','b','b')
> data.frame( xx, yy, ff )
  xx yy ff
1  6 NA  a
2 11 26  a
3 38 18  b
4 17 48  b
> xtabs( cbind(xx,yy) ~ ff )

ff  xx yy
  a 11 26
  b 55 66
> cbind( xtabs(xx ~ ff ),
+xtabs(yy ~ ff ) )
  [,1] [,2]
a   17   26
b   55   66
>

I would have guessed the upper left entry would be 17 in the first instance 
too, but it appears that xtabs does something like complete.cases() on the 
l.h.s. before summing. At least this should be in the description.

Am I missing something here?
Bendix Carstensen
Steno Diabetes Center Copenhagen




Denne e-mail indeholder fortrolig information. Hvis du ikke er den rette 
modtager af denne e-mail eller hvis du modtager den ved en fejltagelse, beder 
vi dig venligst informere afsender om fejlen ved at bruge svarfunktionen. 
Samtidig bedes du slette e-mailen med det samme uden at videresende eller 
kopiere den.

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




Denne e-mail indeholder fortrolig information. Hvis du ikke er den rette 
modtager af denne e-mail eller hvis du modtager den ved en fejltagelse, beder 
vi dig venligst informere afsender om fejlen ved at bruge svarfunktionen. 
Samtidig bedes du slette e-mailen med det samme uden at videresende eller 
kopiere den.

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


[R] xtabs ignores l.h.s. rows with NA in just one column - bug or facility?

2019-04-25 Thread Bendix Carstensen
Here is an example showing that xtabs and cbind are not commutative, which at 
least I thought reading the help page for xtabs.

print( sessionInfo(), l=F )
xx <- c( 6,11,38,17)
yy <- c(NA,26,18,48)
ff <- c('a','a','b','b')
data.frame( xx, yy, ff )
xtabs( cbind(xx,yy) ~ ff )
cbind( xtabs(xx ~ ff ),
   xtabs(yy ~ ff ) )

Here is the result from my xomputer:

> print( sessionInfo(), l=F )
R version 3.5.3 (2019-03-11)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.6 LTS

Matrix products: default
BLAS: /usr/lib/openblas-base/libopenblas.so.0
LAPACK: /usr/lib/lapack/liblapack.so.3.0

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

loaded via a namespace (and not attached):
[1] compiler_3.5.3
> xx <- c( 6,11,38,17)
> yy <- c(NA,26,18,48)
> ff <- c('a','a','b','b')
> data.frame( xx, yy, ff )
  xx yy ff
1  6 NA  a
2 11 26  a
3 38 18  b
4 17 48  b
> xtabs( cbind(xx,yy) ~ ff )

ff  xx yy
  a 11 26
  b 55 66
> cbind( xtabs(xx ~ ff ),
+xtabs(yy ~ ff ) )
  [,1] [,2]
a   17   26
b   55   66
>

I would have guessed the upper left entry would be 17 in the first instance 
too, but it appears that xtabs does something like complete.cases() on the 
l.h.s. before summing. At least this should be in the description.

Am I missing something here?
Bendix Carstensen
Steno Diabetes Center Copenhagen




Denne e-mail indeholder fortrolig information. Hvis du ikke er den rette 
modtager af denne e-mail eller hvis du modtager den ved en fejltagelse, beder 
vi dig venligst informere afsender om fejlen ved at bruge svarfunktionen. 
Samtidig bedes du slette e-mailen med det samme uden at videresende eller 
kopiere den.

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


Re: [R] Names of variables needed in newdata for predict.glm

2018-03-31 Thread Bendix Carstensen
all.vars works fine, EXCEPT, it give a bit too much.
I only want the regression variables, but in the following example I also get 
"k" the variable holding the chosen knots. Any machinery to find only "real" 
regression variables?
cheers, Bendix

library( splines )
y <- rnorm(100)
x <- rnorm(100)
k <- -1:1
ml <-  lm( y ~ bs(x,knots=k) )
mg <- glm( y ~ bs(x,knots=k) )
all.vars(ml$terms)
all.vars(mg$terms)
all.vars(mg$formula)


Fra: Marc Girondot 
Sendt: 8. marts 2018 06:26
Til: Bendix Carstensen; r-help@r-project.org
Emne: Re: [R] Names of variables needed in newdata for predict.glm

Hi,

Some try:
 > names(mi$xlevels)
[1] "f"
 > all.vars(mi$formula)
[1] "D" "x" "f" "Y"
 > names(mx$xlevels)
[1] "f"
 > all.vars(mx$formula)
[1] "D" "x" "f"

When offset is indicated out of the formula, it does not work...

Marc

Le 07/03/2018 à 06:20, Bendix Carstensen a écrit :
> I would like to extract the names, modes [numeric/factor] and levels
> of variables needed in a data frame supplied as newdata= argument to
> predict.glm()
>
> Here is a small example illustrating my troubles; what I want from
> (both of) the glm objects is the vector c("x","f","Y") and an
> indication that f is a factor:
>
> library( splines )
> dd <- data.frame( D = sample(0:1,200,rep=T),
>x = abs(rnorm(200)),
>f = factor(sample(letters[1:4],200,rep=T)),
>Y = runif(200,0.5,10) )
> mx <- glm( D ~ ns(x,knots=1:2,Bo=c(0,5)) + f:I(x^2) , offset=log(Y) , 
> family=poisson, data=dd)
> mi <- glm( D ~ ns(x,knots=1:2,Bo=c(0,5)) + f:I(x^2) + offset(log(Y)), 
> family=poisson, data=dd)
>
> attr(mx$terms,"dataClasses")
> attr(mi$terms,"dataClasses")
> mi$xlevels
> mx$xlevels
>
> ...so far not quite there.
>
> Regards,
>
> Bendix Carstensen
>
> Senior Statistician
> Steno Diabetes Center
> Clinical Epidemiology
> Niels Steensens Vej 2-4
> DK-2820 Gentofte, Denmark
> b...@bxc.dk
> bendix.carsten...@regionh.dk
> http://BendixCarstensen.com
>
> 
>
>
> Denne e-mail indeholder fortrolig information. Hvis du ikke er den rette 
> modtager af denne e-mail eller hvis du modtager den ved en fejltagelse, beder 
> vi dig venligst informere afsender om fejlen ved at bruge svarfunktionen. 
> Samtidig bedes du slette e-mailen med det samme uden at videresende eller 
> kopiere den.
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>





Denne e-mail indeholder fortrolig information. Hvis du ikke er den rette 
modtager af denne e-mail eller hvis du modtager den ved en fejltagelse, beder 
vi dig venligst informere afsender om fejlen ved at bruge svarfunktionen. 
Samtidig bedes du slette e-mailen med det samme uden at videresende eller 
kopiere den.

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


[R] Names of variables needed in newdata for predict.glm

2018-03-06 Thread Bendix Carstensen
I would like to extract the names, modes [numeric/factor] and levels
of variables needed in a data frame supplied as newdata= argument to
predict.glm()

Here is a small example illustrating my troubles; what I want from
(both of) the glm objects is the vector c("x","f","Y") and an
indication that f is a factor:

library( splines )
dd <- data.frame( D = sample(0:1,200,rep=T),
  x = abs(rnorm(200)),
  f = factor(sample(letters[1:4],200,rep=T)),
  Y = runif(200,0.5,10) )
mx <- glm( D ~ ns(x,knots=1:2,Bo=c(0,5)) + f:I(x^2) , offset=log(Y) , 
family=poisson, data=dd)
mi <- glm( D ~ ns(x,knots=1:2,Bo=c(0,5)) + f:I(x^2) + offset(log(Y)), 
family=poisson, data=dd)

attr(mx$terms,"dataClasses")
attr(mi$terms,"dataClasses")
mi$xlevels
mx$xlevels

...so far not quite there.

Regards,

Bendix Carstensen

Senior Statistician
Steno Diabetes Center
Clinical Epidemiology
Niels Steensens Vej 2-4
DK-2820 Gentofte, Denmark
b...@bxc.dk
bendix.carsten...@regionh.dk
http://BendixCarstensen.com




Denne e-mail indeholder fortrolig information. Hvis du ikke er den rette 
modtager af denne e-mail eller hvis du modtager den ved en fejltagelse, beder 
vi dig venligst informere afsender om fejlen ved at bruge svarfunktionen. 
Samtidig bedes du slette e-mailen med det samme uden at videresende eller 
kopiere den.

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


[R] Splines with more restrictions

2015-11-04 Thread BXC (Bendix Carstensen)
I would like to generate a natural spline where the slope beyond the last knot 
(the right outer knot) is constrained to be 0.
Is that available in some package around?
_

Bendix Carstensen
Senior Statistician
Steno Diabetes Center
Clinical Epidemiology
Niels Steensens Vej 2-4
DK-2820 Gentofte
Denmark
phone: +45 30 75 87 38
b...@steno.dk   http://BendixCarstensen.com

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


[R] Computing plot size in Sweave

2012-02-20 Thread BXC (Bendix Carstensen)
Sometimes you want to compute the physical size of a plot based on data.
In R itself this is no problem.

But is there a way to compute the values of height and width in S-weave, say:

<>=

where xx and yy are computed and not physically written in the document?

Bendix
__

Bendix Carstensen 
Senior Statistician
Epidemiology

Steno Diabetes Center A/S
Niels Steensens Vej 2-4
DK-2820 Gentofte
Denmark
+45 44 43 87 38 (direct)
+45 30 75 87 38 (mobile)
b...@steno.dkhttp://BendixCarstensen.com
www.steno.dk

This e-mail (including any attachments) is intended for ...{{dropped:8}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Code for a plot of a DNA double helix?

2012-01-25 Thread BXC (Bendix Carstensen)
Does anyone have a piece of R-code that draws a nice picture of a (piece of a) 
DNA double helix?
B.r.
Bendix
_

Bendix Carstensen 
Senior Statistician
Epidemiology
Steno Diabetes Center A/S
Niels Steensens Vej 2-4
DK-2820 Gentofte
Denmark
+45 44 43 87 38 (direct)
+45 30 75 87 38 (mobile)
b...@steno.dkhttp://BendixCarstensen.com
www.steno.dk

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Sweave in 2.13.1

2011-07-16 Thread BXC (Bendix Carstensen)
I run Windows XP.

and in a command window I get:

> c:\stat\r\R-2.13.1\bin\i386\Rcmd Sweave Lexis.rnw
Error in length(arg) : 'arg' is missing
Calls: 
Execution halted

AND:

> c:\stat\r\R-2.13.1\bin\i386\Rcmd Sweave --help
Error in length(arg) : 'arg' is missing
Calls: 
Execution halted

BUT:

> c:\stat\r\R-2.13.0\bin\i386\Rcmd Sweave --help
Usage: R CMD Sweave file

A simple front-end for Sweave

Options:
  -h, --help print this help message and exit
  -v, --version  print version info and exit

Report bugs to .

Same probelem for help on Stangle, but not for any other command.

Is this a bug or some new facility I overlooked?

Best regards,
Bendix
_________

Bendix Carstensen 
Senior Statistician
Steno Diabetes Center A/S
Niels Steensens Vej 2-4
DK-2820 Gentofte
Denmark
+45 44 43 87 38 (direct)
+45 30 75 87 38 (mobile)
b...@steno.dkwww.biostat.ku.dk/~bxc
www.steno.dk

This e-mail (including any attachments) is intended for ...{{dropped:8}}

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

2011-02-09 Thread BXC (Bendix Carstensen)
We spotted that there were problems, and have realized that the as.Date.numeric 
was a left-over form earlier; it will be removed in the next version of the Epi 
package.
Thanks for the help.
br.
Bendix 

> -Original Message-
> From: Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk] 
> Sent: 9. februar 2011 11:48
> To: Philipp Pagel
> Cc: BXC (Bendix Carstensen); r-help@r-project.org
> Subject: Re: [R] as.Date
> 
> And I am hereby reporting this bug to the package maintainer.
> 
> On Wed, 9 Feb 2011, Philipp Pagel wrote:
> 
> > On Wed, Feb 09, 2011 at 08:44:30AM +0100, Valeri Fabio wrote:
> >> Hello,
> >>
> >> I find out which package disturbs as.Date(). It is the package Epi:
> >>
> >>> as.Date(36525, origin="1900-01-01")
> >> [1] "2000-01-02"
> >>> library(Epi)
> >>> as.Date(36525, origin="1900-01-01")
> >> [1] "2070-01-01"
> >>> detach("package:Epi")
> >>> as.Date(36525, origin="1900-01-01")
> >> [1] "2000-01-02"
> >
> > OK - that makes sense. Epi has its own as.Date.numeric function and 
> > upon loading the package you get a warning:
> >
> >
> >> library(Epi)
> > Attaching package: 'Epi'
> > The following object(s) are masked from 'package:base':
> >as.Date.numeric, merge.data.frame
> >
> >
> > A quick look at the manual page confirms that Epi's version 
> does not 
> > have an origin option.
> >
> > cu
> > Philipp
> >
> > --
> > Dr. Philipp Pagel
> > Lehrstuhl für Genomorientierte Bioinformatik Technische Universität 
> > München Wissenschaftszentrum Weihenstephan Maximus-von-Imhof-Forum 3
> > 85354 Freising, Germany
> > http://webclu.bio.wzw.tum.de/~pagel/
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide 
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
> 
> -- 
> Brian D. Ripley,  rip...@stats.ox.ac.uk
> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
> University of Oxford, Tel:  +44 1865 272861 (self)
> 1 South Parks Road, +44 1865 272866 (PA)
> Oxford OX1 3TG, UKFax:  +44 1865 272595
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Fishy error with NAMESPACE when checking package

2010-04-17 Thread BXC (Bendix Carstensen)
I am updating the Epi package.

I added functions named pc.points and pc.matpoints.
Erroneously I wrote pc.plot and pc.matplot in the NAMESPACE file and of course 
got an error from Rcmd check.
So I corrected the NAMESPACE file, but I still get from r-check:

* install options are ' --no-html'

Loading required package: utils
Error in namespaceExport(ns, exports) :
  undefined exports: pc.plot, pc.matplot
Error: package/namespace load failed for 'Epi'

I cannot seem to find any occurrence of the strings "pc.plot" and "pc.matplot" 
anywhere in the entire package tree.

Any idea of what goes on (and where to find the perpetrators)???

I use:
   _
platform   i386-pc-mingw32  
arch   i386 
os mingw32  
system i386, mingw32
status  
major  2
minor  10.1 
year   2009 
month  12   
day14   
svn rev50720
language   R
version.string R version 2.10.1 (2009-12-14)

Best regards,
Bendix
_______

Bendix Carstensen 
Senior Statistician
Steno Diabetes Center
Niels Steensens Vej 2-4
DK-2820 Gentofte
Denmark
+45 44 43 87 38 (direct)
+45 30 75 87 38 (mobile)
b...@steno.dk   http://www.biostat.ku.dk/~bxc
www.steno.dk

This e-mail (including any attachments) is intended for ...{{dropped:8}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] The TeX-source for the package manual.

2010-01-12 Thread BXC (Bendix Carstensen)
I have noted that the later versions of Rcmd check cleans out the directory 
pkg.Rcheck so that only package-manual.log and package-manual.pdf are left.
Formerly the package-manual.tex was around too --- very handy for various 
purposes.

Is there a way to generate the .tex - version of the manual for a package?

br.
Bendix
__

Bendix Carstensen 
Senior Statistician
Steno Diabetes Center
Niels Steensens Vej 2-4
DK-2820 Gentofte
Denmark
+45 44 43 87 38 (direct)
+45 30 75 87 38 (mobile)
b...@steno.dk   http://www.biostat.ku.dk/~bxc
www.steno.dk

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] The .tex version of the manual in foo.Rcheck

2009-04-27 Thread BXC (Bendix Carstensen)
In version 2.8.1, running Rcmd check on the package foo would leave the file 
foo-manual.tex in the folder foo.Rcheck.

But as of 2.9.0 only foo-manual.pdf and foo-manual.log are there.

Is this intentional?
Anyway it is inconvenient, because I would occasionally like to include the 
manual at the end of a set of exercises, and this was a convenient file to 
\input with a few select %'s added.

br.
Bendix
___

Bendix Carstensen 
Senior Statistician
Steno Diabetes Center
Niels Steensens Vej 2-4
DK-2820 Gentofte
Denmark
+45 44 43 87 38 (direct)
+45 30 75 87 38 (mobile)
b...@steno.dk   http://www.biostat.ku.dk/~bxc
www.steno.dk

This e-mail (including any attachments) is intended for ...{{dropped:8}}

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

2008-08-25 Thread BXC (Bendix Carstensen)
Artimon,

It seems that you have got the data wrong: The data structure is a list of 4 
characters:

> list("y","X","n","m")
[[1]]
[1] "y"

[[2]]
[1] "X"

[[3]]
[1] "n"

[[4]]
[1] "m"

And that is hardly what you want, presumably you meant

list("y"=y,"X"=X,"n"=n,"m"=m)

??
__

Bendix Carstensen
Senior Statistician
Steno Diabetes Center
Niels Steensens Vej 2-4
DK-2820 Gentofte
Denmark
+45 44 43 87 38 (direct)
+45 30 75 87 38 (mobile)
[EMAIL PROTECTED]   http://www.biostat.ku.dk/~bxc

Uwe Ligges ligges at statistik.tu-dortmund.de
Fri Aug 22 19:15:17 CEST 2008

artimon wrote:
> Dear Users,
> I am new to both of things, so do not blame me too much...
>
> I am busy with semiparametric regression and use WinBUGS to sample
> posteriors.
> The code to call Winbugs is as follows:
>
> data  <- list("y","X","n","m") #My variables
> inits.beta<- rep(0,K)
> inits.beta0   <- 0
> inits <- 
> function(){list(beta=inits.beta,beta0=inits.beta0,taueps=1.0E-3)}
> parameters<- list("sigma","beta","beta0","y.star")
> fitm  <- bugs(data,inits,parameters,model.file="model.bug",
>   n.chains=3, n.iter=n.iter, n.burnin=n.burnin, n.thin = 
> n.thin,
>   debug=FALSE,DIC=FALSE,digit=5,codaPkg=FALSE,
>   bugs.directory="C:/Program Files/WinBUGS14/")
 >
> but I always get the following error:
> Error in FUN(X[[1L]], ...) :
>   .C(..): 'type' must be "real" for this format
>
>
> I tried the web, but failed. Could anyone give me a clue?
> Best!
>


- Your example is not reproducible for us (without the data).
- Is WinBUGS runnign correctly (see its output with debug=TRUE)?
- What does traceback() tell us?

Which versions of R, WinBUGS and R2WinBUGS are in use?

Uwe Ligges

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] FW: Installing BRugs

2008-07-29 Thread BXC (Bendix Carstensen)
A funny thing happened when I wanted a student of mine to install Brugs.
Using the InstallPackages in the windows version, firts gives an erro, but 
trying again works flawlessly.

R version is 2.7.0 on WinXP.

Any explanation?

Bendix Carstensen
__

Bendix Carstensen
Senior Statistician
Steno Diabetes Center
Niels Steensens Vej 2-4
DK-2820 Gentofte
Denmark
+45 44 43 87 38 (direct)
+45 30 75 87 38 (mobile)
[EMAIL PROTECTED]   http://www.biostat.ku.dk/~bxc

-Original Message-
From: ACJS (Anders Christian Jensen)
Sent: 29. juli 2008 11:06
To: BXC (Bendix Carstensen)
Subject:

> utils:::menuInstallPkgs()
trying URL 
'http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.7/BRugs_0.4-2.zip'
Content type 'application/zip' length 3399130 bytes (3.2 Mb) opened URL 
downloaded 3.1 Mb

Error in gzfile(file, "r") : cannot open the connection In addition: Warning 
messages:
1: In download.file(url, destfile, method, mode = "wb", ...) :
  downloaded length 3293996 != reported length 3399130
2: In zip.unpack(pkg, tmpDir) : error 1 in extracting from zip file
3: In gzfile(file, "r") :
  cannot open compressed file 'BRugs/DESCRIPTION', probable reason 'No such 
file or directory'
> utils:::menuInstallPkgs()
trying URL 
'http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.7/BRugs_0.4-2.zip'
Content type 'application/zip' length 3399130 bytes (3.2 Mb) opened URL 
downloaded 3.2 Mb

package 'BRugs' successfully unpacked and MD5 sums checked

The downloaded packages are in
c:\temp\RtmpKoBifa\downloaded_packages
updating HTML package descriptions
>

___

Anders Christian Jensen

Steno Diabetes Center
Niels Steensens Vej 2-4
DK-2820 Gentofte
Denmark
+45 444 22475 (direct)
[EMAIL PROTECTED]

This e-mail (including any attachments) is intended for ...{{dropped:8}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] competing risk model with time dependent covariates under R or Splus

2008-07-27 Thread BXC (Bendix Carstensen)
This message was also sent to the MEDSTATS mailing list, so here is the reply I 
posted to that:

Philippe,

The machinery to use is to split follow-up time so finely that you can safely 
assume that rates are constant in each interval, and then just stuff it all 
into a Poisson model. This allows you to use any kind of time-dependent 
variables as well as accommodating competing risks.

In the Epi package (http://staff.pubhealth.ku.dk/~bxc/Epi/) on CRAN there is a 
machinery for representation and manipulation of multistate data (of which 
competing risks are a special case), see the function Lexis().
It also has a time-splitting function there, splitLexis().

If you take a look at practical 14 from this year's SPE course:
http://staff.pubhealth.ku.dk/~bxc/SPE/2008/pracs.pdf
there is an example that addresses the problem you are having, practical no. 14.
If go to the folder
http://staff.pubhealth.ku.dk/~bxc/SPE/2008/R
you will find the R-code that runs the solution to the practical. The data used 
is a part of the Epi-package, so you just have to load the Epi package first.

It is however not using the Fine/Gray approach, but is directly modelling the 
cause-specific rates taking time dependent covariates into account.

Best regards,
Bendix
______

Bendix Carstensen
Senior Statistician
Steno Diabetes Center
Niels Steensens Vej 2-4
DK-2820 Gentofte
Denmark
+45 44 43 87 38 (direct)
+45 30 75 87 38 (mobile)
[EMAIL PROTECTED]   http://www.biostat.ku.dk/~bxc


> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of pguardio
> Sent: 26. juli 2008 22:47
> To: MedStats
> Subject: {MEDSTATS} competing risk model with time dependent
> covariates under R or Splus
>
>
>
> Dear members,
>
> is there a way to perform a competing risk model which can
> handle time dependent covariates under either R ou SPlus ?
>
> my main covariate (additional treatment to patients) violates
> the proportional hazards assumption, its effect being
> observed after one year of the main treatment, not before
> (this is expected / makes sense on a clinical point of view).
> So I was planning to use a time dependent Cox model with 2
> time intervals for patients: < > 1 year etc...
>
> However, I need to use a competing risk model because a large
> number of patients dies from early toxicity from main
> treatment (not related to the additional treatment I m
> evaluating the effect) or from events unrelated to the
> disease or the treatments (elderly patients).
> Therefore, to analyze the effect of my covariate of interest
> on disease free survival and relapse incidence, I d like to
> use a competing risk model such as the Gray CMPRSK.
>
> However, I cannot have multiple "lines" for the same patient
> (cluster function is not allowed in CMPRSK) with this package
> (for time dep covariates I need 1 or 2 lines with same Id /UPN).
>
> Does anyone knows how can I manage this in CMPRSK ?
>
> Any help will be greatly appreciated
> Thanks
> Yours sincerely
>
> Philippe Guardiola
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Figure environment and includegraphics options from Sweave

2008-05-18 Thread BXC (Bendix Carstensen)
Thanks a lot yuor advice works, here is an actually working example of
an .rnw file, where the graphs are stuffed in a subfolder:
 
\documentclass{article}
\begin{document}
\SweaveOpts{include=FALSE}
This is an experiment with two plots.

Here is the first:
<>=
x<-seq(-2*pi, 2*pi, .1)
plot(x, sin(x), type="l", lwd=4)
@
And here is the second:
<>=
x<-seq(-2*pi, 2*pi, .1)
plot(x, cos(x), type="l", lwd=4)
@
The result should be two graphs side by side:
\begin{figure}[h]
  \centering
  \includegraphics[width=0.27\textwidth]{./graph/xx-CHUNK1} \hfill
  \includegraphics[width=0.63\textwidth]{./graph/xx-TJUNK2}
  \caption{\it Here is the caption.}
  \label{fig:Tschunks1und2}
\end{figure}

\end{document}



> -Original Message-
> From: Charilaos Skiadas [mailto:[EMAIL PROTECTED] 
> Sent: 18. maj 2008 17:08
> To: BXC (Bendix Carstensen)
> Cc: r-help@r-project.org
> Subject: Re: [R] Figure environment and includegraphics 
> options from Sweave
> 
> 
> On May 18, 2008, at 10:41 AM, BXC (Bendix Carstensen) wrote:
> 
> > Tha handy thinb about the fig=TRUE option in Sweave is that 
> you do not 
> > have to bother about filenames and starting and stpping the device.
> >
> > I want the the resulting LaTeX to look as:
> >
> > \begin{Schunk}
> > \begin{Sinput}
> >> x <- seq(-2 * pi, 2 * pi, 0.1)
> >> plot(x, cos(x), type = "l", lwd = 4)
> > \end{Sinput}
> > \end{Schunk}
> >
> 
> > \begin{figure}
> > \includegraphics[width=0.6\textwidth]{xx-001}
> > \end{figure}
> >
> 
> > i.e. with options to the \includegraphics and all embedded 
> in a figure 
> > environment.
> >
> > 1)
> > Is there a way to do this without writing the figure environment 
> > manually?
> 
> The Sweave manual (section 4.1.2 in my version) suggests 
> using something like this before the figure call:
> 
> \setkeys{Gin}{width=0.6\textwidth}
> 
> This sets the size globally. Not perfect, but it's what I've 
> been doing.
> I would myself like the ability to add optional arguments to 
> the produced \includegraphics call, but perhaps there is a 
> good reason why this hasn't been implemented (other than that 
> the developer might not have thought it useful/necessary, 
> which is in itself a perfectly good reason why this feature 
> is not there).
> 
> > 2)
> > If not, is there a way to get the generated filename of the 
> plot, or 
> > to explicitly give it in the .rnw file? The point of course 
> being to 
> > avoid to start and stop the graphics driver explicitly?
> 
> I haven't tried it, but perhaps if you have a named figure 
> code chunk, this name is used for the file name?
> 
> > Best,
> > Bendix Carstensen
> > __
> >
> > Bendix Carstensen
> > Senior Statistician
> > Steno Diabetes Center
> > Niels Steensens Vej 2-4
> > DK-2820 Gentofte
> > Denmark
> > +45 44 43 87 38 (direct)
> > +45 30 75 87 38 (mobile)
> > [EMAIL PROTECTED]   http://www.biostat.ku.dk/~bxc
> 
> Haris Skiadas
> Department of Mathematics and Computer Science Hanover College
> 
> 
> 
> 
> 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Figure environment and includegraphics options from Sweave

2008-05-18 Thread BXC (Bendix Carstensen)
Tha handy thinb about the fig=TRUE option in Sweave is that you do not
have to bother about filenames and starting and stpping the device.

I want the the resulting LaTeX to look as:

\begin{Schunk}
\begin{Sinput}
> x <- seq(-2 * pi, 2 * pi, 0.1)
> plot(x, cos(x), type = "l", lwd = 4)
\end{Sinput}
\end{Schunk}

\begin{figure}
\includegraphics[width=0.6\textwidth]{xx-001}
\end{figure}

i.e. with options to the \includegraphics and all embedded in a figure
environment.

1)
Is there a way to do this without writing the figure environment
manually?

2)
If not, is there a way to get the generated filename of the plot, or to
explicitly give it
in the .rnw file? The point of course being to avoid to start and stop
the graphics driver explicitly?

Best,
Bendix Carstensen
______

Bendix Carstensen
Senior Statistician
Steno Diabetes Center
Niels Steensens Vej 2-4
DK-2820 Gentofte
Denmark
+45 44 43 87 38 (direct)
+45 30 75 87 38 (mobile)
[EMAIL PROTECTED]   http://www.biostat.ku.dk/~bxc

This e-mail (including any attachments) is intended for ...{{dropped:8}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Course: STATISTICAL PRACTICE IN EPIDEMIOLOGY USING R

2008-02-24 Thread BXC (Bendix Carstensen)
Course in
 
STATISTICAL PRACTICE IN EPIDEMIOLOGY USING R



Tartu, Estonia, Wednesday 28 May to Monday 2 June 2008.

Aimed at young statisticians and epidemiologists wishing to broaden
their epidemiological skills, in particular with respect to practical
statistical analysis. Participants will gain access to the versatile
analysis tool R which has good analytical in particular graphical 
capabilities. The Epi-package for R will be extensively used.

Participants are required to have a fairly good understanding of
statistical principles and some familiarity with epidemiological
concepts. The course will be mainly practically oriented with more
than half the time at the computer.

Price: Commercial: 1000 EUR, Academic: 750 EUR / 500 EUR.
The 750 EUR are for particpants from the EU pre-2004, North America
and the like. 500 for particants from other countries.

Application deadline: 15 April 2004.

Send an application by mail to the organizers, briefly stating your
qualifications in epidemiology and statistics and a brief reason to
participate: [EMAIL PROTECTED]; [EMAIL PROTECTED];
[EMAIL PROTECTED]

Further information at the course homepage: www.biostat.ku.dk/~bxc/SPE

--
Krista Fischer, University of Tartu, Estonia
Esa Läärä, University of Oulu, Finland
Bendix Carstensen, Steno Diabetes Center, Denmark 
(Organizers)

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


[R] [R-pkgs] New version of Epi package out (1.0.7)

2008-01-17 Thread BXC (Bendix Carstensen)
A new major upgrade of the Epi package for Epidemiological data analysis
has been put on CRAN, it is now at version 1.0.7.

It contains an entirely new way of representing follow-up data on
multiple timescales and multiple states. See the function Lexis().

Plus a lot of other useful stuff for epidemiological analysis.
See more on the package homepage, www.biostat.ku.dk/~bxc/Epi

Note also that there will be a course 28 May - 2 June in Estonia, see
www.biostat.ku.dk/~bxc/SPE.

Bendix Carstensen
Epi package maintainer  
__

Bendix Carstensen
Senior Statistician
Steno Diabetes Center
Niels Steensens Vej 2-4
DK-2820 Gentofte
Denmark
+45 44 43 87 38 (direct)
+45 30 75 87 38 (mobile)
[EMAIL PROTECTED]   http://www.biostat.ku.dk/~bxc

___
R-packages mailing list
[EMAIL PROTECTED]
https://stat.ethz.ch/mailman/listinfo/r-packages

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