R/1.8.createCoefficientsTable.R

Defines functions createCoefficientsTable

createCoefficientsTable <- function(fit) {
  coefficientsTable <- tibble::tibble(
    "  " = rownames(fit$coefficients),
    "Estimate" = round(fit$coefficients, 2),
    "Std. Error" = round(fit$se, 2),
    "t value" = round(fit$coefficients / fit$se, 4),
    "P(t>|t|)" = round(2 * stats::pnorm(-abs(fit$coefficients / fit$se)), 4),
    " " = ifelse(2 * stats::pnorm(-abs(fit$coefficients / fit$se)) < 0.001, "***",
      ifelse(2 * stats::pnorm(-abs(fit$coefficients / fit$se)) < 0.01, "**",
        ifelse(2 * stats::pnorm(-abs(fit$coefficients / fit$se)) < 0.05, "*",
          ifelse(2 * stats::pnorm(-abs(fit$coefficients / fit$se)) < 0.1, ".", "")
        )
      )
    )
  )

  return(coefficientsTable)
}

Try the Mmcsd package in your browser

Any scripts or data that you put into this service are public.

Mmcsd documentation built on March 31, 2023, 7:23 p.m.