Learn R Programming

Indicator (version 0.1.3)

lm_imputation: Function to apply nan inputation with linear regression

Description

The lm_imputation function aims to replace missing values (NA) in a dataset with values estimated using a linear regression model. This technique allows the existing relationships between variables in the dataset to be used to accurately estimate missing values

Usage

lm_imputation(data, to_impute, regressors)

Value

It returns a dataframe with imputed values

Arguments

data

dataframe with rows = observations and columns = quantitative variables

to_impute

string , name of the variables whre there are NANs to impute

regressors

vector of string with names of the variables to use to apply linear regression imputation

References

OECD/European Union/EC-JRC (2008), Handbook on Constructing Composite Indicators: Methodology and User Guide, OECD Publishing, Paris, <https://doi.org/10.1787/9789264043466-en>

Examples

Run this code

data("airquality")
regressors<-colnames(airquality[,c(3,4)])
lm_imputation(data =airquality,"Ozone",regressors = regressors)

Run the code above in your browser using DataLab