Print testEstimates to more than 3 decimal places
Closed this issue · 3 comments
Hi there - I'm wanting to apply FDR correction to the p-values extracted from mitml. In order to do this, I need greater precision in the p-values printed from testEstimates. I've tried a few workarounds (with my limited programming knowledge) but none have worked for me. I wonder if this is possible? Any help here would be really appreciated.
Thanks,
Louise
This is an example of what I have tried;
library(tryCatchLog)
sink('model_results.txt')
for(i in c(1:68)){
resp <- paste('CV',i,sep='')
for(j in c(15:18)){
V <- paste('V',j,sep='')
f <- as.formula(paste(resp,'',V,'+ sex + race + (1|family) + (1|Device)'))',V,'+ sex + race + (1|family) + (1|Device)')), control = lmerControl(optimizer ="bobyqa"))}, warning=function(w){cat("Error fitting model for:",resp,'--',V,end='\n')}))
print(f)
m <- with(impList,tryCatch({lmer(as.formula(paste(resp,'
print(testEstimates(m), digits=10)
est <- testEstimates(m)
print(confint(est), digits=10)
}
}
print(confint(est), digits=10) - by changing the number of digits here, I can get different decimal places in the confidence intervals
print(testEstimates(m), digits=10) - no matter what I enter for the digits here, the number of decimal places remains 3.
Thank you!
The print method doesn't understand digits
, but you don't need that because the results are always saved with full precision in the objects produced by testEstimates()
. To get all the decimal places or round them to a certain number of digits, you can look at the results in the object and round those:
library(mitml)
data(studentratings)
fml <- ReadDis + ReadAchiev ~ 1
imp <- jomoImpute(formula = fml, data = studentratings, n.burn = 500, n.iter = 100, m = 5)
implist <- mitmlComplete(imp)
fit <- with(implist, lm(ReadDis ~ ReadAchiev))
res <- testEstimates(fit)
res
# Call:
#
# testEstimates(model = fit)
#
# Final parameter estimates and inferences obtained from 5 imputed data sets.
#
# Estimate Std.Error t.value df P(>|t|) RIV FMI
# (Intercept) 3.678 0.160 22.955 34.610 0.000 0.515 0.375
# ReadAchiev -0.002 0.000 -7.106 47.290 0.000 0.410 0.319
#
# Unadjusted hypothesis test as appropriate in larger samples.
round(res$estimates, 5)
# Estimate Std.Error t.value df P(>|t|) RIV FMI
# (Intercept) 3.67821 0.16024 22.95491 34.61005 0 0.51506 0.37506
# ReadAchiev -0.00220 0.00031 -7.10613 47.29015 0 0.41011 0.31904
Thanks for the good suggestion about the print method, though. I think it's a good idea to make them respect options("digits")
in the future.
Perfect. Thank you so much for your help with this. And thank you for an excellent package!
Louise