similar to: Understanding the sequence of events when calling the R dpois function

Displaying 20 results from an estimated 2000 matches similar to: "Understanding the sequence of events when calling the R dpois function"

2018 Jun 01
1
Understanding the sequence of events when calling the R dpois function
Chuck and Greg, Thanks a lot for your help! I have a much better understanding now of what is happening ?under the hood?. Kind Regards, Jason > On 31 May 2018, at 20:08, Greg Minshall <minshall at acm.org> wrote: > > Jason, > > as Chuck Berry (to whom, *thanks* for 'do {...} while(0)'!) suggested, > using grep, or even grep executed from find, such as >
2015 Nov 03
1
Fwd: Rcpp sugar dpois
Hi. Here is a piece of cpp code. It works, but I do not understand the rational for the use of "R::dpois" to call the function dpois since in the examples I have always found directly "dpois" or "Rcpp::dpois" that both do not work in my code. Could anyone be so patient to explain me why should it be like that? Thaks a lot, Enrico #include <Rcpp.h> using
2009 Oct 27
1
Poisson dpois value is too small for double precision thus corrupts loglikelihood
Hi - I have a likelihood function that involves sums of two possions: L = a*dpois(Xi,theta1)*dpois(Yi,theta2)+b*(1-c)*a*dpois(Xi,theta1+theta3)*dpois(Yi,theta2) where a,b,c,theta1,theta2,theta3 are parameters to be estimated. (Xi,Yi) are observations. However, Xi and Yi are usually big (> 20000). This causes dpois to returns 0 depending on values of theta1, theta2 and theta3. My first
2000 Feb 25
1
lambda==0 in dpois() (PR#459)
The nice new log=TRUE option in dpois appears to mess up the case where lambda=0 (I was trying to calculate the likelihood of a saturated model). Because the behavior is now always to calculate the probability in terms of exp(log(prob)), there's a test for lambda<=0 which really needs to be only lambda<0. dpois(0:5,0) ought to give 1 0 0 0 0 but gives NaNs instead. Here's
2010 Oct 17
2
dpois().......bizarre warning messages
Dear Masters, I have a question to submit consider the following script m<-4.95 obs<-rpois(36,m) # i generate 36 realization from a poisson(m) hist(obs,freq=F) curve(dpois(x,m),add=T,col="red") #i wish to overlay on the histogram the theorical poisson density function errors are returned saing the x vector doesn't contain integers.... really bizarre i can't give
2011 Nov 14
7
Very simple loop
I'm very new to R and am trying to create my first loop. I have: x <-c(0:200) A <- dpois(x,exp(4.5355343)) B <- dpois(x,exp(4.5355343 + 0.0118638)) C <- dpois(x,exp(4.5355343 -0.0234615)) D <- dpois(x,exp(4.5355343 + 0.0316557)) E <- dpois(x,exp(4.5355343 + 0.0004716)) F <- dpois(x,exp(4.5355343 + 0.056437)) G <- dpois(x,exp(4.5355343 + 0.1225822)) and would like to
2011 Aug 08
3
on "do.call" function
Dear all, Even though one of R users answered my question, I cannot understand, so I re-ask this question. I am trying to use "do.call", but I don't think I totally understand this function. Here is an simple example. -------------------------------------------- > B <- matrix(c(.5,.1,.2,.3),2,2) > B [,1] [,2] [1,] 0.5 0.2 [2,] 0.1 0.3 > x <- c(.1,.2) >
2011 Aug 08
1
problem in do.call function
Dear all, I am trying to use "do.call", but I don't think I totally understand this function. Here is an simple example. -------------------------------------------- > B <- matrix(c(.5,.1,.2,.3),2,2) > B [,1] [,2] [1,] 0.5 0.2 [2,] 0.1 0.3 > x <- c(.1,.2) > X <- cbind(1,x) > X x [1,] 1 0.1 [2,] 1 0.2 > > lt <-
2009 Sep 19
1
Poisson Regression - Query
Hi All, My dependent variable is a ratio that takes a value of 0 (zero) for 95% of the observations and positive non-integer values for the other 5%. What model would be appropriate? I'm thinking of fitting a GLM with a Poisson ~. Now, becuase it takes non-integer values, using the glm function with Poisson family issues warning messages. Warning messages: 1: In dpois(y, mu, log = TRUE) :
2001 Aug 01
1
glm() with non-integer responses
A question about the inner workings of glm() and dpois(): Suppose I call glm(y ~ x, family=poisson, weights = w) where y contains NON-INTEGER (but still nonnegative) values. (a) Does glm() still correctly maximise the weighted Poisson loglikelihood ? (i.e. the function given by the same formal expression as the weighted loglikelihood of independent Poisson variables Y_i except that the
2011 Apr 27
3
Kolmogorov-Smirnov test
Hi, I have a problem with Kolmogorov-Smirnov test fit. I try fit distribution to my data. Actualy I create two test: - # First Kolmogorov-Smirnov Tests fit - # Second Kolmogorov-Smirnov Tests fit see below. This two test return difrent result and i don't know which is properly. Which result is properly? The first test return lower D = 0.0234 and lower p-value = 0.00304. The lower 'D'
2011 Sep 06
2
Generalizing call to function
Hello guys, I would like to ask for help to understand what is going on in "func2". My plan is to generalize "func1", so that are expected same results in "func2" as in "func1". Executing "func1" returns... 0.25 with absolute error < 8.4e-05 But for "func2" I get... Error in dpois(1, 0.1, 23.3065168689948, 0.000429064542600244,
2007 Dec 06
1
suggested modification to the 'mle' documentation?
Hello: I wish to again express my appreciation to all who have contributed to making R what it is today. At this moment, I'm particularly grateful for whoever modified the 'mle' code so data no longer need be passed via global variables. I remember struggling with this a couple of years ago, and I only today discovered that it is no longer the case. I'd
2005 Oct 19
2
matching two plots
Hi, I have a problem about graphics. I would like to plot two graphs: a barplot and curve. Here is the code: > barplot(dpois(0:45,20),xlim=c(0,45),names=0:45) > curve(dnorm(x,20,sqrt(20)),from=0,to=45,add=T) Both graphs are drawn in the same figure, however the scale in both graphs dooes not match. For some reason the second plot is shifted to left. I think there is a problem
2005 Nov 02
5
Distribution fitting problem
I am using the MASS library function fitdistr(x, dpois, list(lambda=2)) but I get Error in optim(start, mylogfn, x = x, hessian = TRUE, ...) : Function cannot be evaluated at initial parameters In addition: There were 50 or more warnings (use warnings() to see the first 50) and all the first 50 warnings say 1: non-integer x = 1.452222 etc Can anyone tell me what I am doing
2011 Jan 27
3
Warning with mle
Hi there, I'm pretty new to the field of fitting (anything). I try to fit a distribution with mle, because my real data seems to follow a zero-inflated poisson distribution. So far, I tried a simple example to see whether I understand how to do it or not: # example count data x <- 0:10 y <- dpois(x, lambda = 1.4) # zero-inflated poisson zip <- function(x, lambda, prop) { (1 -
2004 Mar 02
2
Problem with Integrate
The background: I'm trying to fit a Poisson-lognormal distrbutuion to some data. This is a way of modelling species abundances: N ~ Pois(lam) log(lam) ~ N(mu, sigma2) The number of individuals are Poisson distributed with an abundance drawn from a log-normal distrbution. To fit this to data, I need to integrate out lam. In principle, I can do it this way: PLN1 <- function(lam, Count,
2008 Jul 04
1
update on dnbinom with large "size"
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 ~ turns out I don't need to look at the C code. ~ if one uses the mu/size parameterization of the negative binomial, R computes size/(size+mu) to switch parameterizations. If size>>mu this gets rounded to 1 ... should be easy enough to test and return NA under these circumstances? function (x, size, prob, mu, log = FALSE) { ~ if
2011 Mar 22
1
Problem with plot histogram
Hi R-users, I'm trying to built a plot of two series of data, but thees series result "superimposed". The R-code is like this: goal <- c(125, 143, 81, 26, 2, 3) numgoal <- 0:5 lambda <- sum(goal*numgoal)/sum(goal) plot(numgoal, goal, type="h") x <- 0:5 y<-dpois(x, lambda) att<-y*380 lines(x,att, type="h", col="red")
2007 Jul 29
1
behavior of L-BFGS-B with trivial function triggers bug in stats4::mle
With the exception of "L-BFGS-B", all of the other optim() methods return the value of the function when they are given a trivial function (i.e., one with no variable arguments) to optimize. I don't think this is a "bug" in L-BFGS-B (more like a response to an undefined condition), but it leads to a bug in stats4::mle -- a spurious error saying that a better fit has been