[R] Compiling RMySQL on Win7 64bits RS-DBI.c:1:0: sorry, unimplemented: 64-bit mode not compiled in

2012-04-24 Thread Ben Rhelp
Hi,

On a Win7 64 bit, I have installed:
*R-15.0 and I am running it in 64bits
*Rtools215.exe*MySQL 5.5.23 64bits

My PATH start with 
D:\BenSave\Rtools\bin;D:\BenSave\Rtools\MinGW64\bin;D:\BenSave\R\R-2.15.0\bin;D:\BenSave\Rtools\MinGW\bin;D:\BenSave\Rtools\gcc-4.6.3\bin;


Note that I place MinGW64\bin has I want the package in 64 bits, so just in 
case it helps...


To install RMySQL 64 bits, I then followed the steps described in 
http://stackoverflow.com/questions/4785933/adding-rmysql-package-to-r-fails, 
namely:

1. Install latest RTools from 
http://cran.r-project.org/bin/windows/Rtools/
2. install MySQL or header and library files of mysql
3. create or edit file C:\Program Files\R\R-2.15\etc\Renviron.site and 
add line like MYSQL_HOME=C:/mysql (path to your mysql files)
4. copy libmysql.lib from mysql/lib to mysql/lib/opt to meet 
dependencies.
5. copy libmysql.dll to C:\Program Files\R\R-2.15\bin directory.
6. run install.packages('RMySQL',type='source') and wait while 
compilation will end.

 install.packages('RMySQL', type = 'source')
--- Please select a CRAN mirror for use in this session ---
trying URL 'http://cran.ma.imperial.ac.uk/src/contrib/RMySQL_0.9-3.tar.gz'
Content type 'application/x-gzip' length 165363 bytes (161 Kb)
opened URL
downloaded 161 Kb

* installing *source* package 'RMySQL' ...
** package 'RMySQL' successfully unpacked and MD5 sums checked
checking for $MYSQL_HOME... D:/MySQL/forR55
** libs
Warning: this package has a non-empty 'configure.win' file,
so building only the main architecture

gcc -m64 -ID:/BenSave/R/R-215~1.0/include -DNDEBUG 
-ID:/MySQL/forR55/include    
-Id:/RCompile/CRANpkg/extralibs64/local/include     -O2 -Wall  
-std=gnu99 -mtune=core2 -c RS-DBI.c -o RS-DBI.o
RS-DBI.c:1:0: sorry, unimplemented: 64-bit mode not compiled in
make: *** [RS-DBI.o] Error 1
ERROR: compilation failed for package 'RMySQL'
* removing 'D:/BenSave/R/R-2.15.0/library/RMySQL'

The downloaded source packages are in
        
‘C:\Users\Bvinsonneau\TempFolder\RtmpwPJoVe\downloaded_packages’
Warning messages:
1: running command 'D:/BenSave/R/R-2.15.0/bin/x64/R CMD INSTALL -l 
D:/BenSave/R/R-2.15.0/library   
C:\Users\BenSave\TempFolder\RtmpwPJoVe/downloaded_packages/RMySQL_0.9-3.tar.gz' 
had status 1 
2: In install.packages(RMySQL, type = source) :
  installation of package ‘RMySQL’ had non-zero exit status
 



I seems to have the same error than the reporter on

http://r.789695.n4.nabble.com/Installing-RMySQL-64-bit-Windows-7-td4466352.html
and Prof Brian Ripley suggests that the reporter should re-read the the 
instructions in 'R Installation and 
Administration'. I did so but no luck. I am not sure what I am missing. 

Does anyone have a suggestion?

Regards,

