Closed bernard-liew closed 3 years ago
Apologies,
I realised for error 2 it is because there is missing data in my dataframe. I assume one needs to remove it prior.
For error 1, i assume one cannot paste a formula string directly into the neModel call?
Regards, Bernard
Thanks for your interest in medflex! Your answers are correct. The code below works, using complete cases.
samp.df <- samp.df[complete.cases(samp.df), ]
out.mod <- glm(osw_late ~ grp + pain_cope_success_early + lbp_early, data = samp.df)
impData <- neImpute(out.mod, nMed = 1)
ne.mod <- neModel(osw_late ~ grp0 + grp1 + lbp_early , expData = impData, se = "robust")
If you wish to run the analysis accounting for the missing data, you can use the functionality of the mice
and mitools
packages, as explained in the package vignette (section 9.2).
Also note that to obtain robust standard errors, one must use glm
instead of lm
for fitting the imputation model.
Please close this issue if you agree it has been solved.
Dear team,
many thanks for your lovely package. I hope everyone is safe too currently.
I am trying to run some analysis on my data but ran into some errors. Here is a sample of my data with the codes and errors. I would appreciate any help.
R version 3.6.2 (2019-12-12) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 18363)
Matrix products: default
locale: [1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252
attached base packages: [1] stats graphics grDevices utils datasets methods base
other attached packages: [1] medflex_0.6-6 multcomp_1.4-11 TH.data_1.0-10 MASS_7.3-51.5 survival_3.1-8 mvtnorm_1.0-11
loaded via a namespace (and not attached): [1] zip_2.0.4 Rcpp_1.0.3 cellranger_1.1.0 compiler_3.6.2 pillar_1.4.3 forcats_0.4.0
[7] tools_3.6.2 zeallot_0.1.0 packrat_0.5.0 tibble_2.1.3 lattice_0.20-38 pkgconfig_2.0.3
[13] rlang_0.4.4 openxlsx_4.1.4 Matrix_1.2-18 rstudioapi_0.11 curl_4.3 haven_2.2.0
[19] rio_0.5.16 vctrs_0.2.1 hms_0.5.2 grid_3.6.2 data.table_1.12.8 readxl_1.3.1
[25] foreign_0.8-72 carData_3.0-3 car_3.0-6 magrittr_1.5 backports_1.1.5 codetools_0.2-16 [31] splines_3.6.2 abind_1.4-5 sandwich_2.5-1 stringi_1.4.3 crayon_1.3.4 zoo_1.8-6
Regards, Bernard