Lets take the conditional logisitc regression example from the Survival Package
And using the following commands
library(survival)
data(logan)
resp <- levels(logan$occupation)
n <- nrow(logan)
indx <- rep(1:n, length(resp))
logan2 <- data.frame(logan[indx,],
id = indx,
tocc = factor(rep(resp, each=n)))
logan2$case <- (logan2$occupation == logan2$tocc)
B <- clogit(case ~ tocc + tocc:education + strata(id), logan2)
Now we can generate the regression parameters, but lets say we specifically want the toccfarm
value of -1.896.
How would we only output this or save it as x
save this.
When we use
B$coefficients
we get all the regression coefficients.
I have tried something like
B$coefficients[1,]
B$coefficients(term=1)
B$coefficients("toccfarm")
But none have worked
Another approach can be with the use of the summary
function. You can see that with summary the coefficients of the model are taken as a matrix.
> is.matrix(summary(B)$coefficients)
[1] TRUE
At this point you can store summary(B)$coefficients
in an object and then subset it as you wish.
summary(B)$coefficients[1,1]