1
$\begingroup$

I have three models :

Model A :

>>> lm = smf.ols(formula='Total_yield ~  PH + EC + N + P + Fe + Cu + Mn  ', data=data).fit()
>>> lm.summary()
<class 'statsmodels.iolib.summary.Summary'>
"""
                            OLS Regression Results                            
==============================================================================
Dep. Variable:            Total_yield   R-squared:                       0.590
Model:                            OLS   Adj. R-squared:                  0.508
Method:                 Least Squares   F-statistic:                     7.186
Date:                Tue, 07 Mar 2017   Prob (F-statistic):             0.0438
Time:                        14:32:50   Log-Likelihood:                -58.331
No. Observations:                   7   AIC:                             120.7
Df Residuals:                       5   BIC:                             120.6
Df Model:                           1                                         
Covariance Type:            nonrobust                                         
==============================================================================
                 coef    std err          t      P>|t|      [95.0% Conf. Int.]
------------------------------------------------------------------------------
Intercept    564.3577    142.383      3.964      0.011       198.350   930.366
PH          1693.0731    427.150      3.964      0.011       595.049  2791.097
EC           564.3577    142.383      3.964      0.011       198.350   930.366
N            564.3577    142.383      3.964      0.011       198.350   930.366
P            564.3577    142.383      3.964      0.011       198.350   930.366
Fe          1128.7154    284.767      3.964      0.011       396.700  1860.731
Cu          1693.0731    427.150      3.964      0.011       595.049  2791.097
Mn         -3447.6000   1286.078     -2.681      0.044     -6753.569  -141.631
==============================================================================
Omnibus:                          nan   Durbin-Watson:                   3.039
Prob(Omnibus):                    nan   Jarque-Bera (JB):                0.312
Skew:                          -0.026   Prob(JB):                        0.856
Kurtosis:                       1.968   Cond. No.                     9.81e+50
==============================================================================

In model A, I have just use variables which p values have less than 0.05, other variables are > 0.05 , so remove in model using forward-backward.

Model : B

>>> lm = smf.ols(formula='Total_yield ~  PH + EC + N + P + Fe + Cu + Average_rain + Mn  ', data=data).fit()
>>> lm.summary()
<class 'statsmodels.iolib.summary.Summary'>
"""
                            OLS Regression Results                            
==============================================================================
Dep. Variable:            Total_yield   R-squared:                       0.751
Model:                            OLS   Adj. R-squared:                  0.626
Method:                 Least Squares   F-statistic:                     6.017
Date:                Tue, 07 Mar 2017   Prob (F-statistic):             0.0622
Time:                        14:32:01   Log-Likelihood:                -56.590
No. Observations:                   7   AIC:                             119.2
Df Residuals:                       4   BIC:                             119.0
Df Model:                           2                                         
Covariance Type:            nonrobust                                         
================================================================================
                   coef    std err          t      P>|t|      [95.0% Conf. Int.]
--------------------------------------------------------------------------------
Intercept      913.6628    250.453      3.648      0.022       218.295  1609.031
PH            2740.9883    751.358      3.648      0.022       654.885  4827.092
EC             913.6628    250.453      3.648      0.022       218.295  1609.031
N              913.6628    250.453      3.648      0.022       218.295  1609.031
P              913.6628    250.453      3.648      0.022       218.295  1609.031
Fe            1827.3255    500.905      3.648      0.022       436.590  3218.061
Cu            2740.9883    751.358      3.648      0.022       654.885  4827.092
Average_rain   -78.6178     48.959     -1.606      0.184      -214.549    57.313
Mn           -3938.5683   1162.148     -3.389      0.028     -7165.209  -711.928
==============================================================================
Omnibus:                          nan   Durbin-Watson:                   2.296
Prob(Omnibus):                    nan   Jarque-Bera (JB):                0.917
Skew:                           0.630   Prob(JB):                        0.632
Kurtosis:                       1.754   Cond. No.                     4.90e+32
==============================================================================

In this model( B) , I just add Rain variables ,Rain variable is I have remove in the model (A)

Model-C :

