Hi,

 

I think the function MonteCarloOption in package ‘fOptions’ has something
wrong. The original function is 

 

function (delta.t, pathLength, mcSteps, mcLoops, init = TRUE, 

    innovations.gen, path.gen, payoff.calc, antithetic = TRUE, 

    standardization = FALSE, trace = TRUE, ...) 

{

    delta.t <<- delta.t

    if (trace) 

        cat("\nMonte Carlo Simulation Path:\n\n")

    iteration = rep(0, length = mcLoops)

    cat("\nLoop:\t", "No\t")

    for (i in 1:mcLoops) {

        if (i > 1) 

            init = FALSE

        eps = innovations.gen(mcSteps, pathLength, init = init, 

            ...)

        if (antithetic) 

            eps = rbind(eps, -eps)

        if (standardization) 

            eps = (eps - mean(eps))/sqrt(var(as.vector(eps)))

        path = t(path.gen(eps))

        payoff = NULL

        for (j in 1:dim(path)[1]) payoff = c(payoff, payoff.calc(path[, 

            j]))

        iteration[i] = mean(payoff)

        if (trace) 

            cat("\nLoop:\t", i, "\t:", iteration[i], sum(iteration)/i)

    }

    if (trace) 

        cat("\n")

    iteration

}

 

But in line ‘for (j in 1:dim(path)[1]) payoff = c(payoff,
payoff.calc(path[,j]))’ the condition of ‘for’ should be ‘j in
1:dim(path)[2]’ since dim(path)[2] is the mcStep.

 

Do I misunderstand the function?

 

                                                                Hsiao-nan
Cheung

                                                                2008/8/4

 

 


	[[alternative HTML version deleted]]

