    * Weibull Fitting to Cox Regression.sps.
    * Written by PSKL on 21/05/03.

    GET DATA /TYPE=XLS
       /FILE='H:\documents\PhD\Full Longitudinal\Cox Regression Survival.xls'
       /SHEET=name 'Sheet1'
       /CELLRANGE=full
       /READNAMES=on .

    save outfile= 'd:\temp1.sav'
     /keep time survival.

    get file=  'd:\temp1.sav'.

    * Check log-cumulative hazard plot for linearity.

    Compute LLS=ln(-ln( survival)).
    compute Ltime=ln(time).

    GRAPH
      /SCATTERPLOT(BIVAR)=Ltime WITH LLS
      /MISSING=LISTWISE
      /TITLE= 'Log Cumulative Hazard Plot '.

# Graph

Notes
Output Created | 21-MAY-2003 18:25:35
Comments |
Input | Data | d:\temp1.sav
Filter | <none>
Weight | <none>
Split File | <none>
N of Rows in Working Data File | 3764
Syntax | GRAPH /SCATTERPLOT(BIVAR)=Ltime WITH LLS /MISSING=LISTWISE /TITLE= 'Log Cumulative Hazard Plot '.
Resources | Elapsed Time | 0:00:00.18

    * Weibull fitting, with starting values derived from overall plot.

    * NonLinear Regression.
    MODEL PROGRAM LAMBDA=0.0000454 GAMMA=1 .
    COMPUTE Weipred = exp(-lambda*time**gamma).
    NLR survival
      /PRED WEIPRED
      /SAVE PRED RESID
      /CRITERIA SSCONVERGENCE 1E-9 PCON 1E-9 .

# Non-linear Regression

Notes
Output Created | 21-MAY-2003 18:25:36
Comments |
Input | Data | d:\temp1.sav
Filter | <none>
Weight | <none>
Split File | <none>
N of Rows in Working Data File | 3764
Syntax | MODEL PROGRAM LAMBDA=0.0000454 GAMMA=1 . COMPUTE Weipred = exp(-lambda*time**gamma). NLR survival /PRED WEIPRED /SAVE PRED RESID /CRITERIA SSCONVERGENCE 1E-9 PCON 1E-9 .
Resources | Elapsed Time | 0:00:01.92

    All the derivatives will be calculated numerically.

    The following new variables are being created:

    Name          Label

    WEIPRED       Predicted Values
    RESID         Residuals

     Iteration  Residual SS      LAMBDA       GAMMA

         1      412.1269358  .000045400  1.00000000
         1.1    672.9363194  .000795523  -.61988490
         1.2    604.8898884  .000380342  .538556458
         1.3    3.171811649  .000198129  1.04546895
         2      3.171811649  .000198129  1.04546895
         2.1    49.99267769  .000442051  .885199603
         2.2    2.737176386  .000221700  1.02851242
         3      2.737176386  .000221700  1.02851242
         3.1    2.252128005  .000273055  .999452263
         4      2.252128005  .000273055  .999452263
         4.1    1.702245112  .000328373  .976324586
         5      1.702245112  .000328373  .976324586
         5.1    1.666413371  .000441317  .934344826
         6      1.666413371  .000441317  .934344826
         6.1    .7418645929  .000501598  .922967769
         7      .7418645929  .000501598  .922967769
         7.1    .6012124609  .000620164  .893578802
         8      .6012124609  .000620164  .893578802
         8.1    .3317988728  .000740928  .871564909
         9      .3317988728  .000740928  .871564909
         9.1    .2000497401  .000862360  .852558894
        10      .2000497401  .000862360  .852558894
        10.1    .1493013321  .000984233  .835850907
        11      .1493013321  .000984233  .835850907
        11.1    .1220508864  .001008520  .833833721
        12      .1220508864  .001008520  .833833721
        12.1    .1220219191  .001007569  .833993599
        13      .1220219191  .001007569  .833993599
        13.1    .1220219185  .001007585  .833991713
        14      .1220219185  .001007585  .833991713
        14.1    .1220219185  .001007584  .833991774

    Run stopped after 31 model evaluations and 14 derivative evaluations.
    Iterations have been stopped because the relative reduction between successive
    residual sums of squares is at most SSCON = 1.000E-09

    Nonlinear Regression Summary Statistics     Dependent Variable SURVIVAL

      Source                 DF  Sum of Squares  Mean Square

      Regression              2     1520.60774      760.30387
      Residual             3762         .12202   3.243539E-05
      Uncorrected Total    3764     1520.72976

      (Corrected Total)    3763      108.10777

      R squared = 1 - Residual SS / Corrected SS =     .99887

                                               Asymptotic 95 %
                              Asymptotic     Confidence Interval
      Parameter   Estimate    Std. Error     Lower         Upper

      LAMBDA      .001007584  5.07795E-06   .000997628   .001017540
      GAMMA       .833991774   .000653264   .832710987   .835272560

      Asymptotic Correlation Matrix of the Parameter Estimates

                  LAMBDA     GAMMA

      LAMBDA      1.0000    -.9980
      GAMMA       -.9980    1.0000

    GRAPH
      /SCATTERPLOT(OVERLAY)=time time  WITH survival weipred (PAIR)
      /MISSING=LISTWISE .

# Graph

Notes
Output Created | 21-MAY-2003 18:25:37
Comments |
Input | Data | d:\temp1.sav
Filter | <none>
Weight | <none>
Split File | <none>
N of Rows in Working Data File | 3764
Syntax | GRAPH /SCATTERPLOT(OVERLAY)=time time WITH survival weipred (PAIR) /MISSING=LISTWISE .
Resources | Elapsed Time | 0:00:00.09

    SAVE TRANSLATE OUTFILE='I:\Research Projects\Longevity\Weibull Fitting to Cox Regression.xls'
      /TYPE=XLS /MAP /REPLACE /FIELDNAMES.

    Data written to I:\Research Projects\Longevity\Weibull Fitting to Cox Regression.xls.
    6 variables and 3764 cases written to range: SPSS.
    Variable: TIME       Type: Number   Width: 11   Dec: 0
    Variable: SURVIVAL   Type: Number   Width: 11   Dec: 5

    Variable: LLS        Type: Number   Width:  8   Dec: 2
    Variable: LTIME      Type: Number   Width:  8   Dec: 2
    Variable: WEIPRED    Type: Number   Width:  8   Dec: 2
    Variable: RESID      Type: Number   Width:  8   Dec: 2