Ben
[[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] Compiling RMySQL on Win7 64bits RS-DBI.c:1:0: sorry, unimplemented: 64-bit mode not compiled in

2012-04-24 Thread Ben Rhelp
:(.text+0x3408): undefined reference to 
`mysql_server_end@0'
collect2: ld returned 1 exit status
ERROR: compilation failed for package 'RMySQL'
* removing 'D:/BenSave/R/R-2.15.0/library/RMySQL'

The downloaded source packages are in
        ‘C:\Users\BenSave\TempFolder\RtmpS8df20\downloaded_packages’
Warning messages:
1: running command 'D:/BenSave/R/R-2.15.0/bin/i386/R CMD INSTALL -l 
D:/BenSave/R/R-2.15.0/library   
C:\Users\BenSave\TempFolder\RtmpS8df20/downloaded_packages/RMySQL_0.9-3.tar.gz' 
had status 1 
2: In install.packages(RMySQL, type = source) :
  installation of package ‘RMySQL’ had non-zero exit status






 From: Uwe Ligges lig...@statistik.tu-dortmund.de
To: Ben Rhelp benrh...@yahoo.co.uk 
Cc: r-help@r-project.org r-help@r-project.org 
Sent: Tuesday, 24 April 2012, 18:22
Subject: Re: [R] Compiling RMySQL on Win7 64bits RS-DBI.c:1:0: sorry, 
unimplemented: 64-bit mode not compiled in
 


On 24.04.2012 16:40, Ben Rhelp wrote:
 Hi,

 On a Win7 64 bit, I have installed:
 *R-15.0 and I am running it in 64bits
 *Rtools215.exe*MySQL 5.5.23 64bits

 My PATH start with 
 D:\BenSave\Rtools\bin;D:\BenSave\Rtools\MinGW64\bin;D:\BenSave\R\R-2.15.0\bin;D:\BenSave\Rtools\MinGW\bin;D:\BenSave\Rtools\gcc-4.6.3\bin;


What is D:\BenSave\Rtools\MinGW64\bin? Probably it needs to go out of 
the way.

Uwe Ligges


 Note that I place MinGW64\bin has I want the package in 64 bits, so just in 
 case it helps...


 To install RMySQL 64 bits, I then followed the steps described in 
 http://stackoverflow.com/questions/4785933/adding-rmysql-package-to-r-fails, 
 namely:

     1. Install latest RTools from 
 http://cran.r-project.org/bin/windows/Rtools/
     2. install MySQL or header and library files of mysql
     3. create or edit file C:\Program Files\R\R-2.15\etc\Renviron.site 
 and add line like MYSQL_HOME=C:/mysql (path to your mysql files)
     4. copy libmysql.lib from mysql/lib to mysql/lib/opt to meet 
 dependencies.
     5. copy libmysql.dll to C:\Program Files\R\R-2.15\bin directory.
     6. run install.packages('RMySQL',type='source') and wait while 
 compilation will end.

 install.packages('RMySQL', type = 'source')
 --- Please select a CRAN mirror for use in this session ---
 trying URL 'http://cran.ma.imperial.ac.uk/src/contrib/RMySQL_0.9-3.tar.gz'
 Content type 'application/x-gzip' length 165363 bytes (161 Kb)
 opened URL
 downloaded 161 Kb

 * installing *source* package 'RMySQL' ...
 ** package 'RMySQL' successfully unpacked and MD5 sums checked
 checking for $MYSQL_HOME... D:/MySQL/forR55
 ** libs
 Warning: this package has a non-empty 'configure.win' file,
 so building only the main architecture

 gcc -m64 -ID:/BenSave/R/R-215~1.0/include -DNDEBUG 
 -ID:/MySQL/forR55/include    
 -Id:/RCompile/CRANpkg/extralibs64/local/include     -O2 -Wall  
 -std=gnu99 -mtune=core2 -c RS-DBI.c -o RS-DBI.o
 RS-DBI.c:1:0: sorry, unimplemented: 64-bit mode not compiled in
 make: *** [RS-DBI.o] Error 1
 ERROR: compilation failed for package 'RMySQL'
 * removing 'D:/BenSave/R/R-2.15.0/library/RMySQL'

 The downloaded source packages are in
         
 ‘C:\Users\Bvinsonneau\TempFolder\RtmpwPJoVe\downloaded_packages’
 Warning messages:
 1: running command 'D:/BenSave/R/R-2.15.0/bin/x64/R CMD INSTALL -l 
 D:/BenSave/R/R-2.15.0/library   
 C:\Users\BenSave\TempFolder\RtmpwPJoVe/downloaded_packages/RMySQL_0.9-3.tar.gz'
  had status 1
 2: In install.packages(RMySQL, type = source) :
   installation of package ‘RMySQL’ had non-zero exit status




 I seems to have the same error than the reporter on

 http://r.789695.n4.nabble.com/Installing-RMySQL-64-bit-Windows-7-td4466352.html
 and Prof Brian Ripley suggests that the reporter should re-read the the 
 instructions in 'R Installation and
 Administration'. I did so but no luck. I am not sure what I am missing.Â

 Does anyone have a suggestion?

 Regards,

 Ben
     [[alternative HTML version deleted]]




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



[[alternative HTML version deleted]]

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


Re: [R] Compiling RMySQL on Win7 64bits RS-DBI.c:1:0: sorry, unimplemented: 64-bit mode not compiled in

2012-04-24 Thread Ben Rhelp
Thank you very much Uwe for pointing me in the right direction.

The solution is to specify the path as: 
D:\BenSave\Rtools\bin;D:\BenSave\Rtools\gcc-4.6.3\bin;D:\BenSave\Rtools\MinGW\bin;D:\BenSave\R\R-2.15.0\bin;

the reason is in Rtools\MinGW\bin there is a gcc.exe which does not seems to 
work in this case. It is selected first if D:\BenSave\Rtools\MinGW\bin is in 
front of D:\BenSave\Rtools\gcc-4.6.3\bin.
The folder gcc-4.6.3\bin has the required gcc.exe to compile RMySQL.

I just checked again the R-admin page at:

http://cran.r-project.org/doc/manuals/R-admin.html#The-Windows-toolset
and it is indeed noted in the example of the PATH:

For example for a 32-bit build, all on one line, 
PATH=c:\Rtools\bin;c:\Rtools\gcc-4.6.3\bin;c:\MiKTeX\miktex\bin; 
c:\R\R-2.15\bin\i386;c:\windows;c:\windows\system32 

My fault. Sorry, I only realised my mistake too late.

Best regards,

Ben





 From: Uwe Ligges lig...@statistik.tu-dortmund.de
To: Ben Rhelp benrh...@yahoo.co.uk 
Cc: r-help@r-project.org r-help@r-project.org 
Sent: Tuesday, 24 April 2012, 19:30
Subject: Re: [R] Compiling RMySQL on Win7 64bits RS-DBI.c:1:0: sorry, 
unimplemented: 64-bit mode not compiled in
 


On 24.04.2012 20:13, Ben Rhelp wrote:
 Hi Uwe,

 I tried removing D:\BenSave\Rtools\MinGW64\bin (and replacing it with 
 D:\BenSave\Rtools\MinGW\bin) but the result is the same.

 If I try to run install.packages('RMySQL', type = 'source') on my R 32bits 
 instance I get the following which seems to be due to having a MySQL server 
 64bits as expected.

 any other suggestions?

Yes, do not replace but delete that part, you have gcc-4.6.3 in your 
path which should be sufficient.
I do not know if it is possible to compile RMySQL afterwards (untested, 
and it depends on the MySQL you are linking against.

best,
Uwe Ligges



 thanks in advance,

 Ben


 install.packages('RMySQL', type = 'source')
 --- Please select a CRAN mirror for use in this session ---
 trying URL 'http://cran.ma.imperial.ac.uk/src/contrib/RMySQL_0.9-3.tar.gz'
 Content type 'application/x-gzip' length 165363 bytes (161 Kb)
 opened URL
 downloaded 161 Kb

 * installing *source* package 'RMySQL' ...
 ** package 'RMySQL' successfully unpacked and MD5 sums checked
 checking for $MYSQL_HOME... D:/MySQL/forR55
 ** libs
 Warning: this package has a non-empty 'configure.win' file,
 so building only the main architecture

 gcc  -ID:/BenSave/R/R-215~1.0/include -DNDEBUG 
 -ID:/MySQL/forR55/include         -O3 -Wall  -std=gnu99 -mtune=core2 
 -c RS-DBI.c -o RS-DBI.o
 gcc  -ID:/BenSave/R/R-215~1.0/include -DNDEBUG 
 -ID:/MySQL/forR55/include         -O3 -Wall  -std=gnu99 -mtune=core2 
 -c RS-MySQL.c -o RS-MySQL.o
 gcc -shared -s -static-libgcc -o RMySQL.dll tmp.def RS-DBI.o RS-MySQL.o 
 D:/MySQL/forR55/lib/opt/libmysql.lib -LD:/BenSave/R/R-215~1.0/bin/i386 -lR
 RS-MySQL.o:RS-MySQL.c:(.text+0xba): undefined reference to 
 `mysql_more_results@4'
 RS-MySQL.o:RS-MySQL.c:(.text+0x352): undefined reference to `mysql_init@4'
 RS-MySQL.o:RS-MySQL.c:(.text+0x36f): undefined reference to 
 `mysql_options@12'
 RS-MySQL.o:RS-MySQL.c:(.text+0x38d): undefined reference to 
 `mysql_options@12'
 RS-MySQL.o:RS-MySQL.c:(.text+0x3ab): undefined reference to 
 `mysql_options@12'
 RS-MySQL.o:RS-MySQL.c:(.text+0x3e6): undefined reference to 
 `mysql_real_connect@32'
 RS-MySQL.o:RS-MySQL.c:(.text+0x44a): undefined reference to `mysql_close@4'
 RS-MySQL.o:RS-MySQL.c:(.text+0x5b8): undefined reference to `mysql_error@4'
 RS-MySQL.o:RS-MySQL.c:(.text+0x9c4): undefined reference to `mysql_close@4'
 RS-MySQL.o:RS-MySQL.c:(.text+0xa3d): undefined reference to 
 `mysql_fetch_fields@4'
 RS-MySQL.o:RS-MySQL.c:(.text+0xa55): undefined reference to 
 `mysql_field_count@4'
 RS-MySQL.o:RS-MySQL.c:(.text+0xd5b): undefined reference to 
 `mysql_next_result@4'
 RS-MySQL.o:RS-MySQL.c:(.text+0xd85): undefined reference to 
 `mysql_use_result@4'
 RS-MySQL.o:RS-MySQL.c:(.text+0xd93): undefined reference to 
 `mysql_field_count@4'
 RS-MySQL.o:RS-MySQL.c:(.text+0xe7b): undefined reference to 
 `mysql_affected_rows@4'
 RS-MySQL.o:RS-MySQL.c:(.text+0xf56): undefined reference to 
 `mysql_fetch_row@4'
 RS-MySQL.o:RS-MySQL.c:(.text+0xf73): undefined reference to 
 `mysql_free_result@4'
 RS-MySQL.o:RS-MySQL.c:(.text+0xfd7): undefined reference to `mysql_query@8'
 RS-MySQL.o:RS-MySQL.c:(.text+0xfea): undefined reference to 
 `mysql_use_result@4'
 RS-MySQL.o:RS-MySQL.c:(.text+0xffb): undefined reference to 
 `mysql_field_count@4'
 RS-MySQL.o:RS-MySQL.c:(.text+0x109d): undefined reference to `mysql_error@4'
 RS-MySQL.o:RS-MySQL.c:(.text+0x1146): undefined reference to 
 `mysql_affected_rows@4'
 RS-MySQL.o:RS-MySQL.c:(.text+0x12bd): undefined reference to 
 `mysql_fetch_row@4'
 RS-MySQL.o:RS-MySQL.c:(.text+0x12d8): undefined reference to 
 `mysql_fetch_lengths@4'
 RS-MySQL.o:RS-MySQL.c:(.text+0x154f): undefined reference to `mysql_errno@4'
 RS-MySQL.o:RS-MySQL.c:(.text+0x16e4): undefined

Re: [R] Porting unmaintained packages to post R 2.10.0 era

2011-06-17 Thread Ben Rhelp
- Original Message 

 From: Uwe Ligges lig...@statistik.tu-dortmund.de
 To: Ben Rhelp benrh...@yahoo.co.uk
 Cc: r-help@r-project.org
 Sent: Thu, 16 June, 2011 14:38:12
 Subject: Re: [R] Porting unmaintained packages to post R 2.10.0 era
 
[...]
 
  What about --binary is  deprecated? What is the correct way now?
 
 See the manual. It tells  you
 
 R CMD INSTALL --build
 
 will generate a binary  package.

Hi Uwe,

Thanks a lot for this. I hope Google will rank your reply because it seems I am 
not the only one to make this mistake:

http://www.biostat.wisc.edu/~kbroman/Rintro/Rwinpack.html
http://robjhyndman.com/researchtips/building-r-packages-for-windows/
http://stevemosher.wordpress.com/step-10-build/

Cheers,

Ben

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Porting unmaintained packages to post R 2.10.0 era

2011-06-17 Thread Ben Rhelp
Hi Prof Brian,

Thank you for your email and for writing MASS. This book is brilliant.


- Original Message 
 From: Prof Brian Ripley rip...@stats.ox.ac.uk
 To: Ben Rhelp benrh...@yahoo.co.uk
 Cc: r-help@r-project.org
 Sent: Thu, 16 June, 2011 14:48:00
 Subject: Re: [R] Porting unmaintained packages to post R 2.10.0 era
 
 On Thu, 16 Jun 2011, Mr Rhelp wrote:
 
[...]
 
 Sounds  like you are doing this on Windows (please do tell us!) and trying to 
start with  a Windows binary package.
 

Yes, sorry about that:
 version
   _
platform   x86_64-pc-mingw32
arch   x86_64   
os mingw32  
system x86_64, mingw32  
status  
major  2
minor  13.0 
year   2011 
month  04   
day13   
svn rev55427
language   R
version.string R version 2.13.0 (2011-04-13)

[...]

  Is there a HOWTO/porting  guide for packages pre R 2.10.0 to post R 2.10.0?
 
 You don't need  one.  You start with the package sources, and install those.  
If you  don't have the sources, you ask the author for the sources.  But on 
the  
page you mention, I see
 
 'unix/macs use the  *.tar.gz  version'
 
 by which they mean 'the source package'.
 
 (Note that for  GPLed packages such as this one, the sources must be made  
available.)
 
 There are some errors in the format of the Rd files, but both  packages 
 install 
in R 2.13.0.  However, you are supposed to get Java  components from a site 
which no longer exists, so I think you are going to need  to ask the author 
for 
help.
 
 One advantage of recent R is that to install  packages like these from the 
sources you just need R, so there is no reason to  distribute Windows binary 
packages (for such packages, with no C/C++/Fortran  code).
 

Ok, my thinking was completely wrong. Your response help me to get things 
working. I have updated the packages to work with the latest version of the 
third party software (SoNIA) and I have contacted the original author with the 
aim to distribute some updated versions of the packages.
[...]

Thanks a lot again for your help.

Best regards,

Ben


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Porting unmaintained packages to post R 2.10.0 era

2011-06-16 Thread Ben Rhelp
Hi all,

I am trying to re-compile some unmaintained (it seems) packages, namely 
rSoNIA 
and dynamicnetwork from:
http://csde.washington.edu/~skyebend/rsonia/rsoniaDemo/ 
These packages predates R 2.10.0 so they need to be recompile.

After split the single big file in /man in each packages into a file  for each 
function + some minor fix,  I successfully manage to recompile and load the 
packages

C:\BenSave\R\BuildRPackageR CMD build --binary dynamicnetwork
--binary is deprecated
* checking for file 'dynamicnetwork/DESCRIPTION' ... OK
* preparing 'dynamicnetwork':
* checking DESCRIPTION meta-information ... OK
* checking whether 'INDEX' is up-to-date ... OK
* checking for LF line-endings in source and make files
* checking for empty or unneeded directories
* building binary distribution
* installing *source* package 'dynamicnetwork' ...
** help
*** installing help indices
** building package indices ...
** testing if installed package can be loaded
 Classes for Relational Data
Version  1.6 created on  January 28, 2011.
copyright (c) 2005, Carter T. Butts, University of California-Irvine
Mark S. Handcock, University of Washington
David R. Hunter, Penn State University
Martina Morris, University of Washington
For citation information, type citation(network).
Type help(network-package) to get started.
* MD5 sums
packaged installation of 'dynamicnetwork' as dynamicnetwork_0.0-4.zip

* DONE (dynamicnetwork)

I then tried to run the main example, but it seems no function has been built 
(The help for these function is working for some reason).

fauxDyn - as.dynamic(fauxSim20, check.renewal=FALSE); 

Error: could not find function as.dynamic 

launchSonia(fauxDyn); 

Error: could not find function launchSonia 



Is there a HOWTO/porting guide for packages pre R 2.10.0 to post R 2.10.0?

I have tried googling for it but I must be looking at the wrong place.

What about --binary is deprecated? What is the correct way now?

Thanks in advance,

Ben


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Compiling Rgraphiz on Windows 7 64bit with R-2.13.0

2011-05-07 Thread Ben Rhelp
Hi Martin,

Thanks a lot for your help. this was spot on. With your instructions, I manage 
to successfully compile Rgraphiz.

thanks again.

regards,

Ben



- Original Message 
 From: Martin Morgan mtmor...@fhcrc.org
 To: Ben Rhelp benrh...@yahoo.co.uk
 Cc: r-help@r-project.org
 Sent: Wed, 4 May, 2011 1:01:35
 Subject: Re: [R] Compiling Rgraphiz on Windows 7 64bit with R-2.13.0
 
 On 05/03/2011 03:23 PM, Ben Rhelp wrote:
  Hi all,
 
  I am  trying to compile Rgraphiz on Windows 7 64bit with R-2.13.0. I have
   installed
 
  Rtools213.exe from [1]. The 64bit packages in [2]  provided me with the 64 
bit
  version
  of graphviz. After intalling  the binary version Rgraphviz 1.30 (in 32bit) 
it
  complains  (as
 
  expected) that:
  library(Rgraphviz)
   Error: package 'Rgraphviz' is not installed for 'arch=x64'
 
  I  don't understand why the 64 bit version of graphiz is provided but not 
  one  
for
  Rgraphviz.
  Have I missed it somewhere? In any case, it is  suggested to build it from
  source, so I tried
  following the  steps of the README from the source package of Rgraphviz (see
  below). I  have the
  same error than in [3]. Does anyone know what is going on or if  Kasper 
  found 
a
  solution back
 
  in 2009?
 
   thanks in advance,
 
  Cheers,
 
   Ben
 
 
  C:\BenSaveR --arch x64 CMD build --binary  .\Rgraphviz
  --binary is deprecated
  * checking for file  '.\Rgraphviz/DESCRIPTION' ... OK
  * preparing 'Rgraphviz':
  *  checking DESCRIPTION meta-information ... OK
  * cleaning src
  *  installing the package to re-build vignettes
  ---
  * installing *source* package  'Rgraphviz' ...
  Using the following environment variables
   GRAPHVIZ_INSTALL_DIR=C:\/BenSave\/GoodiesWin64\/graphviz
   GRAPHVIZ_INSTALL_MAJOR=2
  GRAPHVIZ_INSTALL_MINOR=20
   GRAPHVIZ_INSTALL_SUBMINOR=3
 
 These should be set to match the version of  the graphviz library you're 
 using, MINOR=25  SUBMINOR=20090912.0445
 
  Using the following compilation and linking  flags for Rgraphviz
   PKG_CPPFLAGS=-IC:\/BenSave\/GoodiesWin64\/graphviz/include/graphviz
   PKG_LIBS=-LC:\/BenSave\/GoodiesWin64\/graphviz/bin -lgvc-4 -lgraph-4  
-lcdt-4
 
 Unfortunately, these will now be incorrect; edit  Rgraphviz/configure.win 
 so that the line that includes
 
test  ${GRAPHVIZ_INSTALL_MINOR} -eq 21
 
 reads
 
test  ${GRAPHVIZ_INSTALL_MINOR} -ge 21
 
 Martin
 
 
   GVIZ_DEFS=-DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=20 -DWin32
  Created file  src/Makevars.win
  Created file R/graphviz_build_version.R
  **  libs
  cygwin warning:
 MS-DOS style path detected:  C:/PROGRA~1/R/R-213~1.0/etc/x64/Makeconf
 Preferred POSIX  equivalent is: 
/cygdrive/c/PROGRA~1/R/R-213~1.0/etc/x64/Makeco
   nf
 CYGWIN environment variable option nodosfilewarning  turns off this 
warning.
 Consult the user's guide for more  details about POSIX paths:
   http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
   x86_64-w64-mingw32-gcc -IC:/PROGRA~1/R/R-213~1.0/include  
-IC:/BenSave/GoodiesW
  in64/graphviz/include/graphviz -DGRAPHVIZ_MAJOR=2  -DGRAPHVIZ_MINOR=20 
-DWin32
 -O2 -Wall   -std=gnu99 -c LL_funcs.c -o LL_funcs.o
  x86_64-w64-mingw32-gcc  -IC:/PROGRA~1/R/R-213~1.0/include 
-IC:/BenSave/GoodiesW
   in64/graphviz/include/graphviz -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=20  
-DWin32
 -O2 -Wall  -std=gnu99 -c  Rgraphviz.c -o Rgraphviz.o
  x86_64-w64-mingw32-gcc  -IC:/PROGRA~1/R/R-213~1.0/include 
-IC:/BenSave/GoodiesW
   in64/graphviz/include/graphviz -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=20  
-DWin32
 -O2 -Wall  -std=gnu99 -c  RgraphvizInit.c -o RgraphvizInit.o
  x86_64-w64-mingw32-gcc  -IC:/PROGRA~1/R/R-213~1.0/include 
-IC:/BenSave/GoodiesW
   in64/graphviz/include/graphviz -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=20  
-DWin32
 -O2 -Wall  -std=gnu99 -c  agopen.c -o agopen.o
  x86_64-w64-mingw32-gcc  -IC:/PROGRA~1/R/R-213~1.0/include 
-IC:/BenSave/GoodiesW
   in64/graphviz/include/graphviz -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=20  
-DWin32
 -O2 -Wall  -std=gnu99 -c  agread.c -o agread.o
  x86_64-w64-mingw32-gcc  -IC:/PROGRA~1/R/R-213~1.0/include 
-IC:/BenSave/GoodiesW
   in64/graphviz/include/graphviz -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=20  
-DWin32
 -O2 -Wall  -std=gnu99 -c  agwrite.c -o agwrite.o
  x86_64-w64-mingw32-gcc  -IC:/PROGRA~1/R/R-213~1.0/include 
-IC:/BenSave/GoodiesW
   in64/graphviz/include/graphviz -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=20  
-DWin32
 -O2 -Wall  -std=gnu99 -c  bezier.c -o bezier.o
  x86_64-w64-mingw32-gcc  -IC:/PROGRA~1/R/R-213~1.0/include 
-IC:/BenSave/GoodiesW
   in64/graphviz/include/graphviz -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=20  
-DWin32
 -O2 -Wall  -std=gnu99 -c  buildEdgeList.c -o buildEdgeList.o
  x86_64-w64-mingw32-gcc  -IC:/PROGRA~1/R/R-213~1.0/include 
-IC:/BenSave/GoodiesW
   in64/graphviz/include/graphviz -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=20  
-DWin32
 -O2 -Wall  -std

[R] Compiling Rgraphiz on Windows 7 64bit with R-2.13.0

2011-05-03 Thread Ben Rhelp
Hi all,

I am trying to compile Rgraphiz on Windows 7 64bit with R-2.13.0. I have 
installed 

Rtools213.exe from [1]. The 64bit packages in [2] provided me with the 64 bit 
version
of graphviz. After intalling the binary version Rgraphviz 1.30 (in 32bit) it 
complains (as 

expected) that:
 library(Rgraphviz)
Error: package 'Rgraphviz' is not installed for 'arch=x64'

I don't understand why the 64 bit version of graphiz is provided but not one 
for 
Rgraphviz.
Have I missed it somewhere? In any case, it is suggested to build it from 
source, so I tried
following the steps of the README from the source package of Rgraphviz (see 
below). I have the
same error than in [3]. Does anyone know what is going on or if Kasper found a 
solution back 

in 2009?

thanks in advance,

Cheers,

Ben


C:\BenSaveR --arch x64 CMD build --binary .\Rgraphviz
--binary is deprecated
* checking for file '.\Rgraphviz/DESCRIPTION' ... OK
* preparing 'Rgraphviz':
* checking DESCRIPTION meta-information ... OK
* cleaning src
* installing the package to re-build vignettes
  ---
* installing *source* package 'Rgraphviz' ...
Using the following environment variables
GRAPHVIZ_INSTALL_DIR=C:\/BenSave\/GoodiesWin64\/graphviz
GRAPHVIZ_INSTALL_MAJOR=2
GRAPHVIZ_INSTALL_MINOR=20
GRAPHVIZ_INSTALL_SUBMINOR=3
Using the following compilation and linking flags for Rgraphviz
   PKG_CPPFLAGS=-IC:\/BenSave\/GoodiesWin64\/graphviz/include/graphviz
   PKG_LIBS=-LC:\/BenSave\/GoodiesWin64\/graphviz/bin -lgvc-4 -lgraph-4 -lcdt-4
   GVIZ_DEFS=-DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=20 -DWin32
Created file src/Makevars.win
Created file R/graphviz_build_version.R
** libs
cygwin warning:
  MS-DOS style path detected: C:/PROGRA~1/R/R-213~1.0/etc/x64/Makeconf
  Preferred POSIX equivalent is: /cygdrive/c/PROGRA~1/R/R-213~1.0/etc/x64/Makeco
nf
  CYGWIN environment variable option nodosfilewarning turns off this warning.
  Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
x86_64-w64-mingw32-gcc -IC:/PROGRA~1/R/R-213~1.0/include -IC:/BenSave/GoodiesW
in64/graphviz/include/graphviz -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=20 -DWin32
  -O2 -Wall  -std=gnu99 -c LL_funcs.c -o LL_funcs.o
x86_64-w64-mingw32-gcc -IC:/PROGRA~1/R/R-213~1.0/include -IC:/BenSave/GoodiesW
in64/graphviz/include/graphviz -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=20 -DWin32
  -O2 -Wall  -std=gnu99 -c Rgraphviz.c -o Rgraphviz.o
x86_64-w64-mingw32-gcc -IC:/PROGRA~1/R/R-213~1.0/include -IC:/BenSave/GoodiesW
in64/graphviz/include/graphviz -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=20 -DWin32
  -O2 -Wall  -std=gnu99 -c RgraphvizInit.c -o RgraphvizInit.o
x86_64-w64-mingw32-gcc -IC:/PROGRA~1/R/R-213~1.0/include -IC:/BenSave/GoodiesW
in64/graphviz/include/graphviz -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=20 -DWin32
  -O2 -Wall  -std=gnu99 -c agopen.c -o agopen.o
x86_64-w64-mingw32-gcc -IC:/PROGRA~1/R/R-213~1.0/include -IC:/BenSave/GoodiesW
in64/graphviz/include/graphviz -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=20 -DWin32
  -O2 -Wall  -std=gnu99 -c agread.c -o agread.o
x86_64-w64-mingw32-gcc -IC:/PROGRA~1/R/R-213~1.0/include -IC:/BenSave/GoodiesW
in64/graphviz/include/graphviz -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=20 -DWin32
  -O2 -Wall  -std=gnu99 -c agwrite.c -o agwrite.o
x86_64-w64-mingw32-gcc -IC:/PROGRA~1/R/R-213~1.0/include -IC:/BenSave/GoodiesW
in64/graphviz/include/graphviz -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=20 -DWin32
  -O2 -Wall  -std=gnu99 -c bezier.c -o bezier.o
x86_64-w64-mingw32-gcc -IC:/PROGRA~1/R/R-213~1.0/include -IC:/BenSave/GoodiesW
in64/graphviz/include/graphviz -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=20 -DWin32
  -O2 -Wall  -std=gnu99 -c buildEdgeList.c -o buildEdgeList.o
x86_64-w64-mingw32-gcc -IC:/PROGRA~1/R/R-213~1.0/include -IC:/BenSave/GoodiesW
in64/graphviz/include/graphviz -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=20 -DWin32
  -O2 -Wall  -std=gnu99 -c buildNodeList.c -o buildNodeList.o
x86_64-w64-mingw32-gcc -IC:/PROGRA~1/R/R-213~1.0/include -IC:/BenSave/GoodiesW
in64/graphviz/include/graphviz -DGRAPHVIZ_MAJOR=2 -DGRAPHVIZ_MINOR=20 -DWin32
  -O2 -Wall  -std=gnu99 -c doLayout.c -o doLayout.o
doLayout.c: In function 'getEdgeLocs':
doLayout.c:131:17: error: 'textlabel_t' has no member named 'p'
doLayout.c:132:17: error: 'textlabel_t' has no member named 'p'
doLayout.c: In function 'getNodeLayouts':
doLayout.c:243:13: error: 'textlabel_t' has no member named 'p'
doLayout.c:244:13: error: 'textlabel_t' has no member named 'p'
make: *** [doLayout.o] Error 1
ERROR: compilation failed for package 'Rgraphviz'
* removing 'C:/Users/BVINSO~1/AppData/Local/Temp/Rtmpz6M19V/Rinst76da24d2/Rgraph
viz'
  ---
ERROR: package installation failed




[1] http://www.murdoch-sutherland.com/Rtools/
[2] http://www.stats.ox.ac.uk/pub/Rtools/goodies/Win64No_/
[3] https://stat.ethz.ch/pipermail/bioconductor/2009-March/026585.html



[R] Nnet and AIC: selection of a parsimonious parameterisation

2011-01-05 Thread Ben Rhelp
Hi All,

I am trying to use a neural network for my work, but I am not sure about my 
approach to select a parsimonious model. In R with nnet, the IAC has
not been defined for a feed-forward neural network with a single hidden layer. 
Is this because it does not make sens mathematically in this case?
For example, is this pseudo code sensible?

Thanks in advance for your help. I am sorry if this has been answered before, 
but I haven't found an answer for this in the archive.

Below, I have added an implementation of this idea based on (Modern Applied 
Statistic with S) MASS code of chapter 8.

Cheers,

Ben



Pseudo code


Define RSS as:
RSS = (1-alpha)*RSS(identification set) +  alpha* RSS(validation set)
and AIC as:
AIC = 2*np + N*log(RSS)
where np corresponds to the non-null parameters of the neural network
and N is the sample size (based on 
http://en.wikipedia.org/wiki/Akaike_information_criterion).

Assuming a feed-forward neural network with a single hidden layer and
a maximum number of neurons (maxSize),

For size = 1 to maxSize
Optimise the decay
Select the neural network with the smallest AIC for a given size and decay
  using random starting parameterisation and random identification set
For the lowest to the largest diagonal element of the Hessian,
   Equate the corresponding parameter to 0
   If AIC(i)AIC(i-1), break;

The neural network selected is the one with the smallest AIC.


an example based on cpus data in Chapter 8 of MASS



library(nnet)
library(MASS)

# From Chapter 6, for comparisons
set.seed(123)
cpus.samp -
c(3, 5, 6, 7, 8, 10, 11, 16, 20, 21, 22, 23, 24, 25, 29, 33, 39, 41, 44, 45,
46, 49, 57, 58, 62, 63, 65, 66, 68, 69, 73, 74, 75, 76, 78, 83, 86,
88, 98, 99, 100, 103, 107, 110, 112, 113, 115, 118, 119, 120, 122,
124, 125, 126, 127, 132, 136, 141, 144, 146, 147, 148, 149, 150, 151,
152, 154, 156, 157, 158, 159, 160, 161, 163, 166, 167, 169, 170, 173,
174, 175, 176, 177, 183, 184, 187, 188, 189, 194, 195, 196, 197, 198,
199, 202, 204, 205, 206, 208, 209)


cpus2 - cpus[, 2:8] # excludes names, authors’ predictions
attach(cpus2)
cpus3 - data.frame(syct = syct-2, mmin = mmin-3, mmax = mmax-4, 
cach=cach/256,chmin=chmin/100, chmax=chmax/100, perf)
detach()




CVnn.cpus - function(formula, data = cpus3[cpus.samp, ], maxSize = 10,
decayRange = c(0,0.2), nreps = 5, nifold = 10, alpha= 9/10,
linout = TRUE, skip = TRUE, maxit = 1000,...){
#nreps=number of attempts to fit a nnet model with randomly chosen initial 
parameters
#  The one with the smallest RSS on the training data is then chosen
  nnWtsPrunning -function(nn,data,alpha,i){
truth - log10(data$perf)
RSS=(1-alpha)*sum((truth[ri != i] - predict(nn, data[ri != i,]))^2) + 
alpha* sum((truth[ri == i] - predict(nn, data[ri == i,]))^2)
AIC=2*sum(nn$wts!=0) + length(data$perf)*log(RSS)
nn.tmp=nn
for (j in (1:length(nn$wts))) {
  nn.tmp$wts[order(diag(nn.tmp$Hessian))[j]]=0
  RSS.tmp=(1-alpha)*sum((truth[ri != i] - predict(nn.tmp, data[ri != 
i,]))^2) + 

 alpha* sum((truth[ri == i] - predict(nn.tmp, data[ri == 
i,]))^2)
  AIC.tmp=2*sum(nn.tmp$wts!=0) + length(data$perf)*log(RSS.tmp)  
  if (is.nan(AIC.tmp) || AIC.tmpAIC ) {
  cat('\n  j',j,'AIC'=AIC.tmp,'AIC_1',AIC,'\n')
  break
  } else {
  nn=nn.tmp; AIC=AIC.tmp; RSS=RSS.tmp
  }
}
list(choice=sqrt(RSS/100),nparam=sum(nn$wts!=0),AIC=AIC,nn=nn)
  }

  #Modified function for optimisation
  CVnn1 - function(decay, formula, data, nreps=1, ri, size, linout, skip, 
maxit, optimFlag=FALSE, alpha) {
truth - log10(data$perf)
nn - nnet(formula, data[ri !=1,], trace=FALSE, size=size, linout=linout, 
skip=skip, maxit=maxit, Hess = TRUE)
RSS=(alpha-1)*sum((truth[ri != 1] - predict(nn, data[ri != 1,]))^2) + 
alpha* sum((truth[ri == 1] - predict(nn, data[ri == 1,]))^2)
ii=1
for (i in sort(unique(ri))) {
  for(rep in 1:nreps) {
nn.tmp - nnet(formula, data[ri !=i,], trace=FALSE, size=size, 
linout=linout, skip=skip, maxit=maxit, Hess = TRUE)
RSS.tmp=(alpha-1)*sum((truth[ri != i] - predict(nn.tmp, data[ri != 
i,]))^2) + 

 alpha* sum((truth[ri == i] - predict(nn.tmp, data[ri == 
i,]))^2)
if (RSS.tmpRSS){ RSS=RSS.tmp; nn=nn.tmp; ii=i}
  }
}
if (optimFlag) {
 return(RSS)
}else{
 prn=nnWtsPrunning(nn,data,alpha,ii)

 
list(choice=prn$choice,nparam=prn$nparam,nparaminit=length(nn$wts),AIC=prn$AIC,nn1=prn$nn)

}
  }

  maxSize=maxSize+1; j=1;   
  choice - numeric(maxSize);  nparam - numeric(maxSize);  lambdaj - 
numeric(maxSize)
  AIC - numeric(maxSize);  nparamInit - 

Re: [R] Is there an equivalent to predict(..., type=linear) of a Proportional hazard model for a Cox model instead?

2010-11-26 Thread Ben Rhelp
 Hi Terry, David, and Thomas,
 
Thank you for all your emails and the time you to took to clarify my 
misunderstanding on survival analysis. I will need a bit of time to digest all 
this information and to do some more reading.
 
Best regards,
 
Ben


 From: Terry Therneau
 
 1. survreg() does NOT fit a proportional hazards model, a mistake
 repeated  multiple times in your post
 
 2. The coxph function operates on the risk  scale: large values of Xbeta
 = large death rates = bad
The survreg  operates on the time scale: large values of xbeta =
 longer liftetime =  good.
 
 3. predict(fit, type='risk') = exp(predict(fit, type='linear')) in  a Cox
 model returns an estimate of the relative risk for each subject.   That
 is, his/her predicted death rate as compared to the others in  the
 sample.  It has no units of years or days or anything  else.  The
 predicted survival TIME for a subject is something else  entirely.
 
   predict(fit, type='response') in a survreg model does  give predicted
 survvival times.  
 
   If you really want to  understand the interrelationships of these
 things more deeply I think you  need some textbook time.  Read the book
 by Kalbfleisch and Prentice for  accelerated failure time models, or even
 better Escobar and Meeker which  comes from the industrial reliability
 view.  For predicted survival from  a Cox model see Chapter 10 of
 Therneau and Grambsch.  The answers to  your specific questions would be
 a document rather than an  email.
 
 Terry Therneau
 
 
 




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


Re: [R] Is there an equivalent to predict(..., type=linear) of a Proportional hazard model for a Cox model instead?

2010-11-25 Thread Ben Rhelp
I manage to achieve similar results with a Cox model as follows but I don't 
really understand why we have to take the inverse of the linear prediction with 
the Cox model and why we do not need to divide by the number of days in the 
year 
anymore?

Am I getting a similar result out of pure luck?

thanks in advance,

Ben

# MASS example with the proportional hazard model
par(mfrow = c(1, 2));
(aids.ps - survreg(Surv(survtime + 0.9, status) ~ state + T.categ + 
pspline(age, df=6), data = Aidsp))

zz - predict(aids.ps, data.frame(state = factor(rep(NSW, 83), levels = 
levels(Aidsp$state)),
T.categ = factor(rep(hs, 83), levels = levels(Aidsp$T.categ)), age = 
0:82), se = T, type = linear)
plot(0:82, exp(zz$fit)/365.25, type = l, ylim = c(0, 2), xlab = age, ylab = 
expected lifetime (years))
lines(0:82, exp(zz$fit+1.96*zz$se.fit)/365.25, lty = 3, col = 2)
lines(0:82, exp(zz$fit-1.96*zz$se.fit)/365.25, lty = 3, col = 2)
rug(Aidsp$age + runif(length(Aidsp$age), -0.5, 0.5), ticksize = 0.015)


# same example but with a Cox model instead
(aids.pscp - coxph(Surv(survtime + 0.9, status) ~ state + T.categ + 
pspline(age, df=6), data = Aidsp))
zzcp - predict(aids.pscp, data.frame(state = factor(rep(NSW, 83), levels = 
levels(Aidsp$state)),
T.categ = factor(rep(hs, 83), levels = levels(Aidsp$T.categ)), age = 
0:82), se = T, type = lp)
plot(0:82, 1/exp(zzcp$fit), type = l, ylim = c(0, 2), xlab = age, ylab = 
expected lifetime (years))
lines(0:82, 1/exp(zzcp$fit+1.96*zzcp$se.fit), lty = 3, col = 2)
lines(0:82, 1/exp(zzcp$fit-1.96*zzcp$se.fit), lty = 3, col = 2)
rug(Aidsp$age + runif(length(Aidsp$age), -0.5, 0.5), ticksize = 0.015)




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


Re: [R] Is there an equivalent to predict(..., type=linear) of a Proportional hazard model for a Cox model instead?

2010-11-25 Thread Ben Rhelp
Hi David,

Thank you for your reply. See below for more information.


 From: David Winsemius 
 
 
 On Nov 25, 2010, at 7:27 AM, Ben Rhelp wrote:
 
  I manage to  achieve similar results with a Cox model as follows but I don't
  really  understand why we have to take the inverse of the linear prediction 
with
   the Cox model
 
 Different parameterization. You can find expanded answer(s)  in the archives 
and in the documentation of  survreg.distributions.
 

I understand (i think) the difference in model structures between a Cox (coxph) 
and Proportional hazard model (survreg). 


 
  and why we do not need to divide by the  number of days in the year
  anymore?
 
 Here I'm guessing (since you  don't offer enough evidence to confirm) that 
 the 
difference is in the time  scales used in your Aidsp$survtime versus some 
other 
example to which you are  comparing .

Both models are run from the same data, so I am not expecting any differences 
in 
time scales. 

To get similar results, I need to actually run the following equations:
expected_lifetime_in_years = exp(fit)/365.25--- Linear 
prediction of the Proportional hazard model
expected_lifetime_in_years = 1/exp(fit)--- Linear 
prediction of the Cox model
where fit come from the linear prediction of each models, respectively.

Actually, in the code below, I re-run the models and predictions based on a 
yearly sampling time (instead of daily).
Again, to get similar results, I now need to actually run the following 
equations:
expected_lifetime_in_years = exp(fit)   --- Linear 
prediction of the Proportional hazard model
expected_lifetime_in_years = 1/exp(fit)--- Linear 
prediction of the Cox model

I think I understand the logic behind the results of the proportional hazard 
model, but not for the prediction of the Cox model.

Thank you for your help. I hope this is not a too stupid hole in my logic.

Here is the self contained R code to produce the charts:

library(MASS);
library(survival);

#Same data but parametric fit
make.aidsp - function(){
   cutoff - 10043 # July 1987 in julian days
   btime - pmin(cutoff, Aids2$death) - pmin(cutoff, Aids2$diag)
   atime - pmax(cutoff, Aids2$death) - pmax(cutoff, Aids2$diag)
   survtime - btime + 0.5*atime
   status - as.numeric(Aids2$status)
   data.frame(survtime, status = status - 1, state = Aids2$state,
   T.categ = Aids2$T.categ, age = Aids2$age, sex = Aids2$sex)
}
Aidsp - make.aidsp()

# MASS example with the proportional hazard model
par(mfrow = c(1, 2));
(aids.ps - survreg(Surv(survtime + 0.9, status) ~ state + T.categ + 
pspline(age, df=6), data = Aidsp))
zz - predict(aids.ps, data.frame(state = factor(rep(NSW, 83), levels = 
levels(Aidsp$state)),
T.categ = factor(rep(hs, 83), levels = levels(Aidsp$T.categ)), age = 
0:82), se = T, type = linear)
plot(0:82, exp(zz$fit)/365.25, type = l, ylim = c(0, 2), xlab = age, ylab = 
expected lifetime (years))
lines(0:82, exp(zz$fit+1.96*zz$se.fit)/365.25, lty = 3, col = 2)
lines(0:82, exp(zz$fit-1.96*zz$se.fit)/365.25, lty = 3, col = 2)
rug(Aidsp$age + runif(length(Aidsp$age), -0.5, 0.5), ticksize = 0.015)


# Same example but with a Cox model instead
(aids.pscp - coxph(Surv(survtime + 0.9, status) ~ state + T.categ + 
pspline(age, df=6), data = Aidsp))
zzcp - predict(aids.pscp, data.frame(state = factor(rep(NSW, 83), levels = 
levels(Aidsp$state)),
T.categ = factor(rep(hs, 83), levels = levels(Aidsp$T.categ)), age = 
0:82), se = T, type = lp)
plot(0:82, 1/exp(zzcp$fit), type = l, ylim = c(0, 2), xlab = age, ylab = 
expected lifetime (years))
lines(0:82, 1/exp(zzcp$fit+1.96*zzcp$se.fit), lty = 3, col = 2)
lines(0:82, 1/exp(zzcp$fit-1.96*zzcp$se.fit), lty = 3, col = 2)
rug(Aidsp$age + runif(length(Aidsp$age), -0.5, 0.5), ticksize = 0.015)


# Change the sampling time from daily to yearly
par(mfrow = c(1, 1));
(aids.ps - survreg(Surv((survtime + 0.9)/365.25, status) ~ state + T.categ + 
pspline(age, df=6), data = Aidsp))
zz - predict(aids.ps, data.frame(state = factor(rep(NSW, 83), levels = 
levels(Aidsp$state)),
T.categ = factor(rep(hs, 83), levels = levels(Aidsp$T.categ)), age = 
0:82), se = T, type = linear)
plot(0:82, exp(zz$fit), type = l, ylim = c(0, 2), xlab = age, ylab = 
expected lifetime (years))

(aids.pscp - coxph(Surv((survtime + 0.9)/365.25, status) ~ state + T.categ + 
pspline(age, df=6), data = Aidsp))
zzcp - predict(aids.pscp, data.frame(state = factor(rep(NSW, 83), levels = 
levels(Aidsp$state)),
T.categ = factor(rep(hs, 83), levels = levels(Aidsp$T.categ)), age = 
0:82), se = T, type = lp)
lines(0:82, 1/exp(zzcp$fit),col=4)





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


[R] Is there an equivalent to predict(..., type=linear) of a Proportional hazard model for a Cox model instead?

2010-11-24 Thread Ben Rhelp
Hi all,

Is there an equivalent to predict(...,type=linear) of a Proportional hazard 
model for a Cox model instead?

For example, the Figure 13.12 in MASS (p384) is produced by:

(aids.ps - survreg(Surv(survtime + 0.9, status) ~ state + T.categ + 
pspline(age, df=6), data = Aidsp))

zz - predict(aids.ps, data.frame(state = factor(rep(NSW, 83), levels = 
levels(Aidsp$state)),
T.categ = factor(rep(hs, 83), levels = levels(Aidsp$T.categ)), age = 
0:82), se = T, type = linear)
plot(0:82, exp(zz$fit)/365.25, type = l, ylim = c(0, 2), xlab = age, ylab = 
expected lifetime (years))
lines(0:82, exp(zz$fit+1.96*zz$se.fit)/365.25, lty = 3, col = 2)
lines(0:82, exp(zz$fit-1.96*zz$se.fit)/365.25, lty = 3, col = 2)
rug(Aidsp$age + runif(length(Aidsp$age), -0.5, 0.5), ticksize = 0.015)

Is it possible to achieve something similar with a Cox model instead?

Is there a more detailed explanation of the type option for predict.coxph 
than 
what's in the help of predict.coxph? e.g. type=c(lp, risk, expected, 
terms)

thanks in advance,

Ben





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

2010-07-01 Thread Ben Rhelp
Hi all,

I am looking at the tutorial/appendix from John Fox on “Cox 
Proportional-Hazards Regression for Survival Data” available here:
http://cran.r-project.org/doc/contrib/Fox-Companion/appendix-cox-regression.pdf
I am particularly interested in modelling survival with time-dependent 
covariates (Section 4).
 
The data look like this:
  Rossi.2[1:50,]
start
stop arrest.time week arrest fin age race wexp mar paro prio educ employed
0 1 0 20 1 0 27 1 0 0 1 3 3 0
1 2 0 20 1 0 27 1 0 0 1 3 3 0
...
18 19 0 20 1 0 27 1 0 0 1 3 3 0
19 20 1 20 1 0 27 1 0 0 1 3 3 0
0 1 0 17 1 0 18 1 0 0 1 8 4 0
1 2 0 17 1 0 18 1 0 0 1 8 4 0
...
15 16 0 17 1 0 18 1 0 0 1 8 4 0
16 17 1 17 1 0 18 1 0 0 1 8 4 0
0 1 0 25 1 0 19 0 1 0 1 13 3 0
1 2 0 25 1 0 19 0 1 0 1 13 3 0
...
3.13 12 13 0 25 1 0 19
0 1 0 1 13 3 0
 
John suggests the following model:
mod.allison.2 - coxph(Surv(start, stop, arrest.time) ~
+ fin + age + race + wexp + mar + paro + prio + employed,
+ data=Rossi.2)
 1-Would informing the algorithm coxph which samples represents the same person 
(through the use of an Id for example) improve the “efficiency” of the 
estimated model? And if so, how should i do that? Using strata()?
 
2- He later suggests “accommodating non-proportional hazards by building 
interactions between covariates and time into the Cox regression model” as 
follows:
 
mod.allison.5
- coxph(Surv(start, stop, arrest.time) ~
+   fin + age + age:stop + prio,
+   data=Rossi.2)
 
I have read quite a lot of documentation to understand the meaning of “age + 
age:stop” in the formula, but I am unsure of what it means. If I wanted to  
visualise these variables which are entering the model, would it be something 
like:
data.frame(Rossi.2$age,Rossi.2$age %in% Rossi.2$stop)
 
I hope this make sense. Thanks for your help,
Ben




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