Displaying 20 results from an estimated 6000 matches similar to: "glm with negative binomial family"
2010 Nov 03
3
optim works on command-line but not inside a function
Dear all,
I am trying to optimize a logistic function using optim, inside the
following functions:
#Estimating a and b from thetas and outcomes by ML
IRT.estimate.abFromThetaX <- function(t, X, inits, lw=c(-Inf,-Inf),
up=rep(Inf,2)){
optRes <- optim(inits, method="L-BFGS-B", fn=IRT.llZetaLambdaCorrNan,
gr=IRT.gradZL,
lower=lw, upper=up, t=t, X=X)
2002 Jun 20
1
Possible bug with glm.nb and starting values (PR#1695)
Full_Name: Ben Cooper
Version: 1.5.0
OS: linux
Submission from: (NULL) (134.174.187.90)
The help page for glm.nb (in MASS package) says that it takes "Any other
arguments for the glm() function except family"
One such argument is start "starting values for the parameters in the linear
predictor."
However, when called with starting values glm.nb returns:
Error in
2008 Apr 22
4
how to convert non numeric data into numeric?
I am having the following error in my function
function(theta,reqdIRR)
{
theta1<-theta[1]
theta2<-theta[2]
n<-length(reqdIRR)
constant<- n*(theta1+theta2)
sum1<-lapply(reqdIRR*exp(theta1),FUN = sum)
sum2<-lapply(exp(theta2 - reqdIRR*exp(theta1)),FUN = sum)
sum = sum1 + sum2
log.fcn = constant - as.numeric(sum)
result = - log.fcn
return(result)
}
*error :
2004 Jun 15
1
AIC in glm.nb and glm(...family=negative.binomial(.))
Can anyone explain to me why the AIC values are so different when
using glm.nb and glm with a negative.binomial family, from the MASS
library? I'm using R 1.8.1 with Mac 0S 10.3.4.
>library(MASS)
> dfr <- data.frame(c=rnbinom(100,size=2,mu=rep(c(10,20,100,1000),rep(25,4))),
+ f=factor(rep(seq(1,4),rep(25,4))))
> AIC(nb1 <- glm.nb(c~f, data=dfr))
[1] 1047
>
2008 Aug 21
1
rc note, etc
Are the messages below to be expected from make check-all ?
using the rc today, Aug 21, on
Red Hat Enterprise Linux AS release 4 (Nahant Update 4)
Kernel 2.6.9-42.0.8.ELsmp on an x86_64
Paul
________
....
checking package 'utils'
....
* checking R code for possible problems ... NOTE
install.packages: no visible global function definition for
?.install.winbinary?
install.packages: no
2007 Jan 06
2
negative binomial family glm R and STATA
Dear Lister,
I am facing a strange problem fitting a GLM of the negative binomial
family. Actually, I tried to estimate theta (the scale parameter)
through glm.nb from MASS and could get convergence only relaxing the
convergence tolerance to 1e-3. With warning messages:
glm1<-glm.nb(nbcas~.,data=zonesdb4,control=glm.control(epsilon = 1e-3))
There were 25 warnings (use warnings() to see
2011 Jun 27
1
Neg Binomial In GEE
Hi, I want to fit a GEE with a negative binomial distribution. I have uesd
already a poisson glm and then neg binommial to deal with alot of
dispersion. In my neg binomial residuals i have some patterns so i have
implemented a GEE, but only with a poisson family as i couldnt with neg
binomial. However the residual patterns in fact look worse here. When i
try and put neg binomial family it
2011 Dec 01
1
Estimation of AR(1) Model with Markov Switching
Dear R users,
I have been trying to obtain the MLE of the following model
state 0: y_t = 2 + 0.5 * y_{t-1} + e_t
state 1: y_t = 0.5 + 0.9 * y_{t-1} + e_t
where e_t ~ iidN(0,1)
transition probability between states is 0.2
I've generated some fake data and tried to estimate the parameters using the
constrOptim() function but I can't get sensible answers using it. I've tried
using
2005 Mar 03
1
Negative binomial regression for count data
Dear list,
I would like to fit a negative binomial regression model as described in "Byers AL, Allore H, Gill TM, Peduzzi PN., Application of negative binomial modeling for discrete outcomes: a case study in aging research. J Clin Epidemiol. 2003 Jun;56(6):559-64" to my data in which the response is count data. There are also 10 predictors that are count data, and I have also 3
2006 Jul 28
2
negative binomial lmer
To whom it may concern:
I have a question about how to appropriately conduct an lmer analysis for negative binomially distributed data. I am using R 2.2.1 on a windows machine.
I am trying to conduct an analysis using lmer (for non-normally distributed data and both random and fixed effects) for negative binomially distributed data. To do this, I have been using maximum likelihood,
2003 Jul 17
0
glm.nb
I am trying to fit the generalised linear model for the negative binomial, but the results which come out are attached below. When we fit this model using few covariates, the model converge. Does it mean that this family is fitted differently from other glm? or the number of zeros in my response variable has a limiting factor?
Thanks
Bruno
fit <- glm.nb(pfde~SEX+...., data=data1)
Warning
2010 Jul 06
1
Interpreting NB GLM output - effect sizes?
Hi,
I am trying to find out how to interpret the summary output from a neg
bin GLM?
I have 3 significant variables and I can see whether they have a
positive or negative effect, but I can't work out how to calculate the
magnitude of the effect on the mean of the dependent variable. I used
a log link function so I think I might have to use the antilogs of the
coefficients but I have no idea
2011 Nov 17
1
How to Fit Inflated Negative Binomial
Dear All,
I am trying to fit some data both as a negative binomial and a zero
inflated binomial.
For the first case, I have no particular problems, see the small snippet
below
library(MASS) #a basic R library
set.seed(123) #to have reproducible results
x4 <- rnegbin(500, mu = 5, theta = 4)
#Now fit and check that we get the right parameters
fd <- fitdistr(x4, "Negative
2009 Feb 18
1
Help on warning message from Neg. Binomial error during glm
I am using glm.nb, a ~b*c ( b is categorical and c is continuous). when I
run this model I get the warning message:
Warning messages:
1: In theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
control$trace > :
iteration limit reached
2: In theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
control$trace > :
iteration limit reached
What does this mean?
--
Graduate
2012 Feb 09
1
Constraint on one of parameters.
Dear all,
I have a function to optimize for a set of parameters and want to set a
constraint on only one parameter. Here is my function. What I want to do is
estimate the parameters of a bivariate normal distribution where the
correlation has to be between -1 and 1. Would you please advise how to
revise it?
ex=function(s,prob,theta1,theta,xa,xb,xc,xd,t,delta) {
expo1=
2009 Aug 17
2
Newbie that don't understand R code
I got some R code that I don't understand.
Question as comment in code
//where is t comming from, what is phi inverse
rAC <- function(name, n, d, theta){
#generic function for Archimedean copula simulation
illegalpar <- switch(name,
clayton = (theta < 0),
gumbel = (theta < 1),
frank = (theta < 0),
BB9 = ((theta[1] < 1) | (theta[2] < 0)),
GIG = ((theta[2] < 0) |
2009 May 19
2
what is wrong with this code?
dlogl <- -(n/theta)-sum((y/(theta)^2)*((1-exp(y/theta))/(1+exp(y/theta)))
d2logl <- (n/theta^2) - sum((-2y/theta^3)*(1-exp(y/theta))/(1+exp(y/theta)))
- sum(((2*y/theta^4)*exp(y/theta))/((1+exp(y/theta))^2))
returns the error message:
Error: unexpected symbol in:
"dlogl <- -(n/theta)-sum((y/(theta)^2)*((1-exp(y/theta))/(1+exp(y/theta)))
d2logl"
do you know what i have done
2008 Apr 22
2
optimization setup
Hi, here comes my problem, say I have the following functions (example case)
#------------------------------------------------------------
function1 <- function (x, theta)
{a <- theta[1] ( 1 - exp(-theta[2]) ) * theta[3] )
b <- x * theta[1] / theta[3]^2
return( list( a = a, b = b )) }
#-----------------------------------------------------------
function2<-function (x, theta)
{P
2005 Mar 16
1
Code to replace nested for loops
Dear list members,
How can I replace the nested for loops at then end of the script
below with more efficient code?
# Begin script__________________________________________________
# Dichotomous scores for 100 respondents on 3 items with
# probabilities of a correct response = .6, .4, and .7,
# respectively
x1 <- rbinom(100,1,.6)
x2 <- rbinom(100,1,.4)
x3 <- rbinom(100,1,.7)
#
2008 Mar 19
1
problem with optim and integrate
Dear all,
I want to min "integrate( (p1*dnorm+p2*dnorm+p3*dnorm)^(1.3))" for p, mu,
and sigma.
So, I have to estimate 8 parameters(p3=1-p1-p2).
I got this warning-"Error in integrate(numint, lower = -Inf, upper = Inf) :
non-finite function value."
My questions are
How could I fix it? I tried to divide into several intervals and sum up, but
I got same message.
My code is