rm(list =ls())
library(readxl)
# read data
RD <- read_excel("/home/hossein/Downloads/organiseddata.xlsx")
# summary stats
summary(RD)
## Year Month Frynumber Quntityoffeed Quantityharvested
## Min. :2016 Min. : 1 Min. :10245 Min. : 5405 Min. : 5357
## 1st Qu.:2016 1st Qu.: 9 1st Qu.:19337 1st Qu.: 7890 1st Qu.: 6616
## Median :2017 Median :17 Median :24086 Median : 8612 Median : 7512
## Mean :2017 Mean :17 Mean :26961 Mean :10694 Mean : 9235
## 3rd Qu.:2018 3rd Qu.:25 3rd Qu.:36307 3rd Qu.: 9946 3rd Qu.: 9352
## Max. :2019 Max. :33 Max. :53171 Max. :35260 Max. :25799
## No.workers Revenue Costoffry Costoffeed
## Min. :11.0 Min. :11361 Min. : 409.8 Min. : 5567
## 1st Qu.:11.0 1st Qu.:14010 1st Qu.: 773.5 1st Qu.: 8127
## Median :13.0 Median :16477 Median : 963.4 Median : 8870
## Mean :12.7 Mean :20056 Mean :1078.5 Mean :11014
## 3rd Qu.:13.0 3rd Qu.:19150 3rd Qu.:1452.3 3rd Qu.:10244
## Max. :15.0 Max. :56241 Max. :2126.8 Max. :36318
## Costoflabor Equipmentcosts Operationcosts Totalcost
## Min. : 910.8 Min. : 2.101 Min. :111.9 Min. : 7397
## 1st Qu.: 996.3 1st Qu.: 31.620 1st Qu.:211.2 1st Qu.:10457
## Median :1088.6 Median : 77.046 Median :268.2 Median :11631
## Mean :1095.5 Mean : 109.737 Mean :281.2 Mean :13579
## 3rd Qu.:1169.6 3rd Qu.: 109.471 3rd Qu.:351.4 3rd Qu.:12935
## Max. :1361.6 Max. :1180.772 Max. :552.1 Max. :40089
## CashFlow PV
## Min. : 1303 Min. : 1218
## 1st Qu.: 3964 1st Qu.: 3544
## Median : 5158 Median : 4479
## Mean : 6477 Mean : 5590
## 3rd Qu.: 6400 3rd Qu.: 5626
## Max. :19293 Max. :15749
# Histograms
hist(RD$Frynumber)
hist(RD$Quntityoffeed)
hist(RD$No.workers)
table1::table1 (~ Frynumber + Quntityoffeed+No.workers + Quantityharvested|Year, data=RD,overall="Total",
topclass="Rtable1-grid Rtable1-shade Rtable1-times")
## Warning in table1.formula(~Frynumber + Quntityoffeed + No.workers +
## Quantityharvested | : Terms to the right of '|' in formula 'x' define table
## columns and are expected to be factors with meaningful labels.
2016 (N=9) |
2017 (N=12) |
2018 (N=7) |
2019 (N=5) |
Total (N=33) |
|
---|---|---|---|---|---|
Frynumber | |||||
Mean (SD) | 25200 (10400) | 25700 (11200) | 35100 (13500) | 21900 (8460) | 27000 (11500) |
Median [Min, Max] | 24100 [13600, 42000] | 21900 [10200, 46000] | 30000 [19300, 53200] | 19500 [14900, 36300] | 24100 [10200, 53200] |
Quntityoffeed | |||||
Mean (SD) | 9200 (3200) | 10200 (4590) | 15600 (10000) | 7680 (1540) | 10700 (6030) |
Median [Min, Max] | 8890 [5510, 16600] | 7890 [5410, 20800] | 12900 [6890, 35300] | 7890 [5510, 9490] | 8610 [5410, 35300] |
No.workers | |||||
Mean (SD) | 11.0 (0) | 13.0 (0) | 12.7 (0.488) | 15.0 (0) | 12.7 (1.31) |
Median [Min, Max] | 11.0 [11.0, 11.0] | 13.0 [13.0, 13.0] | 13.0 [12.0, 13.0] | 15.0 [15.0, 15.0] | 13.0 [11.0, 15.0] |
Quantityharvested | |||||
Mean (SD) | 8230 (3120) | 8950 (4050) | 12600 (7480) | 7050 (1360) | 9240 (4720) |
Median [Min, Max] | 7770 [5360, 15600] | 7030 [5360, 18000] | 8290 [6620, 25800] | 6640 [5850, 9350] | 7510 [5360, 25800] |
# Modeling
m1 <- lm(Quantityharvested ~ Frynumber+No.workers+Quntityoffeed, data=RD)
summary(m1)
##
## Call:
## lm(formula = Quantityharvested ~ Frynumber + No.workers + Quntityoffeed,
## data = RD)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2899.43 -377.88 23.03 447.18 2291.57
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -71.33503 1845.76563 -0.039 0.969436
## Frynumber 0.12680 0.03150 4.026 0.000373 ***
## No.workers 3.35089 139.09865 0.024 0.980946
## Quntityoffeed 0.54664 0.06026 9.071 5.74e-10 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1029 on 29 degrees of freedom
## Multiple R-squared: 0.957, Adjusted R-squared: 0.9526
## F-statistic: 215.2 on 3 and 29 DF, p-value: < 2.2e-16
anova(m1)
## Analysis of Variance Table
##
## Response: Quantityharvested
## Df Sum Sq Mean Sq F value Pr(>F)
## Frynumber 1 596130622 596130622 563.0967 < 2.2e-16 ***
## No.workers 1 345431 345431 0.3263 0.5723
## Quntityoffeed 1 87119721 87119721 82.2921 5.738e-10 ***
## Residuals 29 30701279 1058665
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot(m1)
m3 <- lm(Revenue ~ Costoffry+Costoffeed+Costoflabor+Equipmentcosts+Operationcosts, data = RD)
summary(m3)
##
## Call:
## lm(formula = Revenue ~ Costoffry + Costoffeed + Costoflabor +
## Equipmentcosts + Operationcosts, data = RD)
##
## Residuals:
## Min 1Q Median 3Q Max
## -6251.0 -1127.4 123.7 1448.5 4972.2
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -1.510e+03 3.963e+03 -0.381 0.70617
## Costoffry 6.928e+00 1.893e+00 3.660 0.00108 **
## Costoffeed 1.193e+00 1.402e-01 8.512 3.99e-09 ***
## Costoflabor -6.083e-01 3.813e+00 -0.160 0.87443
## Equipmentcosts 1.189e-02 2.203e+00 0.005 0.99573
## Operationcosts 5.740e+00 4.600e+00 1.248 0.22277
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2428 on 27 degrees of freedom
## Multiple R-squared: 0.9548, Adjusted R-squared: 0.9464
## F-statistic: 114.1 on 5 and 27 DF, p-value: < 2.2e-16
anova(m3)
## Analysis of Variance Table
##
## Response: Revenue
## Df Sum Sq Mean Sq F value Pr(>F)
## Costoffry 1 2908951033 2908951033 493.3563 < 2.2e-16 ***
## Costoffeed 1 444199946 444199946 75.3360 2.701e-09 ***
## Costoflabor 1 1059009 1059009 0.1796 0.6751
## Equipmentcosts 1 4303 4303 0.0007 0.9786
## Operationcosts 1 9182432 9182432 1.5573 0.2228
## Residuals 27 159198680 5896247
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot(m3)
m4 <- lm(PV ~ Totalcost+Equipmentcosts+Operationcosts+Quantityharvested+Year,data = RD)
summary(m4)
##
## Call:
## lm(formula = PV ~ Totalcost + Equipmentcosts + Operationcosts +
## Quantityharvested + Year, data = RD)
##
## Residuals:
## Min 1Q Median 3Q Max
## -934.9 -521.4 149.8 388.9 1089.3
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.082e+06 2.234e+05 4.846 4.61e-05 ***
## Totalcost -8.292e-01 7.264e-02 -11.416 7.70e-12 ***
## Equipmentcosts 1.306e-01 5.773e-01 0.226 0.823
## Operationcosts 1.382e+00 1.086e+00 1.272 0.214
## Quantityharvested 1.855e+00 1.009e-01 18.378 < 2e-16 ***
## Year -5.369e+02 1.108e+02 -4.847 4.59e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 630.2 on 27 degrees of freedom
## Multiple R-squared: 0.9764, Adjusted R-squared: 0.9721
## F-statistic: 223.7 on 5 and 27 DF, p-value: < 2.2e-16