This function uses the Amelia package to impute a given data frame and return the imputed values.

impute_dataframe(df, measurements_per_day, repetitions = 30)

Arguments

df

a data frame

measurements_per_day

The number of measurements per day in the diary study

repetitions

The amount of times the Amelia call should be averaged over. Defaults to 30. The actual number of imputations is five times the value for repetitions, since Amelia's values are already averaged over five runs.

Value

This function returns the modified data frame.

Examples

data <- generate_numerical_test_data(40) data
#> id tijdstip something #> 1 1 NA NA #> 2 1 7.131129 391.71823 #> 3 1 29.582397 274.64996 #> 4 1 NA 144.06037 #> 5 1 3.482797 480.49675 #> 6 1 29.677464 1174.06622 #> 7 1 NA 783.72277 #> 8 1 NA 328.77809 #> 9 1 17.854679 305.21776 #> 10 1 NA 532.35094 #> 11 1 4.744942 1229.45761 #> 12 1 16.178128 103.86086 #> 13 1 20.251844 258.33473 #> 14 1 NA 387.53872 #> 15 1 14.093044 321.51461 #> 16 1 22.239532 285.32783 #> 17 1 NA 28.89721 #> 18 1 22.836601 NA #> 19 1 21.588764 137.81367 #> 20 1 36.880216 253.32342 #> 21 1 NA NA #> 22 1 NA 986.38742 #> 23 1 NA 70.14426 #> 24 1 32.421521 NA #> 25 1 9.518809 563.34356 #> 26 1 20.959861 NA #> 27 1 35.094032 1420.59144 #> 28 1 14.999714 612.11627 #> 29 1 23.108879 1282.78163 #> 30 1 NA 175.54598 #> 31 1 NA 924.33056 #> 32 1 22.542726 293.23382 #> 33 1 NA NA #> 34 1 NA NA #> 35 1 7.729795 NA #> 36 1 NA 372.25610 #> 37 1 28.293345 278.22997 #> 38 1 13.979191 206.93043 #> 39 1 38.940924 NA #> 40 1 23.673276 1143.65105
impute_dataframe(data,measurements_per_day=1)
#> id tijdstip something #> 1 1 14.002721 430.75827 #> 2 1 7.131129 391.71823 #> 3 1 29.582397 274.64996 #> 4 1 16.605677 144.06037 #> 5 1 3.482797 480.49675 #> 6 1 29.677464 1174.06622 #> 7 1 15.788297 783.72277 #> 8 1 15.542639 328.77809 #> 9 1 17.854679 305.21776 #> 10 1 20.626080 532.35094 #> 11 1 4.744942 1229.45761 #> 12 1 16.178128 103.86086 #> 13 1 20.251844 258.33473 #> 14 1 21.668926 387.53872 #> 15 1 14.093044 321.51461 #> 16 1 22.239532 285.32783 #> 17 1 21.062323 28.89721 #> 18 1 22.836601 451.19641 #> 19 1 21.588764 137.81367 #> 20 1 36.880216 253.32342 #> 21 1 21.408870 512.13946 #> 22 1 21.543851 986.38742 #> 23 1 17.744876 70.14426 #> 24 1 32.421521 533.52052 #> 25 1 9.518809 563.34356 #> 26 1 20.959861 602.35246 #> 27 1 35.094032 1420.59144 #> 28 1 14.999714 612.11627 #> 29 1 23.108879 1282.78163 #> 30 1 20.373802 175.54598 #> 31 1 25.882412 924.33056 #> 32 1 22.542726 293.23382 #> 33 1 26.524460 625.60976 #> 34 1 21.515369 600.35678 #> 35 1 7.729795 601.36885 #> 36 1 25.743455 372.25610 #> 37 1 28.293345 278.22997 #> 38 1 13.979191 206.93043 #> 39 1 38.940924 756.10249 #> 40 1 23.673276 1143.65105