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 6691425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:45:01+00:00 2026-05-26T05:45:01+00:00

I wan’t to export the output from a cox regression to a table that

  • 0

I wan’t to export the output from a cox regression to a table that I then can put into my article. I guess the best way to go about it is with xtable:

library(survival)
data(pbc)
fit.pbc <- coxph(Surv(time, status==2) ~ age + edema + log(bili) + 
    log(protime) + log(albumin), data=pbc)

summary(fit.pbc)
library(xtable)
xtable(fit.pbc)

Now I want to do the following to the output:

  • Add confidence interval (CI) of 95 %
  • Select certain rows, say age and log(protime)
  • Round the exp(B) & CI to three decimals
  • Remove the column with z & regular coef

Thanks in advance!

  • 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-05-26T05:45:02+00:00Added an answer on May 26, 2026 at 5:45 am

    I’d approach this by first taking a look at how the survival package constructs the table it prints by default.

    To find the function that does that printing, examine the class of your fit object, and then look for a print method for that class:

    class(fit.pbc)
    # [1] "coxph"
    grep("coxph", methods("print"), value=TRUE)
    # [1] "print.coxph"         "print.coxph.null"   
    # [3] "print.coxph.penal"   "print.summary.coxph"
    

    After taking a look at print.coxph, here’s what I came up with:

    cox  <- fit.pbc
    
    # Prepare the columns
    beta <- coef(cox)
    se   <- sqrt(diag(cox$var))
    p    <- 1 - pchisq((beta/se)^2, 1)
    CI   <- round(confint(cox), 3)
    
    # Bind columns together, and select desired rows
    res <- cbind(beta, se = exp(beta), CI, p)
    res <- res[c("age", "log(protime)"),]
    
    # Print results in a LaTeX-ready form
    xtable(res)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i wan to create a program that can get the application name i can
I wan to learn 1). How to call assembly code so that I can
I wan't to have a function that turns spell check on then go's to
I wan't to register the OnMouseOver and OnMouseOut-Event for an Image from the Code
i wan to create a linked list that contains the name , age and
I wan't to animate a view that's shaped as an arrow, and I want
I wan't to perform an animation before quitting a view. The problem is that
I wan't to compare two strings in a SQL request so I can retrieve
I wan't want to create a cross-plattform programm that embedds the python interpreter, and
I wan to get id from the gridview and using this code string UserID

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.