>>> lm = smf.ols(formula='Total_yield ~  PH + EC + OC + N + P  + S + Fe + Cu + K + Hydro + High_temp + Low_temp + Precipitation + Average_rain', data=data).fit()
>>> lm.summary()
<class 'statsmodels.iolib.summary.Summary'>
"""
                            OLS Regression Results                            
==============================================================================
Dep. Variable:            Total_yield   R-squared:                       0.967
Model:                            OLS   Adj. R-squared:                  0.802
Method:                 Least Squares   F-statistic:                     5.872
Date:                Tue, 07 Mar 2017   Prob (F-statistic):              0.303
Time:                        14:29:08   Log-Likelihood:                -49.503
No. Observations:                   7   AIC:                             111.0
Df Residuals:                       1   BIC:                             110.7
Df Model:                           5                                         
Covariance Type:            nonrobust                                         
=================================================================================
                    coef    std err          t      P>|t|      [95.0% Conf. Int.]
---------------------------------------------------------------------------------
Intercept         0.3102      0.140      2.212      0.270        -1.471     2.092
PH                0.9306      0.421      2.212      0.270        -4.414     6.275
EC                0.3102      0.140      2.212      0.270        -1.471     2.092
OC             4169.2723   1332.778      3.128      0.197     -1.28e+04  2.11e+04
N                 0.3102      0.140      2.212      0.270        -1.471     2.092
P                 0.3102      0.140      2.212      0.270        -1.471     2.092
S             -1343.9524    509.239     -2.639      0.231     -7814.450  5126.545
Fe                0.6204      0.280      2.212      0.270        -2.942     4.183
Cu                0.9306      0.421      2.212      0.270        -4.414     6.275
K              2019.6091    959.691      2.104      0.282     -1.02e+04  1.42e+04
Hydro         -2214.3113    734.976     -3.013      0.204     -1.16e+04  7124.439
High_temp        11.1139      5.023      2.212      0.270       -52.715    74.943
Low_temp          8.0121      3.621      2.212      0.270       -38.002    54.026
Precipitation    60.4332     27.316      2.212      0.270      -286.643   407.510
Average_rain   -133.9362     69.860     -1.917      0.306     -1021.593   753.721
==============================================================================
Omnibus:                          nan   Durbin-Watson:                   2.736
Prob(Omnibus):                    nan   Jarque-Bera (JB):                0.548
Skew:                           0.284   Prob(JB):                        0.760
Kurtosis:                       1.752   Cond. No.                     2.81e+16
==============================================================================

I am confusing in which model I have to use for predict the yield. because In model - C we have AIC value is lower than model -A and B, but all p values are bigger than 0.05 .

So which one I have to choose Model - A or Model - B or Model- C ?

$\endgroup$
1
$\begingroup$

Your starting point is a bad one. Using forward-backward selection will give results in which:

  1. The standard errors are too small
  2. The p values are too small
  3. The parameter estimates are biased away from 0
  4. The model is too complex
  5. Your opportunity to think about the model is limited

If you must use an automated method, start with LASSO or LAR. But it would be much better to think about what you are doing.

However, if you are comparing these models, I would go with model 3. The fact that none of the individual tests is significant is not really the point (and that's one more reason why forward-backward isn't great).

$\endgroup$
6
  • $\begingroup$ Sorry for this word " forward-backword" actually my meaning is that remove one by one variables which have higher p values in the model . likewise, and finally I get model-A where all p values are less than 0.05 , so I think that model -A , but I notice that in model- C we have r-square : 0.96 and adjusted r-square : 0.80 with AIC low , so there is does not matter in model - C p value which is greater than 0.05 ? So, model -C is best fitted ? and if I have to use LASSO or LAR method, can you give me one link where i have easy to understand this ? thanks a lot. $\endgroup$
    – e4e5
    Mar 7 '17 at 12:55
  • 1
    $\begingroup$ Backward has all the same problems I listed. $\endgroup$
    – Peter Flom
    Mar 7 '17 at 13:50
  • $\begingroup$ sir so if AIC is low with adjusted r square high then select this model (model-3) ? Can you please tell me what need to check in the model because I have to do same for 200 different district predict yield, a d select best model for different different district, so it will help .thanks $\endgroup$
    – e4e5
    Mar 7 '17 at 15:38
  • 1
    $\begingroup$ There is often no "best model" but this topic has been discussed a lot both here on CrossValidated and in the literature. You should search these topics. There is no single, simple solution. And if you have 200 districts, iI would not make separate models for each. $\endgroup$
    – Peter Flom
    Mar 7 '17 at 15:41
  • 1
    $\begingroup$ @e4e5 This is really a case were most likely a hierarchical model that can account for likely similarities between districts (while allowing differences) would almost certainly perform a lot better at prediction than individual models based on very little data. $\endgroup$
    – Björn
    Jun 21 '17 at 12:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.