Re: [R] (no subject)

From: bartjoosen <bartjoosen_at_hotmail.com>
Date: Mon, 17 Mar 2008 08:09:55 -0700 (PDT)

There are several mistakes:
Why are you using only p[1], p[2]?
Afterwards you try (for i in 1:10) p[i] so you should go to p[10]? Then you should make a pnew wich holds 10 values, so pnew[i]

This should get you back on track

Bart

Kathy Maher wrote:
>
> Hi,
>
> I am trying to use the Fisher scoring method with a geometric
> distribution,
> with p = .07, 100 observations from the geom distrib, and 10 iterations.
> I cannot quite get the code to work.
> Can anyone see the mistake?
>
>
>
>
> n <- 100
>
> p <- 0.07
>
> x <- rgeom(n, p)
>
> s <- sum(x)
>
> f <- function(x, p) p*(1-p)^x
>
> L <- function(p) p^n*(1-p)^s
>
> logL <- function(p) n*log(p)+s*(log(1-p))
>
> logLprime <- function(p) (n/p)-(s/(1-p))
>
>
>
> I <- n/p^2*(1-p)
>
> iter <- 10
>
> p[1] <- .06
>
> p[2] <- .11
>
>
>
>
>
> for (i in 1:10)
>
> {
>
> pnew <- p[i]+logLprime(p[i])/I*(p[i])
>
> }
>
> [[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.
>
>

-- 
View this message in context: http://www.nabble.com/%28no-subject%29-tp16084593p16093575.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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.
Received on Mon 17 Mar 2008 - 15:15:54 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 17 Mar 2008 - 15:30:22 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive