Skip to content

Instantly share code, notes, and snippets.

@MartinMacharia
Created September 14, 2016 11:23
Show Gist options
  • Save MartinMacharia/8a55b8091a8322925720e58dabeab5a5 to your computer and use it in GitHub Desktop.
Save MartinMacharia/8a55b8091a8322925720e58dabeab5a5 to your computer and use it in GitHub Desktop.
Returns LP publication
# 1,000,000
Y_R=5625-2897*(0.966^120)-2728 #Rice N response function
Y_M=3159-1191*(0.976^120)-1968 #Maize N response function
Y_B=1415-715*(0.950^68)-700 #Bean N response function
Y_FM=2100-923*(0.944^61)-1177 #Finger millet N response function
Y_R1=5665-828*(0.871^30)-4837 #Rice P response function
Y_M1=4474-770*(0.898^36)-3704 #Maize P response function
Y_B1=1138-263*(0.848^22)-875 #Bean P response function
Y_FM1=2101-537*(0.798^19)-1564 #Finger millet P response function
Y_PP=2538-487*(0.758^19)-487 #Pigeon Pea P response function
Y_M2=2502-251*(0.94^36)-2251 #Maize K response function
Y_PP1=2535-127*(0.666^10)-2408 #Pigeon Pea K response function
P_R=700;P_M=700;P_B=1000;P_FM=700;P_PP=1500 #Expected commodity prices
P_N=1100; P_P=1200;P_K=1200; #Nutrient cost computed from fertilizer prices per Kg
P1=(Y_R*P_R-120*P_N)+(Y_M*P_M-120*P_N)+(Y_B*P_B-68*P_N)+(Y_FM*P_FM-61*P_N)+
(Y_R1*P_R-30*P_P)+(Y_M1*P_M-36*P_P)+(Y_B1*P_B-22*P_P)+(Y_FM1*P_FM-19*P_P)+(Y_PP*P_PP-19*P_P)+
(Y_M2*P_M-36*P_K)+(Y_PP1*P_PP-10*P_K)
P1
#600,000
Y_R=5625-2897*(0.966^116)-2728 #Rice N response function
Y_M=3159-1191*(0.976^117)-1968 #Maize N response function
Y_B=1415-715*(0.950^67)-700 #Bean N response function
Y_FM=2100-923*(0.944^60)-1177 #Finger millet N response function
Y_R1=5665-828*(0.871^31)-4837 #Rice P response function
Y_M1=4474-770*(0.898^36)-3704 #Maize P response function
Y_B1=1138-263*(0.848^22)-875 #Bean P response function
Y_FM1=2101-537*(0.798^18)-1564 #Finger millet P response function
Y_PP=2538-487*(0.758^18)-487 #Pigeon Pea P response function
Y_M2=2502-251*(0.94^35)-2251 #Maize K response function
Y_PP1=2535-127*(0.666^10)-2408 #Pigeon Pea K response function
P_R=700;P_M=700;P_B=1000;P_FM=700;P_PP=1500 #Expected commodity prices
P_N=1100; P_P=1200;P_K=1200; #Nutrient cost computed from fertilizer prices per Kg
P2=(Y_R*P_R-116*P_N)+(Y_M*P_M-117*P_N)+(Y_B*P_B-67*P_N)+(Y_FM*P_FM-60*P_N)+
(Y_R1*P_R-31*P_P)+(Y_M1*P_M-36*P_P)+(Y_B1*P_B-22*P_P)+(Y_FM1*P_FM-18*P_P)+(Y_PP*P_PP-18*P_P)+
(Y_M2*P_M-35*P_K)+(Y_PP1*P_P-10*P_K)
P2
#400,000
Y_R=5625-2897*(0.966^84)-2728 #Rice N response function
Y_M=3159-1191*(0.976^72)-1968 #Maize N response function
Y_B=1415-715*(0.950^45)-700 #Bean N response function
Y_FM=2100-923*(0.944^40)-1177 #Finger millet N response function
Y_R1=5665-828*(0.871^22)-4837 #Rice P response function
Y_M1=4474-770*(0.898^25)-3704 #Maize P response function
Y_B1=1138-263*(0.848^14)-875 #Bean P response function
Y_FM1=2101-537*(0.798^14)-1564 #Finger millet P response function
Y_PP=2538-487*(0.758^14)-487 #Pigeon Pea P response function
Y_M2=2502-251*(0.94^16)-2251 #Maize K response function
Y_PP1=2535-127*(0.666^7)-2408 #Pigeon Pea K response function
P_R=700;P_M=700;P_B=1000;P_FM=700;P_PP=1500 #Expected commodity prices
P_N=1100; P_P=1200;P_K=1200; #Nutrient cost computed from fertilizer prices per Kg
P3=(Y_R*P_R-84*P_N)+(Y_M*P_M-72*P_N)+(Y_B*P_B-45*P_N)+(Y_FM*P_FM-40*P_N)+
(Y_R1*P_R-22*P_P)+(Y_M1*P_M-25*P_P)+(Y_B1*P_B-14*P_P)+(Y_FM1*P_FM-14*P_P)+(Y_PP*P_PP-14*P_P)+
(Y_M2*P_M-16*P_K)+(Y_PP1*P_P-7*P_K)
P3
#200,000
Y_R=5625-2897*(0.966^52)-2728 #Rice N response function
Y_M=3159-1191*(0.976^22)-1968 #Maize N response function
Y_B=1415-715*(0.950^23)-700 #Bean N response function
Y_FM=2100-923*(0.944^21)-1177 #Finger millet N response function
Y_R1=5665-828*(0.871^13)-4837 #Rice P response function
Y_M1=4474-770*(0.898^14)-3704 #Maize P response function
Y_B1=1138-263*(0.848^8)-875 #Bean P response function
Y_FM1=2101-537*(0.798^9)-1564 #Finger millet P response function
Y_PP=2538-487*(0.758^10)-487 #Pigeon Pea P response function
Y_M2=2502-251*(0.94^0)-2251 #Maize K response function
Y_PP1=2535-127*(0.666^0)-2408 #Pigeon Pea K response function
P_R=700;P_M=700;P_B=1000;P_FM=700;P_PP=1500 #Expected commodity prices
P_N=1100; P_P=1200;P_K=1200; #Nutrient cost computed from fertilizer prices per Kg
P4=(Y_R*P_R-52*P_N)+(Y_M*P_M-22*P_N)+(Y_B*P_B-23*P_N)+(Y_FM*P_FM-21*P_N)+
(Y_R1*P_R-13*P_P)+(Y_M1*P_M-14*P_P)+(Y_B1*P_B-8*P_P)+(Y_FM1*P_FM-9*P_P)+(Y_PP*P_PP-10*P_P)+
(Y_M2*P_M-0*P_K)+(Y_PP1*P_P-0*P_K)
P4
#100000
Y_R=5625-2897*(0.966^29)-2728 #Rice N response function
Y_M=3159-1191*(0.976^0)-1968 #Maize N response function
Y_B=1415-715*(0.950^13)-700 #Bean N response function
Y_FM=2100-923*(0.944^10)-1177 #Finger millet N response function
Y_R1=5665-828*(0.871^7)-4837 #Rice P response function
Y_M1=4474-770*(0.898^7)-3704 #Maize P response function
Y_B1=1138-263*(0.848^0)-875 #Bean P response function
Y_FM1=2101-537*(0.798^6)-1564 #Finger millet P response function
Y_PP=2538-487*(0.758^7)-487 #Pigeon Pea P response function
Y_M2=2502-251*(0.94^0)-2251 #Maize K response function
Y_PP1=2535-127*(0.666^0)-2408 #Pigeon Pea K response function
P_R=700;P_M=700;P_B=1000;P_FM=700;P_PP=1500 #Expected commodity prices
P_N=1100; P_P=1200;P_K=1200; #Nutrient cost computed from fertilizer prices per Kg
P5=(Y_R*P_R-29*P_N)+(Y_M*P_M-0*P_N)+(Y_B*P_B-13*P_N)+(Y_FM*P_FM-10*P_N)+
(Y_R1*P_R-7*P_P)+(Y_M1*P_M-7*P_P)+(Y_B1*P_B-0*P_P)+(Y_FM1*P_FM-6*P_P)+(Y_PP*P_PP-7*P_P)+
(Y_M2*P_M-0*P_K)+(Y_PP1*P_P-0*P_K)
P5
PS=c(P1,P2,P3,P4,P5)
PS
(P1-1000000)/1000000
(P2-600000)/600000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment