Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • fp: fractional polynomial degrees of freedom

    The degrees of freedom which Stata specifies for a model using the fp function for fractional polynomials differs from what I would expect.

    for example running
    Code:
    sysuse auto, clear
    
    fp <weight>: logit foreign <weight>
    results in a model a second degree fractional polynomial with powers -2 -2, according to the model statistics with 2 degrees of freedom.

    I would, maybe erroneously, have expected that the model would have 5 degrees of freedom, as the Stata manual page on fp mentions:
    A fractional polynomial model of degree m is taken to have 2m+1 degrees of freedom (df): one for β0 and one for each βj and its associated power.
    Similar statements can be found in Royston P, Altman DG. Regression Using Fractional Polynomials of Continuous Covariates: Parsimonious Parametric Modelling. Applied Statistics 1994;43:429

    Am I wrong in thinking df=2 would be a little too low in this case?

    Second to that question, I wonder if it would be possible to 'overrule' the prespecified degrees of freedom, for example when running 'estat ic'.

  • #2
    As to the second question: addition of the option df(df) was something I had missed on reading the manual at first... so ...
    'estat ic, df(5)' would set the degrees of freedom to 5.

    But I am still quite unsure about the first question, and depending on that if I should modify the df

    Comment


    • #3
      when I estimate your example, I get the following result (just showing the first part of the output):
      Code:
      Fractional polynomial comparisons:
      --------------------------------------------------------------------
            weight |   df    Deviance   Dev. dif.   P(*)   Powers
      -------------+------------------------------------------------------
           omitted |    0     90.066     33.692    0.000               
            linear |    1     58.108      1.734    0.629   1           
             m = 1 |    1     57.028      0.653    0.884   3           
             m = 2 |    4     56.374      0.000       --   -2 -2       
      --------------------------------------------------------------------
      so the "-2 -2" is shown as having 4 df - where did your "2" come from?

      Comment


      • #4
        The df in the table of 'fractional polynomial comparisons' are the ones that are used in the comparisons between the various(44 by default) possible fractional polynomials. the fp function follows a certain algorithm (as described in the papers by Royston et al.) to determine which power or combination of powers is 'the best'. After that, it runs the function for which it has generated these specific polynomial variables.

        In this case it runs logit, with 2 degrees of freedom: e(df_m)=2

        Code:
        . fp <weight>: logit foreign <weight>
        (fitting 44 models)
        (....10%....20%....30%....40%....50%....60%....70%....80%....90%....100%)
        
        Fractional polynomial comparisons:
        --------------------------------------------------------------------
              weight |   df    Deviance   Dev. dif.   P(*)   Powers
        -------------+------------------------------------------------------
             omitted |    0     90.066     33.692    0.000               
              linear |    1     58.108      1.734    0.629   1           
               m = 1 |    1     57.028      0.653    0.884   3           
               m = 2 |    4     56.374      0.000       --   -2 -2       
        --------------------------------------------------------------------
        (*) P = sig. level of model with m = 2 based on chi^2 of dev. dif.
        
        Logistic regression                             Number of obs     =         74
                                                        LR chi2(2)        =      33.69
                                                        Prob > chi2       =     0.0000
        Log likelihood = -28.187167                     Pseudo R2         =     0.3741
        
        ------------------------------------------------------------------------------
             foreign |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
            weight_1 |  -8.66e+08   3.59e+08    -2.41   0.016    -1.57e+09   -1.62e+08
            weight_2 |   1.22e+08   4.95e+07     2.46   0.014     2.46e+07    2.19e+08
               _cons |  -13.44607    4.32063    -3.11   0.002    -21.91435   -4.977792
        ------------------------------------------------------------------------------
        
        .
        Last edited by Jeroen Albers; 21 May 2020, 15:34.

        Comment


        • #5
          To revisit this again:
          As far as I know two degrees of freedom are taken for a fractional polynomial. The fractional polynomial might be represented as [b-coefficient]*[variable]^[fp-power]. the fp-power is selected by the fp function to generate the fp-variable. this variable is then used in the regression.

          As far as I know, and as is stated in the Stata manual, the effective degrees of freedom for this would be 1 for the b-coefficient and 1 for the fp-power, hence 2m df for a m-degree fractional polynomial. However, the regression function, logit in this case, is not aware of the background of the fp-variable, and takes only 1df, for the coefficient.

          Is it somehow possible to override the degrees of freedom a variable takes in a logistic regression?

          Comment

          Working...
          X