Having trouble setting up these integral terms in R. I created "term1" to more easily insert it into the integral code, but I keep getting various error messages after trying different codes. any help or spotting the issue would be appreciated.
##
S<-readline(prompt="Enter underlying instrument price:")
X<-readline(prompt="Enter strike price:")
V<-readline(prompt="Enter absolute volatility in dollars:")
r<-readline(prompt="Enter risk-free rate (%):")
q<-readline(prompt="Enter dividend yield (%):")
T<-readline(prompt="Enter time to maturity, in fraction of years:")
t=0
##
S<-as.numeric(S)
X<-as.numeric(X)
V<-as.numeric(V)
r<-as.numeric(r)/100
q<-as.numeric(q)/100
T<-as.numeric(T)
##Bond Price
B<-exp(r*(T-t))
##Volatility
vol<-function(start,end,rate,yield,B) {
if(r==q){
V*(sqrt((B-1)/(2*(r-q))))
}
else{
V*(sqrt(T-t))
}
}
##d
d<-(S*B-X)/vol()
##N(d)
term1<-(exp(-(r^2)/2)/sqrt(2*pi))
#Call
Nc<-function(term1){
Nc<-((integrate(term1,-Inf,d)))}
#Put
Np<-function(term1){
Np<-(-(integrate(term1,-Inf,d)))}
These are the errors i am getting
> Nc(term1)
Error in get(as.character(FUN), mode = "function", envir = envir) :
object 'term1' of mode 'function' was not found
> Nc()
Error in match.fun(f) : argument "term1" is missing, with no default