SPSS Statistics

SPSS Statistics

Your hub for statistical analysis, data management, and data documentation. Connect, learn, and share with your peers! 

 View Only
Expand all | Collapse all

How to operate STATS COMPRISK

Community Support Admin

Community Support AdminSat May 22, 2021 07:16 PMBest Answer

  • 1.  How to operate STATS COMPRISK

    Posted Thu May 20, 2021 05:22 AM

    I'v downloaded STATS COMPRISK extension. the first time i run it i got the message "The first word in the line is not recognized as an SPSS Statistics command". I tried to delete the first line or add BEGIN PROGRAM R. but it didnt worked ( the message the first line...disapeared). how could i operate the command?






    #SPSSStatistics
    #Support
    #SupportMigration


  • 2.  RE: How to operate STATS COMPRISK
    Best Answer

    Posted Thu May 20, 2021 12:53 PM

    That message means that STATS COMPRISK was not installed. Did you install it or just download? If you installed it, you should have seen a message in the Viewer about the outcome of the install.

    In some situations, for security reasons, you need to start Statistics using Run as Administrator or equivalent on Mac for the install to be successful.






    #SPSSStatistics
    #Support
    #SupportMigration


  • 3.  RE: How to operate STATS COMPRISK
    Best Answer

    Posted Fri May 21, 2021 04:07 PM

    Thank you.

    I tried to run the command and got:

    "The R cmprsk package is required but could not be loaded."

    I downloaded the cmprsk package for R and insalled it and the same for SPSS. What can I do?

    Thank you






    #SPSSStatistics
    #Support
    #SupportMigration


  • 4.  RE: How to operate STATS COMPRISK
    Best Answer

    Posted Fri May 21, 2021 04:26 PM

    Well, that is progress, since STATS COMPRISK at least started executing.

    My guess is that the cmprsk package might have been installed in a different version of R from the one Statistics is using on your system.

    Try running this code after starting Statistics as Administrator

    begin program r.

    install.packages("cmprsk")

    end program.

    The cmprsk package depends on the survival package. That should be installed automatically along with cmprsk, but if it isn't (try library(survival)), you can use install.packages to add it.






    #SPSSStatistics
    #Support
    #SupportMigration


  • 5.  RE: How to operate STATS COMPRISK
    Best Answer

    Posted Sat May 22, 2021 06:58 PM

    Thanks.

    I tried to run the code :"

    begin program r.

    install.packages("cmprsk")

    end program."

    and got:

    >Error # 1. Command name: end

    >The first word in the line is not recognized as an SPSS Statistics command.

    >Execution of this command stops

    What should I do?

    Thank you!






    #SPSSStatistics
    #Support
    #SupportMigration


  • 6.  RE: How to operate STATS COMPRISK
    Best Answer

    Posted Sat May 22, 2021 07:16 PM

    I also notice that the 'R' in the first line does not highlight like the rest.

    Thanks!






    #SPSSStatistics
    #Support
    #SupportMigration


  • 7.  RE: How to operate STATS COMPRISK
    Best Answer

    Posted Sat May 22, 2021 07:41 PM

    The r in begin program r. won't highlight like the command name as it is a parameter value.

    However, the error message indicates that the program did not get into R mode. Be sure that you highlight everything from begin to end program before running it (or use Run > All).


    If the R code actually runs, you will be prompted to pick a CRAN site from a list that pops up.






    #SPSSStatistics
    #Support
    #SupportMigration


  • 8.  RE: How to operate STATS COMPRISK
    Best Answer

    Posted Sat May 22, 2021 07:49 PM

    Thank you!

    I tried it and picked a CRAN site. Whats next?






    #SPSSStatistics
    #Support
    #SupportMigration


  • 9.  RE: How to operate STATS COMPRISK
    Best Answer

    Posted Sat May 22, 2021 08:36 PM

    It should have then installed the cmprsk module, and you should be able to run your command. However, if it didn't also installed the survival module that cmprsk needs, you will have to run the install.packages program for that one.






    #SPSSStatistics
    #Support
    #SupportMigration


  • 10.  RE: How to operate STATS COMPRISK
    Best Answer

    Posted Sat May 22, 2021 08:58 PM

    I got:"

    begin program r. 

    install.packages("cmprsk") 

    end program. 

    Installing package into 'C:/ProgramData/IBM/SPSS/Statistics/23/extensions' 

    (as 'lib' is unspecified) 

    Warning: unable to access index for repository https://cloud.r-project.org/bin/windows/contrib/3.1 

    Error in readRDS(file) : 

     cannot read workspace version 3 written by R 4.2.0; need R 3.5.0 or newer 

    In addition: Warning message: 

    package 'cmprsk' is not available (as a binary package for R version 3.1.3)






    #SPSSStatistics
    #Support
    #SupportMigration


  • 11.  RE: How to operate STATS COMPRISK
    Best Answer

    Posted Sat May 22, 2021 09:39 PM

    I am guessing from the "installing package" message above that you are using Statistics V23, which is quite old. That would mean using R3.1, which is consistent with the error message. It appears that you may have an R4.2 distribution being used somewhere in tis process. That won't work. If so, you will need to figure out how that distribution is being referenced with V23. It might be that you have too new a version of cmprisk or survival, but normally CRAN would provide the package version that goes with the R version that is running. Statistics 23 will not work with R4.x versions.






    #SPSSStatistics
    #Support
    #SupportMigration


  • 12.  RE: How to operate STATS COMPRISK
    Best Answer

    Posted Wed May 26, 2021 07:51 PM

    Hellow. Iv downloaded SPSS V25 and the correct R version. When i tried to run the code I got:

    "Error in data.frame(df[noncatcovar], catdf) :

    arguments imply differing number of rows: 1830, 1794"

    What can I do?

    Thank you






    #SPSSStatistics
    #Support
    #SupportMigration


  • 13.  RE: How to operate STATS COMPRISK
    Best Answer

    Posted Wed May 26, 2021 09:32 PM

    I cannot help with this without details of the syntax you ran. It would also help to have the data if you can share it (jkpeckSupport Member).






    #SPSSStatistics
    #Support
    #SupportMigration


  • 14.  RE: How to operate STATS COMPRISK
    Best Answer

    Posted Thu May 27, 2021 06:09 AM

    This is the syntax:

    DATASET ACTIVATE DataSet1.

    STATS COMPRISK FAILTIME=T_TOT_SPP FAILSTATUS=Cause_Death_GROUP FIXEDCOVAR=SEX norigin agephase2 

      ishunll MCA_GROUP 

    FAILCODE=2 CENSORCODE=1

    /OPTIONS MISSING=OMIT PLOT=YES QUANTILES=.25 .50 .75 MAXITER=10 TOL=.000001.


    I have 1830 subjects

    Thank you






    #SPSSStatistics
    #Support
    #SupportMigration


  • 15.  RE: How to operate STATS COMPRISK
    Best Answer

    Posted Thu May 27, 2021 07:12 PM

    I think this has to do with missing data. Try running with MISSING=FAIL to check this.

    If that is correct. try selecting only complete cases and running the command like this.

    COUNT missingcount=your variables(MISSING).

    temporary.

    select if missingcount eq 0.

    stats comprisk ...


    If this is the solution, it would help me to improve the procedure if I could get the data (jkpeckSupport Member).







    #SPSSStatistics
    #Support
    #SupportMigration


  • 16.  RE: How to operate STATS COMPRISK
    Best Answer

    Posted Thu May 27, 2021 07:38 PM

    Using data->select cases i selected only the valid cases and ignored the missing data and it worked!

    Thank you so much!






    #SPSSStatistics
    #Support
    #SupportMigration


  • 17.  RE: How to operate STATS COMPRISK
    Best Answer

    Posted Sun May 30, 2021 10:22 AM

    Hi, how can I calculate the confidance intervals using the cmprsk package? there isnt any option to choose the presentation of the CI.

    The plot describes the hazard function for the two compiting risk and the censored? How can i tell which one is my primary outcome?

    Thank you






    #SPSSStatistics
    #Support
    #SupportMigration


  • 18.  RE: How to operate STATS COMPRISK
    Best Answer

    Posted Sun May 30, 2021 02:56 PM

    I have added the CI to the Coefficients table. You can get it from here

    https://1drv.ms/u/s!AoWcE61g_FAdisQJNGzg3ezH_EsUyQ?e=2Xgqq4

    and install it over the existing version using Extensions > Install local extension bundle.


    This will eventually get posted on the Extension Hub, but I would like to fix the missing data problem first. It would really help if you could send me the data and syntax where that occurred so that I can reproduce the problem (jkpeckSupport Member)






    #SPSSStatistics
    #Support
    #SupportMigration


  • 19.  RE: How to operate STATS COMPRISK
    Best Answer

    Posted Sun May 30, 2021 02:59 PM

    And the plot lines are annotated in the covariate evaluation table above the plot.






    #SPSSStatistics
    #Support
    #SupportMigration


  • 20.  RE: How to operate STATS COMPRISK
    Best Answer

    Posted Sun May 30, 2021 06:31 PM

    Thank you so much for all of your help! unfortunately I cannot send the file due to hospital policies. I attach the syntax.


    STATS COMPRISK FAILTIME=T_TOT_SPP FAILSTATUS=Cause_Death_GROUP FIXEDCOVAR=agephase2 SEX_NEW norigin 

      ishunll TTG DIab_Group_N MCA_GROUP BP_GROUP2 BMI_GROUP TCH_GROUP 

    FAILCODE=2 CENSORCODE=1

    /OPTIONS MISSING=OMIT PLOT=YES QUANTILES=.25 .50 .75 MAXITER=10 TOL=.000001.


    STATS COMPRISK FAILTIME=T_TOT_SPP FAILSTATUS=Cause_Death_GROUP FIXEDCOVAR=agephase2 SEX_NEW norigin 

      ishunll TTG DIab_Group_N MCA_GROUP BP_GROUP2 BMI_GROUP TCH_GROUP 

    FAILCODE=2 CENSORCODE=1 

    /OPTIONS MISSING=OMIT PLOT=YES QUANTILES=.25 .50 .75 MAXITER=10 TOL=.000001. 

    Error in data.frame(df[noncatcovar], catdf) : 

     arguments imply differing number of rows: 1830, 1795


    The porblem was fixed after I ignored the missing values.

    Thank you






    #SPSSStatistics
    #Support
    #SupportMigration


  • 21.  RE: How to operate STATS COMPRISK
    Best Answer

    Posted Sun May 30, 2021 08:15 PM

    That's okay. I was able to reproduce the problem and fix it. The updated version, which also allows the user to control the confidence interval probability, can be obtained here.

    https://1drv.ms/u/s!AoWcE61g_FAdisQJNGzg3ezH_EsUyQ?e=QP6OTB







    #SPSSStatistics
    #Support
    #SupportMigration