NaNs produced when using aodml beta-binomial model in aods3 package - r

When trying to use the aodml funciton to fit a beta-binomial distribution GLM with my own data I get a warning message, stating that there are NaNs produced. When I tried to run the same function with the dataset given in the example of the aods3 package I get the same warning messages.
Code:
library(aods3)
data(orob2)
fm1<-aodml(cbind(m, n-m)~seed, data=orob2, family="bb")
Warning messages:
1: In lbeta(a, b): NaNs produced
I have an inkling that the warning is caused by the cbind(m, n-m) but I don't know why or how? Any ideas, especially strange since this is happening with the example data? Am I missing something here?

The problem here is that the optimization procedure tries a negative value of the dispersion parameter along the way. You can see this yourself by setting
options(warn=2, error=recover)
which specifies that warnings get converted to errors, and that errors trigger debug mode. Once you do this, re-run the aodml(...) command, choose frame 4, and print the values of m, n, mu, and k being passed to dbetabin. You'll see that k is negative.
You can resolve this by setting phi.scale="log", which will fit the dispersion parameter on a log scale (which makes more sense anyway).

Related

GEE log binomial to estimate relative risk in clustered data

I need to perform a log binomial regression using GEE. I tried to solve this using gee package with the following code:
gee(y~x,id,data = data, family="binomial",link="log",corstr="exchangeable")
Where y is a binary variable 0/1.
When I run that, i got this error:
Error in gee(y~x,id,data = data, family="binomial",link="log",corstr="exchangeable") :
unused argument (link = "log")
I know that the error is straightforward, however, I don't know how to specify the link function inside the gee function. The problem is that the binary outcome is more than 50%. Because of that, OR is not a good proxy for risk interpretation.
Please help.

coxph Error weights must be finite. How do I return this model?

I have run a cox regression model below
allcause_cox<-coxph(Surv(allcause_time, allcause)~centgroup, data=fulldata)
This has run fine. However I want to return robust standard error. Therefore I have introduced the
cluster(parity)
term into the model, where parity is another variable in my data set. However this won't run. It returns the error
> allcause_cox<-coxph(Surv(allcause_time, allcause)~centgroup, data=fulldata, cluster(parity))
Error in coxph(Surv(allcause_time, allcause)~centgroup, data=fulldata, :
weights must be finite
Is there a solution to this? I have read about the weight term which can be added but I'm not sure what this does.
cluster is in the wrong place, the command should read
allcause_cox<-coxph(Surv(allcause_time, allcause)~centgroup+cluster(parity), data=fulldata)

Need help to understand ctree plot warnings()

First time asking a question.
I am relatively new to using R. Using it on a project for the Party package (cforest, ctree) which has no implementation in Python.
I receive no warnings in my code until I plot a ctree, at which point I get a varying number of the same two warnings each time I plot a new ctree. The two types of warnings are shown below:
Warning messages:
In model#fit(data, ...) : cmvnorm: completion with ERROR > EPS
In model#fit(data, ...) : cmvnorm: N > 1000 or N < 1
I’ve determined these warnings are coming from the libcoin package, but I don’t understand them.
To be clear, I am getting a plot. The results seem reasonable. I just want to know what these warnings are trying to convey so I can know to disregard or not.
Any help is appreciated.

Error when estimating CI for GLMM using confint()

I have a set of GLMMs fitted with a binary response variable and a set of continuous variables, and I would like to get confidence intervals for each model. I've been using confint() function, at 95% and with the profile method, and it works without any problems if it is applied to a model with no interactions.
However, when I apply confint() to a model with interactions (continuous*continuous), I've been getting this error:
m1CI <- confint(m1, level=0.95, method="profile")
Error in zeta(shiftpar, start = opt[seqpar1][-w]) :
profiling detected new, lower deviance
The model runs without any problem (although I applied an optimizer because some of the models were having problems with convergence), and here is the final form of one of them:
m1 <- glmer(Use~RSr2*W+RSr3*W+RShw*W+RScon*W+
RSmix*W+(1|Pack/Year),
control=glmerControl(optimizer="bobyqa",
optCtrl=list(maxfun=100000)),
data = data0516RS, family=binomial(link="logit"))
Does anyone know why this is happening, and how can I solve it?
I am using R version 3.4.3 and lme4 1.1-17
The problem was solved by following these instructions:
The error message indicates that during profiling, the optimizer found
a fitted value that was significantly better (as characterized by the
'devtol' parameter) than the supposed minimum-deviance solution returned
in the first place. You can boost the 'devtol' parameter (which is
currently set at a conservative 1e-9 ...) if you want to ignore this --
however, the non-monotonic profiles are also warning you that something
may be wonky with the profile.
From https://stat.ethz.ch/pipermail/r-sig-mixed-models/2014q3/022394.html
I used the confint.merModfrom the lme4 package, and boosted the 'devtol' parameter, first to 1e-8, which didn't work for my models, and then to 1e-7. With this value, it worked

Error in La.svd(x, nu, nv) : error code 1 from Lapack routine 'dgesdd' when using stability function in ClustOfVar

I tried to apply stability function in ClustOfVar package and got an error message as below:
Error in La.svd(x, nu, nv) : error code 1 from Lapack routine 'dgesdd'.
I intended to do the variable clustering on a data set including both quantitative and qualitative variables. The R codes I uses are shown as below. At first I use the data directly (i.e., without standardization of the quantitative variables) and got the error message when running the stability function). Then I scale the quantitative variables and rerun the codes and got the same error message. Would someone give a suggestion how to fix the problem? Also, I do not think it need no step to standardize the quantitative variables because the hclustvar function should contain the standardization, right?
X.quanti<-Data4Cluster[, c(9:28)]
X.quanti2<-scale(X.quanti, center=TRUE, scale=TRUE)
X.quali<-Data4Cluster[, c(1:4,8)]
tree<-hclustvar(X.quanti,X.quali)
plot(tree)
stab<-stability(tree, B=40)
tree2<-hclustvar(X.quanti2,X.quali)
plot(tree2)
stab<-stability(tree2, B=40)
I am having exactly the same problem. The only thing that fixed it for me was changing the value of B (reducing it to 20) but I don't think it is right so I hope someone can give us a solution. My worry from searching the web is that there is a bug in the Lapack package which seems unfixable (this error is a common occurrence with various functions).
I had this error using the MASS::lda function. The error went away when I removed collinear variables from the model.

Resources