Open tomdrake opened 6 years ago
Awesome, thank you! E
On Sun, 31 Dec 2017 at 15:29, tomdrake notifications@github.com wrote:
Hello - Not one to rush into - I'll test over next couple of weeks, but as an update I've rewritten a few of the glm functions to be able to handle weights and potentially new families in models (so these are compatible with propensity score matching.
It produces the same glmlist model (albeit with a more accurate call per dependent variable).
I'll work on it a bit and see if it errors at all. Posted for the record!
Example:
glmmulti <- function(df.in, dependent, explanatory, weights = NULL, family = "binomial"){ result = list() if (is.null(weights)){ for (i in 1:length(dependent)) { f <- as.formula(paste(dependent, '~', paste(explanatory, collapse="+"))) fit <- do.call("glm", list(formula=f, data=df.in, family= family)) fit['call'] = deparse(f) result[[i]] <- fit} } else { for (i in 1:length(dependent)) { f <- as.formula(paste(dependent, '~', paste(explanatory, collapse="+"))) fit <- do.call("glm", list(formula=f, data=df.in, family= family, weights = weights)) fit['call'] = deparse(f) result[[i]] <- fit} } result = setNames(result, dependent) class(result) = "glmlist" return(result) }
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ewenharrison/summarizer/issues/8, or mute the thread https://github.com/notifications/unsubscribe-auth/ADO_oieAjdPLFVerq90QCmdQjBk4SOF_ks5tF6hWgaJpZM4RP363 .
-- Ewen M Harrison MB ChB MSc PhD FRCS (Gen Surg) Senior Lecturer in General Surgery Consultant Transplant and Hepatobiliary Surgeon ChM General Surgery http://www.chm.rcsed.ac.uk Programme Director GlobalSurg http://globalsurg.org Research Collaborative Lead Surgical Informatics Clinical Surgery University of Edinburgh http://www.ed.ac.uk/schools-departments/surgery/staff/surgical-profiles/ewen-harrison Royal Infirmary of Edinburgh Edinburgh EH16 4SA Mobile: +44 (0) 797 442 0495 mail@ewenharrison.com Twitter: @ewenharrison Web: DataSurg http://datasurg.net SurgicalInformatics
Hello - Not one to rush into - I'll test over next couple of weeks, but as an update I've rewritten a few of the glm functions to be able to handle weights and potentially new families in models (so these are compatible with propensity score matching.
It produces the same glmlist model (albeit with a more accurate call per dependent variable).
I'll work on it a bit and see if it errors at all. Posted for the record!
Example:
glmmulti <- function(df.in, dependent, explanatory, weights = NULL, family = "binomial"){ result = list() if (is.null(weights)){ for (i in 1:length(dependent)) { f <- as.formula(paste(dependent, '~', paste(explanatory, collapse="+"))) fit <- do.call("glm", list(formula=f, data=df.in, family= family)) fit['call'] = deparse(f) result[[i]] <- fit} } else { for (i in 1:length(dependent)) { f <- as.formula(paste(dependent, '~', paste(explanatory, collapse="+"))) fit <- do.call("glm", list(formula=f, data=df.in, family= family, weights = weights)) fit['call'] = deparse(f) result[[i]] <- fit} } result = setNames(result, dependent) class(result) = "glmlist" return(result) }