Re: [R] Extend my code to run several data at once.

2011-07-27 Thread EdBo
Date: Sat, 23 Jul 2011 14:43:30 To: EdBo Subject: Re: Extend my code to run several data at once. If you just want to apply the function over successive columns of a data frame use apply(name.of.data.frame, 2 , llik) Daniel EdBo wrote: > > Hi > > I have a code that calcul

[R] Extend my code to run several data at once.

2011-07-23 Thread EdBo
Hi I have a code that calculate maximisation using optimx and it is working just fine. I want to extend the code to run several colomns of R_j where j runs from 1 to 200. If I am to run the code in its current state, it means I will have to run it 200 times manually. May you help me adjust it to a

[R] error on my loop function

2011-07-16 Thread EdBo
> t Hi I have to matrices t and y below. I want correlation of columns (a,d) (b,e) and (c,f). The correlation should be for the first 3 rows of matrix t against matrix y; and then the last 3 i.e a loop function. I have a code I created below but its giving me an error, surprisingly the the indiv

Re: [R] loop in optim

2011-07-07 Thread EdBo
values of the next loop because I did not know I could do that but I think it will help quicken the maximisation. Edward UCT On 7 July 2011 13:40, John C Nash [via R] wrote: > 2 comments below. > > On 07/07/2011 06:00 AM, [hidden email] wrote: >> Date: Wed, 6 Jul 2011 20:39:19 -0700

Re: [R] loop in optim

2011-07-06 Thread EdBo
I have one last theoretical question, I did not adjust my code prior so that it maximise the likehood function. I googled that to make optim maximise you multiply fn by -1. In my code, would that be the same as saying "-sum" on the "sum" part of my code (see below)? llik = function(x) {

Re: [R] loop in optim

2011-07-06 Thread EdBo
sigma_j b_j Run:1 0.1088116 0.1621605 -1.554167e-24 0.969153 Run:2 0.1088116 0.1621605 -1.554167e-24 0.969153 Run:3 0.1088116 0.1621605 -1.554167e-24 0.969153 Run:4 0.1088116 0.1621605 -1.554167e-24 0.959875 On 6 July 2011 11:46, Berend Hasselman [via R] wrote: > EdBo wrote: > You ar

Re: [R] loop in optim

2011-07-05 Thread EdBo
uot; Date: Tue, 5 Jul 2011 20:28:09 To: EdBo Subject: Re: loop in optim On Tue, Jul 5, 2011 at 7:07 PM, EdBo wrote: > Hi Josh > > I have run the code and the structure of the output is what I wanted. > However, the code is giving an identical result for all runs. Right because the obj

Re: [R] loop in optim

2011-07-05 Thread EdBo
Hi Josh I have run the code and the structure of the output is what I wanted. However, the code is giving an identical result for all runs. I have attached the code I ran below as well as the output. I have just changed number of runs to match with the size of the data. a=read.table("D:/hope.txt

Re: [R] loop in optim

2011-07-04 Thread EdBo
Hi I have re-worked on my likelihood function and it is now working(#the code is below#). May you help me correct my loop function. I want optim to estimates al_j; au_j; sigma_j; b_j by looking at 0 to 20, 21 to 40, 41 to 60 data points. The final result should have 4 columns of each of th

[R] loop in optim

2011-07-04 Thread EdBo
Hi May you help me correct my loop function. I want optim to estimates al_j; au_j; sigma_j; b_j by looking at 0 to 20, 21 to 40, 41 to 60 data points. The final result should have 4 columns of each of the estimates AND 4 rows of each of 0 to 20, 21 to 40, 41 to 60. ###MY code is n=20 runs=4 o

Re: [R] Hint improve my code

2011-07-03 Thread EdBo
Please also consider the code below. My attempt to loop through the rows of R_j so that I do not force if() to work on a vector. > llik <- function(par, R_j, R_m) { + al_j <- par[1] + au_j <- par[2] + sigma_j <- par[3] + b_j <- par[4] + + n=2 + runs=5 + est1=

Re: [R] Hint improve my code

2011-07-03 Thread EdBo
e best estimate of each of the parameters. On 3 July 2011 06:59, Berend Hasselman [via R] wrote: > EdBo wrote: > 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

[R] Hint improve my code

2011-07-02 Thread EdBo
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(