[R] regression for poisson distributed data

Kjetil Halvorsen kjetilbrinchmannhalvorsen at gmail.com
Tue Apr 3 17:43:58 CEST 2012


¿Just write down the loglikelihood function and send it to optim?

Kjetil

On Tue, Apr 3, 2012 at 8:58 AM, Joachim Audenaert
<Joachim.Audenaert at pcsierteelt.be> wrote:
> Hello all,
>
> I would like to get parameter estimates for different models. For one of
> them I give the code in example. I am estimating the parameters (i,j and
> k) with the nls function, which sees the error distribution as normal, I
> would however like to do the same as nls with the assumption that the
> errors are poisson distributed.
>
> Is there a way to do this with R? Are there packages designed for this? I
> tried with the gnm package, but don't understand how to transform my
> equation to a generalised equation. Is there an option for nls to choose
> family = poisson?
>
> Lower in the mail the code with the model and visualisations I use to
> check my results. I also copied the test dataset from my txt file.
>
> I am using R 2.15 and Rstudio to visualise it.
>
>
> plot(FR~N0)
> x <-
> nls(FR~(exp(i+j*N0)/(1+exp(i+j*N0)))*(k*N0/(k+N0)),start=list(i=0.02,j=0.002,k=6))
> summary(x)
> hatx <- predict(x)
> lines(spline(N0,hatx))
>
> N0      FR
> 10      2
> 10      3
> 10      2
> 10      4
> 10      2
> 10      2
> 10      1
> 10      2
> 10      2
> 10      2
> 20      2
> 20      3
> 20      3
> 20      3
> 20      4
> 20      2
> 20      4
> 20      2
> 20      3
> 20      2
> 30      1
> 30      2
> 30      3
> 30      4
> 30      5
> 30      6
> 30      2
> 30      3
> 30      2
> 30      2
> 40      2
> 40      3
> 40      3
> 40      6
> 40      5
> 40      4
> 40      3
> 40      3
> 40      2
> 40      3
> 50      4
> 50      5
> 50      2
> 50      3
> 50      7
> 50      5
> 50      4
> 50      3
> 50      4
> 50      5
> 60      5
> 60      6
> 60      8
> 60      4
> 60      4
> 60      3
> 60      2
> 60      2
> 60      5
> 60      4
>
> Kind Regards
> Joachim
>
> Don't waste paper! Think about the environment before printing this e-mail
>
> ______________________________________
>
> Joachim Audenaert
> Adviesdienst Gewasbescherming
> Proefcentrum voor Sierteelt
> Schaessestraat 18
> B-9070 Destelbergen
> Tel. +32 9 353 94 71
> Fax +32 9 353 94 95
> E-mail: joachim.audenaert at pcsierteelt.be
> www.pcsierteelt.be
> ______________________________________
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list