Thursday, April 3, 2025

Error in Installing Tidyverse on R

If you encounter error in installing "tidyverse" package on R, the solution is on the terminal install first the two packages (libfribidi-dev and libharfbuzz-dev):

# apt-get install libhartbuzz-dev

# apt-get install libfribidi-dev

 

After installing these two packages, on the R cli, install the "tidyverse" package:

 

 > install.packages("tidyverse")

 

To load the "tidyverse" library on R, issue the command:

library("tidyverse")

 

This works on Ubuntu 20.04.

Wednesday, March 26, 2025

Regression using R

Ordinary Least Squares (OLS) Regression Coefficients

MyMdl = lm(formula = GDP2018 ~ T, data = MM_DTA_01)

summary(MyMdl)

Will produce the following output:

Call:
lm(formula = GDP2018 ~ T, data = MM_DTA_01)

Residuals:
     Min       1Q   Median       3Q      Max
-2684399 -2025650  -592330  1430009  6473734

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept) -2427989     513893  -4.725 1.03e-05 ***
T             218026      11303  19.290  < 2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 2248000 on 76 degrees of freedom
Multiple R-squared:  0.8304,    Adjusted R-squared:  0.8282
F-statistic: 372.1 on 1 and 76 DF,  p-value: < 2.2e-16

 

Multiple Regression

MyMdl = lm(formula = GDP2018 ~ T + EX2018 + IM2018, data = MM_DTA_01)


 

Durbin-Watson Statistic for Serial Correlation (Autocorrelation)

DurbinWatsonTest(MyMdl) 

Will produce the following output:
    Durbin-Watson test

data:  MyMdl
DW = 0.035978, p-value < 2.2e-16
alternative hypothesis: true autocorrelation is greater than 0

 

Breusch-Godfrey Statistic for Serial Correlation (Autocorrelation)

bgtest(MyMdl) 

Will produce the following output:
    Breusch-Godfrey test for serial correlation of order up to 1
 

data:  MyMdl
LM test = 74.301, df = 1, p-value < 2.2e-16


Breusch-Pagan Statistic for Heteroscedasticity

bptest(MyMdl)

Will produce the following output:

  Studentized Breusch-Pagan test

data:  MyMdl

BP = 19.317, df = 1, p-value = 1.107e-05

 

Goldfeld-Quandt Statistic for Heteroscedasticity

gqtest(MyMdl)

Will produce the following output:

  Goldfeld-Quandt test

data:  MyMdl

BP = 29.613, df1 = 37, df2 = 37, p-value = 2.2e-16

alternative hypothesis: Variance increase from segment 1 to 2

 

Correlation Coefficient

head(DataNo2)

Will produce the following output:

# A tibble: 6 × 7
     YR     T       GDP GDPPI2018   GDP2018  EX2018  IM2018
  <dbl> <dbl>     <dbl>     <dbl>     <dbl>   <dbl>   <dbl>
1  2008     1  8050201.     0.784 10270878. 1647293 2216258
2  2009     2  8390421.     0.805 10419633. 1481405 2192637
3  2010     3  9399451.     0.840 11183861. 1769189 2668470
4  2011     4 10144661.     0.873 11615360. 1697601 2716794
5  2012     5 11060589.     0.891 12416466. 1901720 2867464
6  2013     6 12050592.     0.909 13254644. 1817413 3037079

 

cor_matrix = cor(DataNo2)

print(cor_matrix)

Will produce the following output:

                YR         T       GDP GDPPI2018   GDP2018    EX2018    IM2018
YR        1.0000000 1.0000000 0.9884230 0.9872057 0.9791493 0.9599731 0.9465083
T         1.0000000 1.0000000 0.9884230 0.9872057 0.9791493 0.9599731 0.9465083
GDP       0.9884230 0.9884230 1.0000000 0.9788880 0.9943552 0.9807268 0.9764256
GDPPI2018 0.9872057 0.9872057 0.9788880 1.0000000 0.9595876 0.9402991 0.9210839
GDP2018   0.9791493 0.9791493 0.9943552 0.9595876 1.0000000 0.9769194 0.9851542
EX2018    0.9599731 0.9599731 0.9807268 0.9402991 0.9769194 1.0000000 0.9859029
IM2018    0.9465083 0.9465083 0.9764256 0.9210839 0.9851542 0.9859029 1.0000000


