-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to deal with the error in using jstable::TableSubgroupMultiGLM( ) for subgroup analysis of multiple logistic regression #6
Comments
Can you convert Y variable to integer or numeric?(0, 1) Please show me Y variable or your dataset |
hi Kim:
|
Sorry. Now, my function can't support X with 3 category: only 2 category OK. The below code is example with "Y ~ sex" library(survival);library(jstable);library(survey);library(data.table);library(magrittr)
a <- fread("recode.csv")
for (v in c("sex", "race","education")){
a[[v]] <- factor(a[[v]])
}
data.design <- svydesign(id = ~sdmvpsu, weights = ~nhs_wt, data = a)
TableSubgroupMultiGLM(Y~sex, var_subgroups = c("race","education"), data = data.design, family = "binomial")
|
Hi ,I'm using this code and I'm getting :
|
I think this is a converge issue. Can you try each subgroup analysis without my package? Ex) svyglm(Y~sex, design = subset(a, race==1), family = "quasibinomial") |
When I use "svyglm(Y~sex, design = subset(a, race==1), family = "quasibinomial")", I encounter the error "Error in UseMethod("svyglm", design) : "svyglm" does not apply to "c('tbl_df', 'tbl', 'data.frame')"Method of target object". However, when I change the data to weighted data "data.design", I get the result. But using "TableSubgroupMultiGLM" still does not work. |
Can you get result of all subset variable/value combinations? If you share your data, I run |
At present, my classification data is named in English, and the gtsummary package is usually used. I will convert the variables to the form of 0,1. Maybe you will use it more conveniently. |
Can you try other subgroup analysis? svyglm(Y~sex, design = subset(a, race==0), family = "quasibinomial")
svyglm(Y~sex, design = subset(a, sex==0), family = "quasibinomial")
svyglm(Y~sex, design = subset(a, sex==1), family = "quasibinomial")
svyglm(Y~sex, design = subset(a, education==0), family = "quasibinomial")
svyglm(Y~sex, design = subset(a, education==1), family = "quasibinomial") |
data.csv |
This is the result of trying, only the last one will get the result
Call: svyglm(formula = Y ~ sex, design = subset(a, education == 1), Coefficients: Degrees of Freedom: 1823 Total (i.e. Null); 1 Residual |
I run the code below with your data library(survey);library(data.table);library(magrittr)
a <- fread("data (8).csv")
for (v in c("Sex", "Race","education.attainment")){
a[[v]] <- factor(a[[v]])
}
svyglm(Y~Sex, design = subset(data.design, Race == 2), family = quasibinomial()) %>% summary Then, P value can't be calculated. So interaction P can't be calculated too. Call:
svyglm(formula = Y ~ Sex, design = subset(data.design, Race ==
2), family = quasibinomial())
Survey design:
subset(data.design, Race == 2)
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -2.04358 0.13378 -15.275 NaN
Sex2 0.59439 0.08481 7.008 NaN
Zero or negative residual df; p-values not defined
(Dispersion parameter for quasibinomial family taken to be 1.002519)
Number of Fisher Scoring iterations: 4
|
Thank you for your response. I saw a related article that seems to be about issues with the survey package. The author of the article contacted Professor Thomas, the author of the survey package, and he said that the anova.svyglm function needs to be rewritten in order to work properly. The professor mentioned that the next version may improve this. |
hi, kim, I am agnes.
Thanks for your useful package.
I am a tiro of R, I use this package jstable::TableSubgroupMultiGLM( ) for subgroup analysis of multiple logistic regression
below is my code:
data.design <- svydesign(id = ~sdmvpsu,
weights =
nhs_wt,X, var_subgroups = c("sex","eth","maritalstatus"), #both Y and X are categorical variablesdata = A)
TableSubgroupMultiGLM(Y
then, there report the error :
Error in glm.fit(x = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, :
NA/NaN/Inf in 'y'
In addition: Warning messages:
1: In Ops.factor(y, mu) : ‘-’ not meaningful for factors
2: In Ops.factor(eta, offset) : ‘-’ not meaningful for factors
3: In Ops.factor(y, mu) : ‘-’ not meaningful for factors
would your please tell me how to deal with this error above, thanks a lot.
The text was updated successfully, but these errors were encountered: