nt_simple_glm: Simple Generalized Linear Models

View source: R/glm_regression.R

nt_simple_glmR Documentation

Simple Generalized Linear Models

Description

Fit simple GLM.

Usage

nt_simple_glm(
  data,
  response,
  ...,
  family,
  robust.variance = NULL,
  increment = NULL,
  ci.type = "Wald",
  conf.level = 0.95,
  exponentiate = FALSE,
  format = TRUE,
  labels = NULL,
  digits = 2,
  digits.p = 3,
  save = FALSE,
  file = "simple_logistic"
)

Arguments

data

a data frame with the variables.

response

a character value indicating the response variable.

...

character values indicating confounding variables.

family

a character indicating family distribution. See more family.

robust.variance

a function yielding a covariance matrix or a covariance matrix. See more coeftest.

increment

a named list indicating the magnitude of increments to calculate odds ratio for continuous covariates.

ci.type

a character value indicating the procedure to calculate confidence intervals: likelihood ratio (profile) or wald (Wald)

conf.level

a numerical value indicating the confidence level for parameters of interest.

exponentiate

a logical value indicating whether coefficients should be exponentiated.

format

a logical value indicating whether the output should be formatted.

labels

a list of labels with components given by their variable names.

digits

a numerical value defining of digits to present the results.

digits.p

a numerical value defining number of digits to present the p-values.

save

a logical value indicating whether the output should be saved as a csv file.

file

a character indicating the name of output file in csv format to be saved.

Examples

library(titanic)
library(dplyr)

data(titanic_train)
titanic_nt <- titanic_train |>
 mutate(Sex = factor(Sex,
                     levels = c("male", "female"),
                     labels = c("Male", "Female")),
        Pclass = factor(Pclass,
                        levels = 1:3,
                        labels = c("I", "II", "III")),
        Embarked = factor(Embarked,
                          levels = c("C", "Q", "S"),
                          labels = c("Cherbourg", "Queenstown", "Southampton")))

titanic_nt |> select(Survived, Sex, Age, Pclass, Embarked) |>
 nt_simple_glm(response = Survived, Age,
                    family = binomial(link = "logit"),
                    exponentiate = TRUE,
                    labels = list(Pclass = "Passenger class"))


dnzmarcio/ntimes documentation built on Jan. 4, 2024, 2:23 p.m.