Thanks Berend.
Yes that is right. I should get 5 values(results) of x_e because I have
five values of X. I wonder how can I fix it?
On 30/08/2013 13:13, Berend Hasselman wrote:
On 30-08-2013, at 09:44, Jonsson wrote:
I have three datasets that I want to compute the errors between them using
On 30-08-2013, at 09:44, Jonsson wrote:
> I have three datasets that I want to compute the errors between them using
> linear regression.for this, I want to iterate to reach certain criteria for
> the calibration. if changes become smaller than eps the iteration is
> successful, hence stop and w
I have three datasets that I want to compute the errors between them using
linear regression.for this, I want to iterate to reach certain criteria for
the calibration. if changes become smaller than eps the iteration is
successful, hence stop and write parameters into cal:eps=0.1 if number
of i
I'm not here to walk you through learning how to plot: but once again
does this work?
curve(loglikelihood(x, bout = 0.1))
If you want to plot a function of two independent variables, you'll
have to look into the various ways of doing so. Please do read section
12 of "An Introduction to R" which y
Thanks Michael,
I am able to find the very nice plot of the function we discussed but still
have the problem of ploting the function loglikelihood(aout,bout) versus
aout posted in the initial massage.
Best
On Tue, Dec 6, 2011 at 10:40 AM, Gyanendra Pokharel <
gyanendra.pokha...@gmail.com> wrote:
You want a plot of s = sum(log(b^2 + (x-a)^2)) as a function of a or
am I missing something? You do it just like any other R plot: pick
some values of a, evaluate s for each of them (a little tricky if you
use my vectorized version due to the implicit use of the recycling
rule but very easy with y
Yes Michael, it works well and I got the result what I want but it totally
depends on how reliable result do I want. When I take very high rho (near
about 1) and very low psi, it takes very long time may be it gives us more
accurate result. But for lower rho and higher psi, it gives immediately,
an
So I just ran your code verbatim with this one change and it finished
in less than 10 seconds. However, even without the change it doesn't
take more than 15 seconds: what exactly lead you to believe this was
an infinite loop?
Michael
On Tue, Dec 6, 2011 at 12:03 AM, R. Michael Weylandt
wrote:
>
Off the bat I'd suggest you vectorize loglikelihood as a simple one liner:
sum(log(b^2 + (x-a)^2))
That alone will speed up your function many times over: I'll look at the big
function in more detail tomorrow.
Michael
On Dec 5, 2011, at 10:37 PM, Gyanendra Pokharel
wrote:
> Thanks Michael
I ma sorry, I miss typed the function, it should be "loglikelihood" instead.
On Mon, Dec 5, 2011 at 10:37 PM, Gyanendra Pokharel <
gyanendra.pokha...@gmail.com> wrote:
> Thanks Michael
> Lets figure out the problem by using the following function. I found the
> same problem in this code too.
>
>
Thanks Michael
Lets figure out the problem by using the following function. I found the
same problem in this code too.
loglikehood <- function(a, b = 0.1, x = c(-4.2, -2.85, -2.3, -1.02, 0.7,
0.98, 2.72, 3.5))
{
s <- 0
for(i in 1:length(x)){
s <- s + log(b^2 + (x[i] - a)^2)
}
s
}
loglikel
It's not necessarily equivalent to your "loglikelihood" function but since that
function wasn't provided I couldn't test it.
My broader point is this: you said the problem was that the loop ran endlessly:
I showed it does not run endlessly for at least one input so at least part of
the problem
Yes, your function out<- epiann(f = function(a,b) log(dnorm(a)*dnorm(b))),
N = 10) works well.
But why you are changing the loglikelihood function to f = function(a,b)
log(dnorm(a)*dnorm(b))? how it is equivalent to loglikelihood? is there any
mathematical relation? I also want to see the plot of
If you run
out<- epiann(f = function(a,b) log(dnorm(a)*dnorm(b))), N = 10)
It takes less than 0.5 seconds so there's no problem I can see:
perhaps you want to look elsewhere to get better speed (like Rcpp or
general vectorization), or maybe your loglikihood is not what's
desired, but there's no p
Yes, I checked the acceptprob, it is very high but in my view, the while
loop is not stopping, so there is some thing wrong in the use of while
loop. When I removed the while loop, it returned some thing but not the
result what I want. When i run the while loop separately, it never stops.
On Mon,
Your code is not reproducible nor minimal, but why don't you put a
command print(acceptprob) in and see if you are getting reasonable
values. If these values are extremely low it shouldn't surprise you
that your loop takes a long time to run.
More generally, read up on the use of print() and brows
I forgot to upload the R-code in last email, so heare is one
epiann <- function(T0 = 1, N=1000, ainit=1, binit=1,rho = 0.99, amean = 3,
bmean=1.6, avar =.1, bvar=.1, f){
moving <- 1
count <- 0
Temp <- T0
aout <- ainit
bout <- binit
while(moving > 0)
Hi all,
I have the following code,
When I run the code, it never terminate this is because of the while loop i
am using. In general, if you need a loop for which you don't know in
advance how many iterations there will be, you can use the `while'
statement so here too i don't know the number how ma
18 matches
Mail list logo