Search code examples
rregressionchi-squaredexp

Add column in regression output


I would like to add a column with the X² (Chi-Square) as well as a column with the Exp(B) into my regression output. Is there any idea on how to do this? Many thanks in advance. For now i have calculated this manually for every model and variable, which is quite time consuming.

model_simple <- as.formula("completion_yesno ~  ac + ov + UCRate + FirstWeek + LastWeek + DayofWeekSu + DayofWeekMo + DayofWeekTu + DayofWeekWe + DayofWeekTh + DayofWeekFr + MonthofYearJan + MonthofYearFeb + MonthofYearMar + MonthofYearApr +MonthofYearMay+ MonthofYearJun + MonthofYearJul + MonthofYearAug + MonthofYearSep + MonthofYearOct + MonthofYearNov")
clog_simple1 = glm(model_simple,data=cllw,family = binomial(link = cloglog))
summary(clog_simple1)

Solution

  • Maybe you can elaborate on what you mean by chi-square and exp(B). You can do the below:

    da <- MASS::Pima.tr
    model <- glm(type ~ .,data=da,family = binomial(link = cloglog))
    results <- data.frame(coefficients(summary(model)),check.names=FALSE)
    # some random values
    results$chisq = rchisq(nrow(results),1)
    results$expB = exp(results$Estimate)
    

    Or you can use tidy from broom:

    library(broom)
    results = tidy(model)
    results$expB = exp(results$Estimate)