cor_matrix = round(cor(DataNo2), 2)
print(cor_matrix)
Will produce the following rounded to 2 decimal digits correlation matrix output: 
          YR    T  GDP GDPPI2018 GDP2018 EX2018 IM2018
YR 1.00 1.00 0.99 0.99 0.98 0.96 0.95
T 1.00 1.00 0.99 0.99 0.98 0.96 0.95
GDP 0.99 0.99 1.00 0.98 0.99 0.98 0.98
GDPPI2018 0.99 0.99 0.98 1.00 0.96 0.94 0.92
GDP2018 0.98 0.98 0.99 0.96 1.00 0.98 0.99
EX2018 0.96 0.96 0.98 0.94 0.98 1.00 0.99
IM2018 0.95 0.95 0.98 0.92 0.99 0.99 1.00 

Graphing with R

plot(MyMdl)

Will produce the following graphs:


 



 

 

 

 

 

 

 


Wednesday, August 28, 2024

Black Soldier Fly Research

Black Soldier Fly (Hermetia illucens)



Food Waste Coversion Ratio


  • 1000kg of Food Waste coversion ratio to BSF Frass ranges from 12% (120kg) to 25% BSF frass (250kg)
  • 1000kg of Food Waste conversion ratio to BSF Larvae ranges from 5.5% to 12.5% BSF larvae (125kg)

 

 

 

Sources:

  1. Frass derived from black soldier fly larvae treatment of biodegradable wastes. A critical review and future perspectives, https://www.sciencedirect.com/science/article/pii/S0956053X22000666, 
  2. Black soldier flies (Hermetia illucens Linnaeus) as recyclers of organic waste
    and possible livestock feed, https://www.google.com/url?sa=t&source=web&rct=j&opi=89978449&url=https://www.ajol.info/index.php/ijbcs/article/view/181401/170797&ved=2ahUKEwjprJ6_k5mIAxV7klYBHfFWAmQQFnoECBMQAQ&usg=AOvVaw1V8CqpKZl4kkhHvBisLd-G


Tuesday, March 19, 2024

Spirulina

Growing Spirulina

a)  Materials Needed

  • Hydroponic Solution A (25ml) and B (25ml)
  • Non-iodized Table Salt - 10 TBSP (approx 140 grams)
  • Baking Soda - 10 TBSP (approx 140 grams)
  • Non-chlorinated Drinking Water - 10 liters
  • Aquarium Aerator (Air Pump, Hose, Air Stones)
  • Transparent or White Plastic Pail that can hold at least 11 liters of Water 
  • Spirulina Live Culture - 1 liter
  • If grown indoor, grow lights
  • If grown in non-tropical countries, aquarium water heater that can be adjusted between 30C to 38C

b)  Procedure 

  1. Pour 5 liters of non-chlorinated water to the transparent/white pail;
  2. Pour hydroponic solution A into the water and stir, then wait for 5 minutes;
  3. Pour hydroponic solution B into the water and stir, then wait for 5 minutes;
  4. Add additional 5 liters of non-chlorinated water and stir;
  5. Add 10 TBSP of Baking Soda into the water and stir till dissolved;
  6. Add 10 TBSP of Non-Iodized Table Salt into the water and stir till dissolve;
  7. Add 1 liter of Spirulina Live Culture into the water;
  8. Setup the aquarium aerator;
  9. Cover the pail with transparent covering (Transparent Plastic Cover or UV Sheet is recommended);
  10. Place the pail outside where it can be bathe in the sun for 5 to 7 days.

 

