-
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
Add extractor methods #8
Comments
Title: Request for Cluster-by-Cluster Information Similar to Stata's Default Output Body: I'm currently working on a paper recommending the use of Current SituationUsing the following R code with # Set a wider display
options(width = 150)
# Read the data
data <- read.csv("scrambled_cherish.csv")
# Create dummy variables
data$treat <- ifelse(data$intervention_factor == "Intervention", 1,
ifelse(data$intervention_factor == "Control", 0, NA))
data$elect <- as.numeric(data$adm_cat == "Elective")
data$female <- as.numeric(data$gender == "Female")
data$cog_dec <- ifelse(data$cognitive_impairment_admission == "1", 1,
ifelse(data$cognitive_impairment_admission == "0", 0, NA))
data$fun_dec <- ifelse(data$hospital_associated_functional_decline == "1", 1,
ifelse(data$hospital_associated_functional_decline == "0", 0, NA))
# Create factor variables
data$hospital <- as.factor(data$hospital)
data$ward <- as.factor(data$ward)
# Load necessary libraries
library(sandwich)
library(summclust)
# Specify the model formula
mf <- formula(
delirium_new ~ treat +
age +
female +
cognitive_impairment_admission +
hospital_associated_functional_decline +
cci_unadjusted_for_age +
elect +
factor(hospital)
)
# Testing clusters
fit <- lm(mf, data = data)
summ <- summclust(fit, params = ~ treat, cluster = ~ ward)
summary(summ)
# Create cluster by cluster information
cluster_by_cluster <- data.frame(
Cluster = seq_along(summ$N_G),
Ng = as.vector(summ$N_G),
Leverage = summ$leverage_g,
Partial_L = summ$partial_leverage[1,],
Beta_no_g = summ$beta_jack[1,]
)
print(cluster_by_cluster, row.names = FALSE) I get this output:
Desired OutputWhen running a similar analysis in Stata, I get:
IssueThe values are correct, but the order differs. For example, cluster 1's leverage in Stata is 1.775769, while in R it's 1.5615371 (which corresponds to cluster 5 in Stata). RequestCould you please provide guidance or adjust the Thank you for your attention to this matter. Your assistance will significantly contribute to the adoption of Stata code for reference
|
Hi @SergeyVAlexeev, thanks for raising this - I'm travelling at the moment so haven't really had time to look into it; I'll do so once I'm back home by the end of the week! |
For
The text was updated successfully, but these errors were encountered: