import numpy as np import pandas as pd import statsmodels.api as sm from statsmodels.formula.api import ols y=(24.7,20.6,27.7,16.2,16.2,24.9,27.3,28.8,22.7,15,13,22.5,38.5,39.5,36.8,19.5,15.4,26.3,28.5,31,34.9,14.1,17.7,22.6) print(y) b=('A', 'A', 'A', 'A', 'A', 'A', '8', '8', 'B', 'B', 'B', 'B', 'C', 'C ', 'C ', 'C', 'C','C','D', 'D', 'D', 'D', 'D','D' ) print(b) t=('1', '2', '3', '4', '5', '6', '1', '2', '3', '4', '5', '6', '1', '2', '3', '4', '5', '6', '1', '2', '3', '4', '5', '6', ) print(t) df=pd.DataFrame({'Yield':y,'Treatment':t,'Blocks':b}) print(df) model=ols('Yield~Treatment+Blocks',data=df).fit() rbd_table=sm.stats.anova_lm(model,typ=2) print(rbd_table) p_val_t=0.000545 p_val_b=0.019082 if p_val_t>0.05: print('Accept H0 for treatments') else: print('Reject H0 for treatments') if p_val_b>0.05: print('Accept H0 for blocks') else: print('Reject H0 for blocks')
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter