Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9228641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:22:27+00:00 2026-06-18T05:22:27+00:00

I am using the survival package for a population with two subgroups. I need

  • 0

I am using the survival package for a population with two subgroups. I need the 5 year KM survival percentage for each group. I got this value from:

summary(survfit(Surv(survtime, vital)~subgroup)), time = 60) #in months

However, I also wanted to run a chisq test on the two five year survival rates. Is there an easy way to run this test using the survival package?

Thank you for any advice and help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T05:22:28+00:00Added an answer on June 18, 2026 at 5:22 am

    Not sure if this is the right way to go about it (buyer beware), but here is an example using the aml dataset included as example data with the survival package.

    library(survival)
    amlsurv <- with(aml,survfit(Surv(time,status) ~ x))
    summary(amlsurv ,time=20)
    

    Which results in, for time=20:

    Call: survfit(formula = Surv(time, status) ~ x)
    
                    x=Maintained 
            time       n.risk      n.event
          20.000        7.000        3.000 ...
    
                    x=Nonmaintained 
            time       n.risk      n.event
          20.000        6.000        5.000 ...
    

    Both of these options fail using the survdiff function:

    survdiff(summary(aml,time=20))
    survdiff(aml,time=20)
    

    Now try limiting to 20 days manually:

    aml$status.20 <- aml$status
    # set 'deaths' with a time greater than 20 to be 'survivors'
    aml$status.20[aml$status == 1 & aml$time > 20] <- 0
    amlsurv <- (Surv(aml$time,aml$status.20) ~ aml$x)
    summary(survfit(amlsurv))
    # results are the same as above, Maintained=3 events,Nonmaintained=5 events
    

    Now you can get your results for the 20 days limit comparing the two groups:

    survdiff(amlsurv)
    Call:
    survdiff(formula = amlsurv)
    
                         N Observed Expected (O-E)^2/E (O-E)^2/V
    aml$x=Maintained    11        3      4.3     0.392     0.874
    aml$x=Nonmaintained 12        5      3.7     0.455     0.874
    
     Chisq= 0.9  on 1 degrees of freedom, p= 0.35 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the survival package to generate the KM curves for two populations but
Using jQuery, how do I get the value from a textbox and then load
using this http://bl.ocks.org/950642 we can see how to add images to nodes, the question
Using CI for the first time and i'm smashing my head with this seemingly
Using this code, the following execution yields strange results: C 100 R W The
using xmltextreader, how would I load a hashtable. XML: <base><user name=john>2342343</user><user name=mark>239099393</user></base> This was
using this code: Java Server side: ... out = new PrintWriter(this.client.getOutputStream(), true); ... public
Using Android NDK is it possible (from native C-code) to get a list of
Using Sinatra and DataMapper. This is my first time trying to use more than
Using JQuery,Is there any possible to capture images/scanned documents from digital Camera/Scanner Connected to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.