search for: negbin

Displaying 20 results from an estimated 36 matches for "negbin".

2011 Feb 10
Comparison of glm.nb and negbin from the package aod
I have fitted the to glm.nb and to the function negbin from the package aod. The output of both is the following: summary(glm.nb(n~ll, data=faults)) Call: glm.nb(formula = n ~ ll, data = faults, init.theta = 8.667407437, link = log) Deviance Residuals: Min 1Q Median 3Q Max -2.0470 -0.7815 -0.1723 0.4275 2.0896...
2007 Dec 12
Defining the "random" term in function "negbin" of AOD package
I have tried glm.nb in the MASS package, but many models (I have 250 models with different combinations of predictors for fish counts data) either fail to converge or even diverge. I'm attempting to use the negbin function in the AOD package, but am unsure what to use for the "random" term, which is supposed to provide a right hand formula for the overdispersion parameter. I'm not even sure what this statement means. Any advice you have would be greatly appreciated. negbin(formula, random,...
2010 Feb 11
Zero-inflated Negat. Binom. model
...i.e. how well does chick size predict tape intensity? Since I have a small sample size, I fit a zero inflated negat. Binomial (not Poisson) model using the "pscl" package. I built tried two models and got the outputs below. > model <- zeroinfl(Int_Cesto ~ CAPI, dist = "negbin", EM = TRUE) Call: zeroinfl(formula = Int_Cesto ~ CAPI, dist = "negbin", EM = TRUE) Count model coefficients (negbin with log link): (Intercept) CAPI -2.99182 0.06817 Theta = 0.4528 Zero-inflation model coefficients (binomial with logit link): (Intercept)...
2011 Oct 26
gam predictions with negbin model
Hi, I wonder if predict.gam is supposed to work with family=negbin() definition? It seems to me that the values returned by type="response" are far off the observed values. Here is an example output from the negbin examples: > set.seed(3) > n<-400 > dat<-gamSim(1,n=n) > g<-exp(dat$f/5) > dat$y<-rnbinom(g,size=3,mu=...
2010 Feb 04
Zero inflated negat. binomial model
...g at the association between these two variables, i.e. how well does chick size predict tape intensity? I fit a zero inflated negat. binomial model using the "pscl" package. I built my model as follows and got the output below. > model <- zeroinfl(Int_Cesto ~ CAPI, dist = "negbin", EM = TRUE) > model Call: zeroinfl(formula = Int_Cesto ~ CAPI, dist = "negbin", EM = TRUE) Count model coefficients (negbin with log link): (Intercept) CAPI -2.99182 0.06817 Theta = 0.4528 Zero-inflation model coefficients (binomial with logit link): (Inte...
2013 Mar 15
Poisson and negbin gamm in mgcv - overdispersion and theta
...rsion parameter from a (Poisson) gamm? I have not been able to extract residual degrees of freedom from M1. 2) How to manually estimate theta for a negative binomial gamm? I would like to see if applying a negative binomial distribution with log link (model below) would solve the problem. However, negbin in gamm requires a known theta... M2 <- gamm(Resp ~ s(Day, k=8) + s(Day, by=C, k=8) + Flow + offset(LogVol), data=MyResp, correlation = corAR1(form= ~ Day|Mesocosm), family= negbin(THETA, link="log")) 3) And finally, can I somehow compare the mode...
2005 Jun 02
glm with variance = mu+theta*mu^2?
How might you fit a generalized linear model (glm) with variance = mu+theta*mu^2 (where mu = mean of the exponential family random variable and theta is a parameter to be estimated)? This appears in Table 2.7 of Fahrmeir and Tutz (2001) Multivariate Statisticial Modeling Based on Generalized Linear Models, 2nd ed. (Springer, p. 60), where they compare "log-linear model fits to
2011 Sep 22
negative binomial GAMM with variance structures
...I am having some difficulty converting my gam code to a correct gamm code, and I'm really hoping someone will be able to help me. I was previously using this script for my overdispersed gam data: M30 <-gam(efuscus~s(mic, k=7) +temp +s(date)+s(For3k, k=7) + pressure+ humidity, family=negbin(c(1,10)), data=efuscus) My gam.check gave me the attached result. In order to deal with my heterogeneity, I need to switch over to a gamm structure and use at least one, but possibly multiple, variance structures, and I am starting by applying varPower to my temperature covariate. (Efuscus i...
2005 Jun 30
RE : Dispersion parameter in Neg Bin GLM
Edward, you also can use the package aod on CRAN, see the help page of the function negbin. Best Matthieu An example: > library(aod) > data(dja) > negbin(y ~ group + offset(log(trisk)), ~group, dja, fixpar = list(4, 0)) Negative-binomial model ----------------------- negbin(formula = y ~ group + offset(log(trisk)), random = ~group, data = dja, fixpar = list(4, 0))...
2018 Feb 16
hurdle model - count and response predictions
...on-count-vs-response ). Since the issue is the same (and not resolved), I'll just use the example from the second link: library("pscl") data("RecreationDemand", package = "AER") ## model m <- hurdle(trips ~ quality | ski, data = RecreationDemand, dist = "negbin") nd <- data.frame(quality = 0:5, ski = "no") predict(m, newdata = nd, type = "count") predict(m, newdata = nd, type = "response") The presence/absence part of the model gives identical estimates to a logistic model run on the data. However, I thought that...
2011 May 04
hurdle, simulated power
...n function logit model p0 <- exp(alpha0 + alpha1*trt)/(1 + exp(alpha0 + alpha1*trt)) ### 0 / 1 based on p0 y1 <- as.numeric(runif(n)>p0) ### mean function count portion mu <- exp(beta0 + beta1*trt) ### estimate counts using NB dist require(MASS, quietly = TRUE) y2 <- rnegbin(n, mu = mu, theta = theta) ### if y2 = 0, draw new value while(sum(y2==0)>0){ y2[which(y2==0)] <- rnegbin(length(which(y2==0)), mu=mu[which(y2==0)], theta = theta) } y<-y1*y2 data.frame(trt=trt,y=y) } #alpha0, alpha1 is the parameter for zero part #beta0,beta1 is the parameter for...
2008 Mar 20
logLik calculations
Does the ?logLik? function applied to a ?glm? and ?glm.nb? (from MASS package) calculate the complete log-likelihoods, or does it drop the constant terms of the equation? (It?s not clear from the associated help pages, and I?ve found no reference from searching the R help mailing list) Thank you, Kelly Young
2013 Oct 18
hurdle model error why does need integer values for the dependent variable?
Dear list, I am using the hurdle model for modelling the habitat of rare fish species. However I do get an error message when I try to model my data: > test_new1<-hurdle(GALUMEL~ depth + sal + slope + vrm + lat:long + offset(log(haul_numb)), dist = "negbin", data = datafit_elasmo) Error in hurdle(GALUMEL ~ depth + sal + slope + vrm + lat:long + offset(log(haul_numb)), : invalid dependent variable, non-integer values When I do fit the same model with round(my dependent variable) the model works. Sorry for the stupid question but could anyone...
2010 Sep 03
Interactions in GAM
...h to prevalence (distribution=binomial) and to intensity (distribution=negative binomial): gam(prevalence~s(length)+factor(year)+factor(area)+s(length,by=area)+s(length,by=year), family=binomial,data=X) gam(intensity~s(length)+factor(year)+factor(area)+s(length,by=area)+s(length,by=year), family=negbin(c(1,10)),data=X) The solution that I have seen to introduce an interaction "continuous covariate- continuous covariate" is using the function "te". Below, I show an example of my model with the interactions using "te" both to prevalence (distribution=binomial) and t...
2005 Mar 03
Negative binomial regression for count data
...(mean=2.8, variance=28) as well as in predictors, and there are a lot of zero's (zero-inflated). The authors of that paper used PROC GENMOD in SAS 8.1. I wonder which of the following packages and tests to use in R to acheive such model for my analysis. Is there any tutorial available? anova.negbin Likelihood Ratio Tests for Negative Binomial GLMs glm.convert Change a Negative Binomial fit to a GLM fit glm.nb Fit a Negative Binomial Generalized Linear Model negative.binomial Family function for Negative Binomial GLMs rnegbin Simulate Negative Binomial Variates theta.m...
2011 Sep 02
Hessian Matrix Issue
...irical estimates or sample moments xbar<-mean(y) variance<-(sum((y-xbar)^2))/length(y) dbar<-variance/xbar #sample estimate of proportion of zeros and zero inflation index pbar<-length(y[y==0])/length(y) ### Simplified function ############################################# NegBin<-function(th){ mu<-th[1] d<-th[2] n<-length(y) arg1<-n*mean(y)*ifelse(mu >= 0, log(mu),0) #arg1<-n*mean(y)*log(mu) #arg2<-n*log(d)*((mean(y))+mu/(d-1)) arg2<-n*ifelse(d>=0, log(d), 0)*((mean(y))+mu/ifelse((d-1)>= 0, (d-1), 0.0000001)) aa<-numeric(lengt...
2006 Jul 20
Convergence warnings from zeroinfl (package pscl)
...lly 0 occurred in:, Y, family = poisson()) >> suggest that it did not converge. (See full output below.) Could some possibly help me to interpret these results? Thanks for your time, Dan > zip3=zeroinfl(count=round(modAbun*1000) ~ ., + x=~mod*intact, + z=~1, + dist="negbin", + trace=TRUE, + data=beetles) Zero-Inflated Count Model Using logit to model zero vs non-zero Using Negative Binomial for counts dependent variable y: Y 0 10 11 14 17 19 21 23 25 28 31 33 34 37 40 42 46 1056 3...
2012 Dec 10
Marginal effects of ZINB models
...s of the model, can anyone help me with R code to compute overall marginal effects of each variable? My model is specified as follows: ZINB <- zeroinfl(Tot.Anglers ~ Location + Season + Daytype + Holiday.not + CPUE + ShoreType + Access + Source.pop + WindSpeed + offset(beat_length), dist="negbin", data=anglers) Many thanks, Jeremy [[alternative HTML version deleted]]
2005 Jan 26
Source code for "extractAIC"?
Dear R users: I am looking for the source code for the R function extractAIC. Type the function name doesn't help: > extractAIC function (fit, scale, k = 2, ...) UseMethod("extractAIC") <environment: namespace:stats> And when I search it in the R source code, the best I can find is in (R source root)/library/stats/R/add.R: extractAIC <-
2013 Jun 04
Zero-Inflated Negative Binomial Regression
Hi! I'm running a zero-inflated negative binomial regression on a large (n=54822) set of confidential data. I'm using the code: ZerNegBinRegress<-zeroinfl(Paper~.|., data=OvsP, dist="negbin", EM=TRUE) And keep getting the error: Warning message: fitted probabilities numerically 0 or 1 occurred I've done enough reading about this error to realize that I have a linear separation issue, for which the solut...