Trying to plot a sequence against a function, and am currently finding it difficult to achieve much given the error that keeps popping up. Any help on the issue will be greatly appreciated.
policy_FunE <- function(sum, time, term, age, rate)
return(sum*AExn(AM92Ul, x = age + time, n = term - time, i = rate) -
sum * AExn(AM92Ul, x = age, n = term, i = rate)/axn(AM92Ul, x = age, n = term, i = rate) *
axn(AM92Ul, x = age + time, n = term - time, i = rate))
term <- 0:40
PVs <- matrix(rep(0,41),nrow=1)
for (k in 0:40){
PVs[,k] = apply(as.matrix(term), MARGIN = 2, FUN = policy_FunE,
sum = 500000, time = k, term = 40, age = 25, rate = 0.04)
}
plot(term, PVs[1,], ylim=c(min(PVs),max(PVs)))
> for (k in 0:40){
+ PVs[,k] = apply(as.matrix(term), MARGIN = 2, FUN = policy_FunE,
+ sum = 500000, time = k, term = 40, age = 25, rate = 0.04)
+ }
Error in FUN(newX[, i], ...) : unused argument (newX[, i])
question from:
https://stackoverflow.com/questions/65850883/quite-lost-with-error-error-in-funnewx-i-unused-argument-newx-i 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…