Hello Michael and all.
1. I replaced INT with Numeric that did not solve the error problem.
2. However I discovered that my matrix was the problem, I had it set to 2,5 and
when I set it to 6,6 I no longer get the error, which was due to not having the
correct or more than necessary fields in the matrix.
Clues came from:
https://stackoverflow.com/questions/15031338/subscript-out-of-bounds-general-definition-and-solution
Following the author's pattern they described their data as needing matrix =
6,6 due to 6 factors and 6 covariates .
I set my matrix to the number of Factors and Covariates, 2-5 and that caused the
error.
[,1] [,2]
[1,] 497664 10368
[2,] NA NA
[3,] NA NA
[4,] NA NA
[5,] NA NA
dd <- matrix(nc = 6, nr = 6) View(dd)
for(i in 1:2) for(j in 1:5) dd[i, j] <- glmulti(names(r1a)[1],
names(r1a)[c(2:(1 + i), 8:(3 + j))], data = r1a, method = "d")
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] 497664 10368 432 36 6 NA
[2,] 16000000 200000 5000 250 25 NA
[3,] NA NA NA NA NA NA
[4,] NA NA NA NA NA NA
[5,] NA NA NA NA NA NA
[6,] NA NA NA NA NA NA
Thank you for your support!
WHP
From: Michael Dewey <lists at dewey.myzen.co.uk>
Sent: Thursday, November 15, 2018 7:24 AM
To: Bill Poling <Bill.Poling at zelis.com>; r-sig-mixed-models at
r-project.org; r-help (r-help at r-project.org) <r-help at r-project.org>
Subject: Re: [R] glmutli package assistance please
Dear Bill
I am not sure what is going on here but I notice that 2 of your
covariates are numeric and 3 integer. What happens if you make them all
numeric?
Michael
On 15/11/2018 11:46, Bill Poling wrote:> 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}}
>
> ______________________________________________
> mailto:R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Michael
http://www.dewey.myzen.co.uk/home.html
Confidentiality Notice This message is sent from Zelis. This transmission may
contain information which is privileged and confidential and is intended for the
personal and confidential use of the named recipient only. Such information may
be protected by applicable State and Federal laws from this disclosure or
unauthorized use. If the reader of this message is not the intended recipient,
or the employee or agent responsible for delivering the message to the intended
recipient, you are hereby notified that any disclosure, review, discussion,
copying, or taking any action in reliance on the contents of this transmission
is strictly prohibited. If you have received this transmission in error, please
contact the sender immediately. Zelis, 2018.