glm_impute: Impute missing data using GLM models

View source: R/multiscaleSVDxpts.R

glm_imputeR Documentation

Impute missing data using GLM models

Description

Impute missing data using GLM models

Usage

glm_impute(
  dataframe,
  columns_to_impute,
  predictor_columns,
  family = "gaussian"
)

Arguments

dataframe

A data frame containing the data to impute.

columns_to_impute

A vector of column names to impute.

predictor_columns

A vector of column names to use as predictors.

family

A string specifying the GLM family (default is 'gaussian').

Value

A data frame with imputed values.

Examples

set.seed(123)
df <- data.frame(
  age = c(25, 30, 35, NA, 45, 50, NA, 40, 35, NA),
  income = c(50000, 60000, 70000, 80000, 90000, 100000, 110000, NA, 120000, 130000),
  education = c(12, 16, 14, 12, NA, 18, 20, 16, 14, 12)
)
columns_to_impute <- c("age")
predictor_columns <- c( "income", "education")
imputed_data <- glm_impute(df, columns_to_impute, predictor_columns, family = 'gaussian')
print(imputed_data)

stnava/ANTsR documentation built on April 13, 2025, 4:10 a.m.