-
Notifications
You must be signed in to change notification settings - Fork 2
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
glm.cluster reliant on/generates NULL wgt__ value #18
Comments
I agree that overwriting |
I have been having the same issue as the original poster when calling lm.cluster and glm.cluster within a larger function. Is the best strategy for now to set wgt__ <- NULL just before calling the larger function, as he suggested? Or will this cause other problems that I'm not foreseeing? |
@b-johns , adding wgt__ <- NULL before calling the function is a good solution if you do not use weight in glm.cluster. In this case, f <- function(...){ The line |
I have
glm.cluster
embedded in a larger function. When I run the function (see below) in a new R session, I get the following error:Error in eval(extras, data, env) : object 'wgt_' not found
When I run glm.cluster(...) with the parameters saved as variables but without assigning the output, it automatically saves
wgt__
as a value in the session environment. This does not return an error and I can then run the overarching function without errors.It seems to hinge on whether or not
wgt__
is saved in the environment - as soon as I remove this from the environment, the error message returns. I can also run the function in a new session by assigningwgt__ <- NULL
before the function call.I've included example code and some fake data which generates the error.
R Version: 3.6.0
Mac OSX 10.14.5
Minimal working example
`library(tidyverse)
library(miceadds)
example_data <- read_csv("example_data.csv")
cluster_glm <- function(data, formula, cluster, type) {
mod <- glm.cluster(formula = formula,
data = data,
cluster = cluster,
weights = NULL,
family = if(type == "logit") {
binomial(link="logit")
} else {
gaussian
}
) %>%
summary(.) %>%
as.data.frame(.)
return(mod)
}
mod_basic_vote <- cluster_glm(formula = "Y ~ X1 + X2 + X3",
data = example_data,
type = "logit",
cluster = "pid")
wgt__ <- NULL
mod_basic_vote <- cluster_glm(formula = "Y ~ X1 + X2 + X3",
data = example_data,
type = "logit",
cluster = "pid")`
mwe.zip
The text was updated successfully, but these errors were encountered: