I saw a similar question but I still don't fully understand how to implement
optim.
Can someone help me out with this?
Thanks. Keun-Hyung

> vol<-rep(c(0.03, 0.5, 2, 4, 8, 16, 32), 3)
> time<-rep(c(2,4,8),each=7)
> p.mated<-c(0.47, 0.48, 0.43, 0.43, 0.26, 0.23, "null", 0.68, 0.62, 0.64,
0.58, 0.53, 0.47,
+ 0.24, 0.8, 0.79, 0.71, 0.56, 0.74, 0.8, 0.47)
> eury<-as.data.frame(cbind(vol, time, p.mated))
> eury<-eury[-7,]; eury
    vol time p.mated
1  0.03    2    0.47
2   0.5    2    0.48
3     2    2    0.43
4     4    2    0.43
5     8    2    0.26
6    16    2    0.23
8  0.03    4    0.68
9   0.5    4    0.62
10    2    4    0.64
11    4    4    0.58
12    8    4    0.53
13   16    4    0.47
14   32    4    0.24
15 0.03    8     0.8
16  0.5    8    0.79
17    2    8    0.71
18    4    8    0.56
19    8    8    0.74
20   16    8     0.8
21   32    8    0.47
>
> p0<- c(f=0.87, b=0.1, c=150)
> eury.fit <- function (f, time, vol)
+ {
+             f<-p[1]; b<-p[2]; c<-p[3]
+             p.mated = p[1] * ( (1 -
exp(-p[2]*time))-(p[2]/(p[2]-(p[3]/vol)))
+                            * (exp(-p[3]/vol*time)-exp(-p[2]*time)))
+ }
> eury.opt<- optim(p0, fn=eury.fit, NULL, method = "BFGS", hessian = TRUE)
Error in fn(par, ...) : argument "time" is missing, with no default

	[[alternative HTML version deleted]]

