[R] glmutli package assistance please

Bill Poling Bill@Poling @ending from zeli@@com
Thu Nov 15 12:46:48 CET 2018


Hi, I have removed the pdf which was causing my e-mail to be blocked by moderators, my apologies.

https://www.jstatsoft.org/article/view/v034i12/v34i12.pdf

Original post:

Hello. I am still trying to get some of the examples in this glmulti pdf to work with my data.

I have sent e-mails to author addresses provided but no response or bounced back as in valid.

I am not sure if this is more likely to receive support on r-help or r-sig-mixed-models, hence the double posting, my apologies in advance.

I am windows 10 -- R3.5.1 -- RStudio Version 1.1.456

glmulti: An R Package for Easy Automated Model Selection with (Generalized) Linear Models

pdf Attached:

On page 13 section 3.1 of the pdf they describe a routine to estimate the candidate models possible.

Their data description:
The number of levels factors have does not affect the number of candidate models, only their complexity. We use a data frame dod, containing as a first column a dummy response variable, the next 6 columns are dummy factors with three levels, and the last six are dummy covariates.
To compute the number of candidate models when there are between 1 and 6 factors and 1 and 6 covariates, we call glmulti with method = "d" and data = dod. We use names(dod) to specify the names of the response variable and of the predictors. We vary the number of factors and covariates, this way:


Their routine:
dd <- matrix(nc = 6, nr = 6) for(i in 1:6) for(j in 1:6) dd[i, j] <- glmulti(names(dod)[1],
+ names(dod)[c(2:(1 + i), 8:(7 + j))], data = dod, method = "d")

My data, I organized it similar to the example, Response, Factor, Factor, 5 covariates

Classes 'data.table' and 'data.frame':23141 obs. of  8 variables:
 $ Editnumber2    : num  0 0 1 1 1 1 1 1 1 1 ...
 $ PatientGender  : Factor w/ 3 levels "F","M","U": 1 1 2 2 2 2 1 1 1 1 ...
 $ B1             : Factor w/ 14 levels "Z","A","C","D",..: 2 2 3 3 2 2 2 2 2 2 ...
 $ SavingsReversed: num  -0.139 -0.139 -0.139 -0.139 -0.139 ...
 $ productID      : int  3 3 3 3 3 3 3 3 1 1 ...
 $ ProviderID     : int  113676 113676 113964 113964 114278 114278 114278 114278 114278 114278 ...
 $ ModCnt         : int  0 0 0 0 1 1 1 1 1 1 ...
 $ B2             : num  -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...
 - attr(*, ".internal.selfref")=<externalptr>

Trying to follow what they did, my routine, Editnumber2 is the response variable:

dd <- matrix(nc = 2, nr = 5)
for(i in 1:2) for(j in 1:5) dd[i, j] <- glmulti(names(r1)[1], names(r1)[c(2:(1 + i), 7:(6 + j))], data = r1, method = "d")

The error: Error in terms.formula(formula, data = data) :
  invalid model formula in ExtractVars

I have tried changing the numbers around but get results like this:

Initialization...
TASK: Diagnostic of candidate set.
Sample size: 23141
2 factor(s).
2 covariate(s). <--appears to be missing 3 of the covariates for some reason?
0 f exclusion(s).
0 c exclusion(s).
0 f:f exclusion(s).
0 c:c exclusion(s).
0 f:c exclusion(s).
Size constraints: min =  0 max = -1
Complexity constraints: min =  0 max = -1 Your candidate set contains 250 models.
Error in `[<-`(`*tmp*`, i, j, value = glmulti(names(r1)[1], names(r1)[c(2:(1 +  :
  subscript out of bounds


I hope someone can help straighten out my code, thank you.


WHP



Confidentiality Notice This message is sent from Zelis. ...{{dropped:13}}



More information about the R-help mailing list