[R] maxNR - Error in p(a, b) : element 1 is empty; the part of the args list of '*' being evaluated was: (b, t)
4-real
danielkjaer90 at gmail.com
Mon Mar 22 16:31:59 CET 2010
Hello everyone...
We were trying to implement the Newton-Raphson method in R, and estimate the
parameters a and b, of a function, F, however we can't seem to implement
this the right way. Hope you can show me the right way to do this. I think
what we want R to do is to read the data from the website and then peform
maxNR on the function, F. Btw the version of R being used is "RGui for
Windows" if it helps to know this.
R-code below:
library(maxLik)
> require(maxLik)
>
> x <-
> read.table('http://www.math.ku.dk/kurser/2008-09/blok4/stat2/doku/data/Eksempel_6_3.txt',
> header = TRUE);
> t <- log(x$Koncentration);
> X <- x$Status;
>
> p <- function(a,b) exp(a+b*t)/(1+exp(a+b*t));
> S <- sum(X);
> SP <- sum(t*X);
>
> F <- function(a,b) {
+ c(sum(p(a,b)) - S,
+ sum(t*p(a,b)) - SP)
+ }
>
>
> z <- maxNR(F, start=1, print.level=2)
Error in p(a, b) : element 1 is empty;
the part of the args list of '*' being evaluated was:
(b, t)
>
Thanks and best regards.
--
View this message in context: http://n4.nabble.com/maxNR-Error-in-p-a-b-element-1-is-empty-the-part-of-the-args-list-of-being-evaluated-was-b-t-tp1677790p1677790.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list