title: How to add a strata variable in the crr function?
body: <p>I am trying to test out a Fine and Gray regression and to validate if both the &quot;crr&quot; package and the &quot;survival&quot; package produce the same results. I will then be putting these results into Latex.</p>
  <p>The survival results work, but for the crr results I am having a problem inserting a strata variable. Instead of treating the strata variable as a strata, it simply treats it as a factor variable.</p>
  <p>Here is my code:</p>
  <pre><code>#Create the model matrix
  cov1 &lt;- model.matrix(~ factor(marriage_husbandNP2$factor_age)
                       + factor(marriage_husbandNP2$factor_marital)
                       + factor(marriage_husbandNP2$factor_rural)
                       + relevel((factor(marriage_husbandNP2$factor_crime)), ref=&quot;Theft and Burglary&quot;)
                       + factor(marriage_husbandNP2$factor_religion)
                       + factor(marriage_husbandNP2$factor_time)
                       + strata(marriage_husbandNP2$factor_child)
                       + factor(marriage_husbandNP2$factor_place)
                       + factor(marriage_husbandNP2$factor_town),
                       data = marriage_husbandNP2)[,-1]
  #create the model
  test_newfine &lt;- crr(marriage_husbandNP2$ftime, marriage_husbandNP2$fstatus, cov1=cov1 , failcode=1, cencode=0,
                       na.action=na.omit)
  
  #Print the summary of the results
  
  summary.crr(test_newfine)
  
  </code></pre>
  <p>Here is part of the results:</p>
  <pre><code>factor(marriage_husbandNP2$factor_age)30-39                                                    -0.08958
  factor(marriage_husbandNP2$factor_age)40+                                                      -0.03279
  factor(marriage_husbandNP2$factor_marital)Married                                              -0.24707
  factor(marriage_husbandNP2$factor_rural)Town                                                    0.06140
  factor(marriage_husbandNP2$factor_rural)Port cities                                             0.03485
  relevel((factor(marriage_husbandNP2$factor_crime)), ref = &quot;Theft and Burglary&quot;)Violent crimes  -0.00408
  relevel((factor(marriage_husbandNP2$factor_crime)), ref = &quot;Theft and Burglary&quot;)Livestock theft  0.69953
  relevel((factor(marriage_husbandNP2$factor_crime)), ref = &quot;Theft and Burglary&quot;)Arson            0.18090
  relevel((factor(marriage_husbandNP2$factor_crime)), ref = &quot;Theft and Burglary&quot;)Against society  0.02449
  relevel((factor(marriage_husbandNP2$factor_crime)), ref = &quot;Theft and Burglary&quot;)Unknown          0.47567
  factor(marriage_husbandNP2$factor_religion)Protestant                                          -0.27935
  factor(marriage_husbandNP2$factor_religion)Unknown                                             -0.85640
  factor(marriage_husbandNP2$factor_time)1848-1853                                                0.47355
  strata(marriage_husbandNP2$factor_child)1+                                                     -0.08371
  factor(marriage_husbandNP2$factor_place)Munster                                                -0.07983
  factor(marriage_husbandNP2$factor_place)Ulster                                                  0.06396
  factor(marriage_husbandNP2$factor_place)Connaught                                               0.03635
  factor(marriage_husbandNP2$factor_town)1+                                                      -0.36061
  </code></pre>
  <p>I wish for factor_child to be included as a strata, not as a visible covariate.
  I have also tested the crrs function from the package &quot;crrSC&quot;.</p>
  <pre><code>test_newfine &lt;- crrs(marriage_husbandNP2$ftime, marriage_husbandNP2$fstatus, cov1=cov1 ,strata=marriage_husbandNP2$factor_child, ctype=1,
   failcode=1, cencode=0,
                      na.action=na.omit)
  </code></pre>
  <p>Although it does produce the results with the variable hidden properly. For some reason, all the tests for the overall significance of the model don't work. Moreover, although the package states that it will produce an object that is crr type, it does not produce a package of this type.</p>
  <p>Here are screenshots of how different these two sets look (first is produced by CRR, Second by CRRS):</p>
  <p><a href="https://i.stack.imgur.com/mPZy4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mPZy4.png" alt="Produced by CRR" /></a></p>
  <p><a href="https://i.stack.imgur.com/sKFPK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sKFPK.png" alt="Produced by CRRS" /></a></p>
  <p>So what would be the best way to include a strata variable into a fine and gray regression using the CRR logic.</p>