Displaying 4 results from an estimated 4 matches for "index_start".
2011 Jul 23
1
Extend my code to run several data at once.
...runs=133/20+1
out <- matrix(NA, nrow = runs, ncol = 4,
dimnames = list(paste("Qtr:", 1:runs , sep = ''),
c("al_j", "au_j", "sigma_j", "b_j")))
## Estimate parameters based on rows 0-20, 21-40, 41-60 of afull
for (i in 1:runs) {
index_start=20*(i-1)+1
index_end= 20*i
a=afull[index_start:index_end,]
out[i, ] <- optimx(llik,par = start.par,method = "Nelder-Mead",
control=list(maximize=TRUE) )[[1]][[1]]
}
## Yields
> out
al_j au_j sigma_j b_j
Qtr:1 0.0012402032 0.001082986 0.0...
2011 Jul 06
1
Group Data indexed by n Variables
...b_j*a$R_m,sd=sqrt(sigma_j^2))-
> pnorm(au_j,mean=b_j*a$R_m,sd=sqrt(sigma_j^2)))))
>
> )
>
> }
>
> start.par = c(0, 0, 0.01, 1)
> out1 = optim(llik, par=start.par, method="Nelder-Mead")
>
>
> for (i in 1: runs)
> {
> index_start=20*(i-1)+1
> index_end= 20*i
> out[i]=out1[index_start:index_end]
> }
> out
>
>
> Thank you in advance
>
> Edward
> UCT
> ####My data
>
> R_j R_m
> -0.0625 0.002320654
> 0 -0.004642807
> 0.033333333 0.005936332...
2011 Jul 04
3
loop in optim
...))^2,
-log(pnorm(au_j,mean=b_j*a$R_m,sd=sqrt(sigma_j^2))-
pnorm(au_j,mean=b_j*a$R_m,sd=sqrt(sigma_j^2)))))
)
}
start.par = c(0, 0, 0.01, 1)
out1 = optim(llik, par=start.par, method="Nelder-Mead")
for (i in 1: runs)
{
index_start=20*(i-1)+1
index_end= 20*i
out[i]=out1[index_start:index_end]
}
out
Thank you in advance
Edward
UCT
####My data
R_j R_m
-0.0625 0.002320654
0 -0.004642807
0.033333333 0.005936332
0.032258065 0.001060848
0 0.007114057
0.015625 0.005581558
0 0.002974794
0.015384615 0.004215271
0.060606061...
2011 Jul 03
3
Hint improve my code
Hi
I have developed the code below. I am worried that the parameters I want to
be estimated are "not being found" when I ran my code. Is there a way I can
code them so that R recognize that they should be estimated.
This is the error I am getting.
> out1=optim(llik,par=start.par)
Error in pnorm(au_j, mean = b_j * R_m, sd = sigma_j) :
object 'au_j' not found
#Yet