c)  Harvesting Spirulina 

  1. Using an empty pail, strain (preferably using cheese cloth) the spirulina from the growing pail;
  2. Wash the strained spirulina with drinking water till all salts are washed off;
  3. Squeeze and dry the spirulina in the sun or in a mechanical dryer;
  4. Approximately a 10 liter setup should yield 100 grams of spirulina powder;

 


Thursday, February 22, 2024

Notes on fail2ban

The software "fail2ban" is similar to DenyHosts but more general as it is not only intended for SSHD protection.


Installation

On Debian-based system, issue the command:

sudo apt-get install fail2ban -y


On Fedora-based system, issue the command:

sudo dnf install fail2ban -y


Configuration

The following sample configuration for SSHD are as follows (/etc/fail2ban/):

 

[sshd]
enabled = true
port = ssh
filter = sshd
logpath = /var/log/auth.log
maxretry = 3
findtime = 300
bantime = 28800
ignoreip = 127.0.0.1





Saturday, December 2, 2023

Yogurt Fermentation

Materials Needed

1.  Milk - 1000ml

2.  Live Yogurt Culture - 1 TBSP (You can use Yogurt purchased from store provided it still got live yogurt culture and NOT pasteurized)

3.  Yogurt container that can hold 1500ml or more; preferably glass container

 

Procedure

1.  Heat the milk in a pan at 72C for 15 seconds or more;

2.  Pour the heated milk into the container, place lid slightly ajar, and let the milk cool to around 42C or less;

3.  Once cooled, mix the Live Yogurt Culture to the milk; Stir to ensure the culture is distributed evenly throughout the milk;

4.  Cover the container, this time you can keep the lid tight.  Wait for 24 hrs for the milk to curd.  Once the milk got consistency similar to store bought Yogurt, your homemade Yogurt is ready.  Place it in the refrigerator for storage.





Tuesday, October 3, 2023

RedHill Lactobacillus Concentrate (RLC)

RedHill Lactobacillus Concentrate (RLC)

  • RLC is beneficial microbial inoculant for soil.  It is similar to EMAS, JMS, IMO and LABS.  It principally composed of different strains of lactobacillus and a small proportion of yeasts.  This simple procedure was developed by RedHill Nature Farm and Learning Site Incorporated (RNFLSI).

Why use RLC?

  • RLC is the most cost-effective bio-fertilizer as it is a just a by-product of cooking rice.  It only uses wash rice water, which are often thrown away, as its main ingredient.

Use

  • Bio-fertilizer
  • Seed treatment to increase germination rate
  • Probiotics for farm animals and pets
  • Odor control for kitchen wastes
     

Materials Needed

  • Softdrink bottle with cap (Preferably 1.5 or 2 liter capacity)
  • Wash rice water (1st and 2nd wash only; Make sure that the wash rice water is cloudy like milk and not super diluted with water).  
  • You can also use STALE RICE so long as the rice have no moldy growth.  When using stale rice, add water, mash the stale rice to a milky texture.  The consistency of milky texture should be the same as the wash rice. 

Preparation

  1. Place the wash rice water in the softdrink bottle.
  2. Cap tightly.  This is a MUST as we ferment the wash rice water anaerobically.
  3. Wait for 3-5 days for the wash rice water to ferment.  If the softdrink bottle is hard already, it means gasses has accumulated in the bottle and the wash rice water is already teeming with lactobacillus.  It is now ready for use.
  4. Dilute the RLC using 1:10 ratio of RLC to water.  Do not store RLC longer than 7 days as other microorganisms may grow besides our desired lactobacillus and yeasts.  You can always prepare a new batch.

Preservation

  • Should you really need to store the RLC for much longer period than 7 days, you will need Molasses or Sugar to preserve it.  Add 50ml of Molasses to the RLC.  Cap it tighly and shake till all molasses has been dissolved.  This is ready after 3-5 days.  RLC with Molasses is good for 3-4 months.  The same dilution ratio of 1:10 RLC to water for usage.