rnon-linear-regressionpoly

Interpreting multiple predictor polynomial regression output in R


I need to export a final multivariate polynomial regression equation from R to another application. I do not understand one portion of the regression output. The regression uses the polym() function. The summary table is posted below.

ploy_lm <- lm(df$SV ~ polym(df$Indy, df$HI, degree = 3, raw = TRUE)
summary(ploy_lm)

The table below says polym input for "df$Indy, df$HI, degree = 3, raw = TRUE".

Estimate
Intercept -8.903
(polym input)1.o 1.189E0
(polym input)2.o -1.651E-2
(polym input)1.1 8.247E-4

How do I translate the results into a final regression equation? Does the value at the end of the first column (e.g. from the last row: "polym(df$Indy, df$WM_HI, degree = 3, raw = TRUE)1.1") signify the exponent value?


Solution

  • Here is a simple example with a predefined function:

    x1<-  runif(20, 1, 20)
    x2 <- runif(20, 15, 30)
    
    #define a function for y
    y <- (1 - 3*x1 + 1/5*x2 - x1*x2 + 0.013*x1^2 + 0.2 *x2^2)
    #add some noise to prevent a warning on the fit
    y <- y +rnorm(20, 0, 0.01)
    
    ploy_lm <- lm(y ~ polym(x1, x2, degree = 2, raw = TRUE))
    summary(ploy_lm)
      
    Call:
    lm(formula = y ~ polym(x1, x2, degree = 2, raw = TRUE))
    
    Residuals:
          Min        1Q    Median        3Q       Max 
    -0.017981 -0.007537  0.001757  0.005833  0.018697 
    
    Coefficients:
                                               Estimate Std. Error  t value Pr(>|t|)    
    (Intercept)                               9.588e-01  7.158e-02    13.39 2.25e-09 ***
    polym(x1, x2, degree = 2, raw = TRUE)1.0 -3.003e+00  2.820e-03 -1064.88  < 2e-16 ***
    polym(x1, x2, degree = 2, raw = TRUE)2.0  1.315e-02  9.659e-05   136.15  < 2e-16 ***
    polym(x1, x2, degree = 2, raw = TRUE)0.1  2.059e-01  6.536e-03    31.51 2.12e-14 ***
    polym(x1, x2, degree = 2, raw = TRUE)1.1 -1.000e+00  1.059e-04 -9446.87  < 2e-16 ***
    polym(x1, x2, degree = 2, raw = TRUE)0.2  1.998e-01  1.511e-04  1322.68  < 2e-16 ***
    ---
    Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
    
    Residual standard error: 0.01167 on 14 degrees of freedom
    Multiple R-squared:      1, Adjusted R-squared:      1 
    F-statistic: 6.298e+08 on 5 and 14 DF,  p-value: < 2.2e-16            
    
    #In summary
    # Term         model    Fitted
    # Intercept     1        .959
    # x1           -3       -3
    # x1^2          0.013    .0132
    # x2            0.2     .206
    # x2^2          0.2     .1998
    # x1 * x2      -1       -1
    

    The first digit after the ")" is the power of the first term and the number after the "." is the power of the second term.