Announcement

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

  • predict and fp predict following fractional polynomial regression

    I am using the fp command in Stata 13.1. After identifying the polynomial function with the appropriate powers, I was using the predict command to create variables containing the predicted values and residuals. According to the manual, the fp postestimation tools include the command fp predict; these two yield very highly correlated predicted values, nonetheless they are different. Do you know what is the difference between the two?

  • #2
    There is no reproducible example here.

    I did this as a trivial example:

    Code:
     
    . sysuse auto
    (1978 Automobile Data)
    
    . fp <weight> : regress mpg <weight>
    (fitting 44 models)
    (....10%....20%....30%....40%....50%....60%....70%....80%....90%....100%)
    
    Fractional polynomial comparisons:
    -------------------------------------------------------------------------------
          weight |   df    Deviance  Res. s.d.   Dev. dif.   P(*)   Powers
    -------------+-----------------------------------------------------------------
         omitted |    0    468.789      5.786     83.099    0.000               
          linear |    1    390.777      3.439      5.088    0.189   1           
           m = 1 |    2    385.894      3.327      0.205    0.909   -.5         
           m = 2 |    4    385.690      3.346      0.000       --   -2 -2       
    -------------------------------------------------------------------------------
    (*) P = sig. level of model with m = 2 based on F with 69 denominator dof.
    
          Source |       SS           df       MS      Number of obs   =        74
    -------------+----------------------------------   F(2, 71)        =     73.62
           Model |  1648.56499         2  824.282497   Prob > F        =    0.0000
        Residual |  794.894465        71  11.1956967   R-squared       =    0.6747
    -------------+----------------------------------   Adj R-squared   =    0.6655
           Total |  2443.45946        73  33.4720474   Root MSE        =     3.346
    
    ------------------------------------------------------------------------------
             mpg |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
        weight_1 |  -7.27e+08   3.50e+08    -2.08   0.041    -1.42e+09   -2.95e+07
        weight_2 |   1.08e+08   4.77e+07     2.26   0.027     1.26e+07    2.03e+08
           _cons |   5.524857   3.333785     1.66   0.102    -1.122522    12.17224
    ------------------------------------------------------------------------------
    
    . predict p1
    (option xb assumed; fitted values)
    
    . fp predict p2
    
    . assert p1 == p2
    On the assertion, silence signals consent. How does what you did differ?
    .

    Comment


    • #3
      Thank you so much for this!

      In my case I was using a number of covariates too.

      Code:
       fp <Age>, center fp(3) replace: reg Bone_Mass <Age> i.Sex i.Uni1 i.Uni2 i.Uni3 i.Uni4 i.Uni5
      
      . fp predict fit1
      (658 missing values generated)
       
      . predict fit2
      (option xb assumed; fitted values)
      (658 missing values generated)
       
      . assert fit1==fit2
      4209 contradictions in 4882 observations

      In the manual it says that 'fp predict' generates predictions which are equivalent to the fitted values prediction given by predict, xb, with the covariates other than the fractional polynomial variable set to zero.

      When I do the scattergrams for Age and the respective fit1 and fit2 values they look like this:


      Click image for larger version

Name:	fit1.png
Views:	1
Size:	21.3 KB
ID:	1295611

      Click image for larger version

Name:	fit2.png
Views:	1
Size:	29.0 KB
ID:	1295612


      Could it be that when using 'predict' instead of 'fp predict' the covariate values were set at their mean instead of @0?

      Comment

      Working...
      X