poisson

“Multiple definition of node a” error in Winbugs

牧云@^-^@ 提交于 2019-12-02 18:11:44
问题 okay i just rewrite my code. Now the problem is when i compile it, I get an error of "multiple definition of node a" . Do anyone know what wrong in my code. I create the variable a,b and c for the model not to have many constants. model{ for(i in 1:n){ a <- (k[1] + step(s1[i]-.9)*k[2] + step(s1[i]*.5-.9)*k[3]) b <- (r[1] + step(s2[i]-.9)*r[2] + step(s2[i]*.5-.9)*r[3]) c <- (s[1] + step(s3[i]-.9)*s[2] + step(s3[i]*.5-.9)*s[3]) dummy[i] <- 0 dummy[i] ~ dloglik(logLike[i]) # This is the log

Adjust function for log(0)

我们两清 提交于 2019-12-02 12:43:29
I wrote a function for a poisson regression. The data set discoveris have some count data where 5 entries are y = 0. I want compute the deviance residuals, acroding to the formula in my function : devianceResiduals <- sign(y - fittedValuesFullModell) * sqrt(2 * y * log(y / fittedValuesFullModell) - 2 * (y - fittedValuesFullModell)) My problem ist that i get NaN because log(y = 0) = -inf. So tried to write a loop that use 2 different forumals to compute the deviance residuals. If y = 0 the formula simplifies to - 2 * (y - fittedValuesFullModell)) because of log rules. If y > 0 i want use my

“Multiple definition of node a” error in Winbugs

点点圈 提交于 2019-12-02 11:48:31
okay i just rewrite my code. Now the problem is when i compile it, I get an error of "multiple definition of node a" . Do anyone know what wrong in my code. I create the variable a,b and c for the model not to have many constants. model{ for(i in 1:n){ a <- (k[1] + step(s1[i]-.9)*k[2] + step(s1[i]*.5-.9)*k[3]) b <- (r[1] + step(s2[i]-.9)*r[2] + step(s2[i]*.5-.9)*r[3]) c <- (s[1] + step(s3[i]-.9)*s[2] + step(s3[i]*.5-.9)*s[3]) dummy[i] <- 0 dummy[i] ~ dloglik(logLike[i]) # This is the log transformation of the 3-variate poisson logLike[i] <- -theta12[i] + a*log(theta12[i]) - logfact(a) -theta13

Fast Poisson Disk Sampling [Robert Bridson] in Python

风流意气都作罢 提交于 2019-12-02 06:49:00
First of all, I implemented the ordinary, slow, Poisson Disk Sampling algorithm in the 2D plane and it works just fine. This slow version calculates the distances between all points and checks that the point you wish to place is at least R away from all the others. The fast version by Robert Bridson, available here: https://www.cs.ubc.ca/~rbridson/docs/bridson-siggraph07-poissondisk.pdf , suggests discretizing your 2D plane into quadratic cells with length = R/sqrt(2) since each cell can at most contain a single valid point this way and the number of cells you need to check for distance

Python SciPy chisquare test returns different p value from Excel and LibreOffice

空扰寡人 提交于 2019-12-02 02:10:51
问题 After reading a recent blog post about an application of the Poisson distribution, I tried reproducing its findings using Python's 'scipy.stats' module, as well as Excel/LibreOffice 'POISSON' and 'CHITEST' functions. For the expected values shown in the article, I simply used: import scipy.stats for i in range(8): print(scipy.stats.poisson.pmf(i, 2)*31) This reproduces the table shown in the blog post - and I also recreated it from within LibreOffice, using a first column A that has values 0

Regression for a Rate variable in R

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-01 03:47:07
问题 I was tasked with developing a regression model looking at student enrollment in different programs. This is a very nice, clean data set where the enrollment counts follow a Poisson distribution well. I fit a model in R (using both GLM and Zero Inflated Poisson.) The resulting residuals seemed reasonable. However, I was then instructed to change the count of students to a "rate" which was calculated as students / school_population (Each school has its own population.)) This is now no longer a

XGBoost - Poisson distribution with varying exposure / offset

梦想的初衷 提交于 2019-11-30 13:51:49
I am trying to use XGBoost to model claims frequency of data generated from unequal length exposure periods, but have been unable to get the model to treat the exposure correctly. I would normally do this by setting log(exposure) as an offset - are you able to do this in XGBoost? (A similar question was posted here: xgboost, offset exposure? ) To illustrate the issue, the R code below generates some data with the fields: x1, x2 - factors (either 0 or 1) exposure - length of policy period on observed data frequency - mean number of claims per unit exposure claims - number of observed claims

Generating random integers within range with a probability distribution

て烟熏妆下的殇ゞ 提交于 2019-11-30 09:44:19
I have a problem where I want to generate a set of random integer values between 1 and 5 inclusive using a probability distribution. Poisson and Inverse Gamma are two distributions that show the characteristics I am after (majority at mean, less higher numbers) that I have found. I am looking at using Apache Commons Math but I wasn't sure how to generate the numbers I wanted using the distributions available. From your problem description, it sounds like you actually want a sample generated from a discrete probability distribution, and you can use EnumeratedIntegerDistribution for this purpose

pymc3 : Multiple observed values

夙愿已清 提交于 2019-11-30 00:56:35
I have some observational data for which I would like to estimate parameters, and I thought it would be a good opportunity to try out PYMC3. My data is structured as a series of records. Each record contains a pair of observations that relate to a fixed one hour period. One observation is the total number of events that occur during the given hour. The other observation is the number of successes within that time period. So, for example, a data point might specify that in a given 1 hour period, there were 1000 events in total, and that of those 1000, 100 were successes. In another time period,

Generating random integers within range with a probability distribution

好久不见. 提交于 2019-11-29 14:42:00
问题 I have a problem where I want to generate a set of random integer values between 1 and 5 inclusive using a probability distribution. Poisson and Inverse Gamma are two distributions that show the characteristics I am after (majority at mean, less higher numbers) that I have found. I am looking at using Apache Commons Math but I wasn't sure how to generate the numbers I wanted using the distributions available. 回答1: From your problem description, it sounds like you actually want a sample