I have the dataframe DATA1 as shown for a few rows:
structure(list(S = c(12, 12, 15, 15, 15, 9, 9), UG = c(84, 84,
84, 84, 84, 84, 84), CSi = c(0.487181441487271, 0.623551085193489,
0.505057492620447, 0.704318096382286, 0.575388552145397, 0.400731851672016,
0.490770631112789), N_l = c(1, 3, 1, 3, 5, 1, 3), N_b = c(5,
5, 5, 5, 5, 5, 5), m = c(1.2, 0.85, 1.2, 0.85, 0.65, 1.2, 0.85
), A = c(-12, -12, -15, -15, -15, -9, -9), x.sqr = c(1440, 1440,
2250, 2250, 2250, 810, 810), e_1 = c(21.8, 21.8, 29, 29, 29,
14.6, 14.6), e_2 = c(0, 9.8, 0, 17, 17, 0, 2.6), e_3 = c(0, -2.2,
0, 5, 5, 0, -9.4), e_4 = c(0, 0, 0, 0, -7, 0, 0), e_5 = c(0,
0, 0, 0, -19, 0, 0), K_g = c(6340598.65753794, 6340598.65753794,
6429472.98493414, 6429472.98493414, 6429472.98493414, 6296482.86883766,
6296482.86883766), stiff.girder = c(0.517988322166146, 0.517988322166146,
0.643978136780243, 0.643978136780243, 0.643978136780243, 0.416960174810184,
0.416960174810184), stiff.deck = c(276.422028597005, 276.422028597005,
147.89589537037, 147.89589537037, 147.89589537037, 642.725952664716,
642.725952664716)), row.names = c(10L, 30L, 50L, 70L, 90L, 110L,
130L), class = "data.frame")
I try to run the function proposed with nonlinear regression such as:
Proposed <- function(N_b,N_l,m,A,x.sqr,e_1,e_2,e_3,e_4,e_5,K_g,a,b,c,d) {
e <- data.frame(e_1,e_2,e_3,e_4,e_5,N_l)
CSi <- m * ((N_l/N_b) * ((a*K_g)^b) +
(max(A * apply(e,1,function(v) combn(v[1:5],v["N_l"],sum))) / x.sqr) * ((c*K_g)^d))
return(CSi)
}
library(minpack.lm)
G_1 <- nlsLM(CSi ~ Proposed(N_b,N_l,m,A,x.sqr,e_1,e_2,e_3,e_4,e_5,K_g,a,b,c,d),
data = DATA1,
start = c(a = 0.01, b = 0.01, c = 0.01, d = 0.01))
I get the error:
Error in A * apply(e, 1, function(v) combn(v[1:5], v["N_l"], sum)) :
non-numeric argument to binary operator