Niloofar.Javanrouh <javanrouh_n <at> yahoo.com> writes: > > > hello, > i want to differentiate of L with respect to b > when: > > L= k*ln (k/(k+mu)) + sum(y) * ln (1-(k/mu+k)) > #(negative binomial ln likelihood) > and > ln(mu/(mu+k)) = a+bx #link function > > how can i do it in R? > thank you. >
R has a couple of functions for differentiation, D() and deriv(), but this is probably a case where it would actually be simpler to do it yourself by hand. If you insist on doing it in R, you can either use the chain rule (i.e. compute d(mu)/d(b)*d(L)/d(mu)) or you can make a big ugly expression where you substitute the expression for mu(b) into the expression for L. In either case you'll have to solve your link expression for mu. Wolfram Alpha might help too. good luck Ben Bolker ______________________________________________ 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.