Re: [R] mle question

2011-02-07 Thread Antje Niederlein
Hello,

is there somebody who can help me with my question (see below)?

Antje


On 1 February 2011 09:09, Antje Niederlein niederlein-rs...@yahoo.de wrote:
 Hello,


 I tried to use mle to fit a distribution(zero-inflated negbin for
 count data). My call is very simple:

 mle(ll)

 ll() takes the three parameters, I'd like to be estimated (size, mu
 and prob). But within the ll() function I have to judge if the current
 parameter-set gives a nice fit or not. So I have to apply them to
 observation data. But how does the method know about my observed data?
 The mle()-examples define this data outside of this method and it
 works. For a simple example, it was fine but when it comes to a loop
 (tapply) providing different sets of observation data, it doesn't work
 anymore. I'm confused - is there any way to do better?

 Here is a little example which show my problem:

 # R-code -

 lambda.data - runif(10,0.5,10)

 ll - function(lambda = 1) {
        cat(x in ll(),x,\n)
        y.fit - dpois(x, lambda)

        sum( (y - y.fit)^2 )

        }

 lapply(1:10, FUN = function(x){

        raw.data - rpois(100,lambda.data[x])

        freqTab - count(raw.data)
        x - freqTab$x
        y - freqTab$freq / sum(freqTab$freq)
        cat(x in lapply, x,\n)
        fit - mle(ll)

        coef(fit)
        })

 Can anybody help?

 Antje


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] mle question

2011-02-07 Thread Antje Niederlein
Hello,

is there somebody who can help me with my question (see below)?

Antje



 On 1 February 2011 09:09, Antje Niederlein niederlein-rs...@yahoo.de wrote:
 Hello,


 I tried to use mle to fit a distribution(zero-inflated negbin for
 count data). My call is very simple:

 mle(ll)

 ll() takes the three parameters, I'd like to be estimated (size, mu
 and prob). But within the ll() function I have to judge if the current
 parameter-set gives a nice fit or not. So I have to apply them to
 observation data. But how does the method know about my observed data?
 The mle()-examples define this data outside of this method and it
 works. For a simple example, it was fine but when it comes to a loop
 (tapply) providing different sets of observation data, it doesn't work
 anymore. I'm confused - is there any way to do better?

 Here is a little example which show my problem:

 # R-code -

 lambda.data - runif(10,0.5,10)

 ll - function(lambda = 1) {
        cat(x in ll(),x,\n)
        y.fit - dpois(x, lambda)

        sum( (y - y.fit)^2 )

        }

 lapply(1:10, FUN = function(x){

        raw.data - rpois(100,lambda.data[x])

        freqTab - count(raw.data)
        x - freqTab$x
        y - freqTab$freq / sum(freqTab$freq)
        cat(x in lapply, x,\n)
        fit - mle(ll)

        coef(fit)
        })

 Can anybody help?

 Antje



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] mle question

2011-02-01 Thread Antje Niederlein
Hello,


I tried to use mle to fit a distribution(zero-inflated negbin for
count data). My call is very simple:

mle(ll)

ll() takes the three parameters, I'd like to be estimated (size, mu
and prob). But within the ll() function I have to judge if the current
parameter-set gives a nice fit or not. So I have to apply them to
observation data. But how does the method know about my observed data?
The mle()-examples define this data outside of this method and it
works. For a simple example, it was fine but when it comes to a loop
(tapply) providing different sets of observation data, it doesn't work
anymore. I'm confused - is there any way to do better?

Here is a little example which show my problem:

# R-code -

lambda.data - runif(10,0.5,10)

ll - function(lambda = 1) {
cat(x in ll(),x,\n)
y.fit - dpois(x, lambda)

sum( (y - y.fit)^2 )

}

lapply(1:10, FUN = function(x){

raw.data - rpois(100,lambda.data[x])

freqTab - count(raw.data)
x - freqTab$x
y - freqTab$freq / sum(freqTab$freq)
cat(x in lapply, x,\n)
fit - mle(ll)

coef(fit)
})

Can anybody help?

Antje

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] mle() question

2009-05-22 Thread Stephen Collins
Is there a way to code the mle() function in library stats4 such that it 
switches optimizing methods midstream (i.e. BFGS to Newton and back to 
BFGS, etc.)?

Thanks,
 
Stephen Collins, MPP | Analyst
Health  Benefits | Aon Consulting

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.