From: peter dalgaard pda...@gmail.com
Cc: r-help@r-project.org r-help@r-project.org
Sent: Friday, June 7, 2013 11:12 AM
Subject: Re: [R] Clogit R and Stata
Here is the R output:
Call:
coxph(formula = Surv(rep(1, 1404L), sftpcons) ~ sftptv2a3 + sftptv2a4 +Â
  sftptv2a5 + sftptv2a2 + sftptv2a6 + logim + maccat + disp4cat +Â
  strata(stratida), data = dframe, method = exact)
 n= 1404, number of events= 351Â
       coef      exp(coef) se(coef)    z Pr(|z|) Â
Â
sftptv2a3 Â 1.4552 Â Â 4.2852 Â 0.2273 Â 6.401 1.54e-10 ***
sftptv2a4 Â 3.1118 Â 22.4609 Â 0.2265 13.739 Â 2e-16 ***
sftptv2a5 Â 1.0717 Â Â 2.9204 Â 0.2522 Â 4.249 2.15e-05 ***
sftptv2a2 Â 0.7185 Â Â 2.0514 Â 0.3300 Â 2.177 Â 0.0295 * Â
sftptv2a6 Â 2.7341 Â 15.3965 Â 0.5050 Â 5.414 6.17e-08 ***
logim    0.7579   2.1338  0.1347  5.625 1.85e-08 ***
maccat   3.0809  21.7771  0.4005  7.693 1.43e-14 ***
disp4cat  0.7061   2.0261  0.1524  4.634 3.59e-06 ***
---
Signif. codes: Â 0 â***â 0.001 â**â 0.01 â*â 0.05 â.â 0.1 â
â 1Â
          exp(coef) exp(-coef) lower .95 upper .95
sftptv2a3 Â Â 4.285 Â Â 0.23336 Â Â 2.745 Â Â 6.691
sftptv2a4 Â Â 22.461 Â Â 0.04452 Â Â 14.409 Â Â 35.013
sftptv2a5 Â Â 2.920 Â Â 0.34241 Â Â 1.781 Â Â 4.788
sftptv2a2 Â Â 2.051 Â Â 0.48747 Â Â 1.074 Â Â 3.917
sftptv2a6 Â Â 15.397 Â Â 0.06495 Â Â 5.722 Â Â 41.429
logim     2.134   0.46866   1.639   2.779
maccat    21.777   0.04592   9.934   47.739
disp4cat    2.026   0.49355   1.503   2.731
Rsquare= 0.239 Â (max possible= 0.623 )
Likelihood ratio test= 383.2 Â on 8 df, Â p=0
Wald test       = 264.7  on 8 df,  p=0
Score (logrank) test = 396.2 Â on 8 df, Â p=0
And the STATA output:
Iteration 0: Â log likelihood = -95.537697 Â
Iteration 1: Â log likelihood = -91.465581 Â
Iteration 2: Â log likelihood = -91.402366 Â
Iteration 3: Â log likelihood = -91.402264 Â
Iteration 4: Â log likelihood = -91.402264 Â
Conditional (fixed-effects) logistic regression  Number of obs  =   Â
 468
                         LR
chi2(8) Â Â Â = Â Â 141.59
                         Prob
chi2 Â Â = Â Â 0.
Log likelihood = -91.402264 Â Â Â Â Â Â Â Â Â Â Â Pseudo R2 Â Â Â
= Â Â 0.4365
--
  sftpcons |    Coef.  Std. Err.    z   P|z|   [95%
Conf. Interval]
-+
  sftptv2a3 |  2.042827  .4741327   4.31  0.000   1.113544 Â
 2.97211
  sftptv2a4 |   4.10828  .5593723   7.34  0.000    3.01193 Â
 5.204629
  sftptv2a5 |  1.766492  .5585173   3.16  0.002   .6718177 Â
 2.861165
  sftptv2a2 |  1.366568  .6540307   2.09  0.037    .084691 Â
 2.648444
  sftptv2a6 |  2.307152  .8225835   2.80  0.005   .6949178 Â
 3.919386
    logim |  1.404135  .3480976   4.03  0.000   .7218764 Â
 2.086394
   maccat |   2.8423  .7008588   4.06  0.000   1.468642 Â
 4.215958
  disp4cat |  .6347805  .2872258   2.21  0.027   .0718283 Â
 1.197733
--
Also tried changing method=approximate with no noticeable changeÂ
On Jun 7, 2013, at 15:34 , Richard Beckett wrote:
Sorry to once again write a message but I'm once again stumped and am having
no luck finding a solution anywhere else.
This question requires some finesse in both R and STATA so hopefully I will
be able to get an answer here. I am much more adept in R and am trying to
replicate the results of a STATA file in R. Hopefully this is a proper forum
for such questions.
This is the code for the clogit in STATA
clogit sftpcons sftptv2a3 sftptv2a4 sftptv2a5 sftptv2a2 sftptv2a6 logim
maccat disp4cat if sample==1 glb_ind==Y, group(stratida)
and I tried to replicate it using
clogit1-clogit(sftpcons~sftptv2a3+sftptv2a4+sftptv2a5+sftptv2a2+sftptv2a6+logim+maccat+disp4cat+strata(stratida),
dframe, sample==1 | glb_ind==Y)
but got different results
What did I do wrong here? I interpreted the STATA clogit as run this logit as
long as the sample is 1 and glb_ind=Y What should I be doing instead?
An rather than | in the R version might help. Other than that, we're a
bit short on clues unless you provide some output.
--
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk Priv: pda...@gmail.com
[[alternative HTML version