r-mice

'R', 'mice', missing variable imputation - how to only do one column in sparse matrix

↘锁芯ラ 提交于 2020-06-26 06:22:30
问题 I have a matrix that is half-sparse. Half of all cells are blank (na) so when I try to run the 'mice' it tries to work on all of them. I'm only interested in a subset. Question: In the following code, how do I make "mice" only operate on the first two columns? Is there a clean way to do this using row-lag or row-lead, so that the content of the previous row can help patch holes in the current row? set.seed(1) #domain x <- seq(from=0,to=10,length.out=1000) #ranges y <- sin(x) +sin(x/2) + rnorm

multiple imputation and multigroup SEM in R

匆匆过客 提交于 2020-06-17 15:17:18
问题 I want to perform multigroup SEM on imputed data using the R packages mice and semTools , specifically the runMI function that calls Lavaan . I am able to do so when imputing the entire dataset at once, but whilst trawling through stackoverflow/stackexchange I have come across the recommendation to impute data separately for each level of a grouping variable (e.g. men, women), so that the features of each group are preserved (e.g. https://stats.stackexchange.com/questions/149053/questions-on

multiple imputation and multigroup SEM in R

纵然是瞬间 提交于 2020-06-17 15:17:13
问题 I want to perform multigroup SEM on imputed data using the R packages mice and semTools , specifically the runMI function that calls Lavaan . I am able to do so when imputing the entire dataset at once, but whilst trawling through stackoverflow/stackexchange I have come across the recommendation to impute data separately for each level of a grouping variable (e.g. men, women), so that the features of each group are preserved (e.g. https://stats.stackexchange.com/questions/149053/questions-on

Rpy2: calling to function conaining dots

微笑、不失礼 提交于 2020-05-28 09:48:55
问题 I'm tring to run a R function in Pyton via Jupyter Notebook. the problem is, that my function name (from mice lib) - containing dot. the name of the function is md.pattern , and this is the code that I'm tring to run: from rpy2.robjects.packages import importr mice = importr('mice') mice.md.pattern(train) and this is the error that I get: AttributeError: module 'mice' has no attribute 'md' I also tried to run: from rpy2.robjects.packages import importr mice = importr('mice') pattern =

Rpy2: calling to function conaining dots

五迷三道 提交于 2020-05-28 09:45:31
问题 I'm tring to run a R function in Pyton via Jupyter Notebook. the problem is, that my function name (from mice lib) - containing dot. the name of the function is md.pattern , and this is the code that I'm tring to run: from rpy2.robjects.packages import importr mice = importr('mice') mice.md.pattern(train) and this is the error that I get: AttributeError: module 'mice' has no attribute 'md' I also tried to run: from rpy2.robjects.packages import importr mice = importr('mice') pattern =

Rpy2: calling to function conaining dots

自闭症网瘾萝莉.ら 提交于 2020-05-28 09:42:36
问题 I'm tring to run a R function in Pyton via Jupyter Notebook. the problem is, that my function name (from mice lib) - containing dot. the name of the function is md.pattern , and this is the code that I'm tring to run: from rpy2.robjects.packages import importr mice = importr('mice') mice.md.pattern(train) and this is the error that I get: AttributeError: module 'mice' has no attribute 'md' I also tried to run: from rpy2.robjects.packages import importr mice = importr('mice') pattern =

Running mice with a formula as a variable: instant evaluation instead of later evaluation?

三世轮回 提交于 2020-02-24 11:26:47
问题 The R package mice comes with following example: library("mice") imp <- mice(nhanes) fit <- with(data=imp,exp=lm(bmi~hyp+chl)) I want a flexible call of with() like: model_formula <- bmi~hyp+chl fit <- with(data=imp,exp=lm(model_formula)) But this throws Error in eval(predvars, data, env) : object 'bmi' not found . I searched for similar problems. The closet problem I found was Help understand the error in a function I defined in R. My impression is, that writing exp=lm(model_formula) the

Mice pool() function and coxph(): in mice.df (…) : large sample assumend?

六月ゝ 毕业季﹏ 提交于 2020-01-13 18:05:14
问题 I used coxph() from the survival package in multiply imputed dataset and encountered a warning when trying to pool the results. The warning message states: "In mice.df(m, lambda, dfcom, method) : Large sample assumed. A reproducible example is below (with publically available data, without worrying to much about the appropriateness of using both mice and coxph is these data): library(mice) library(survival) #load publically available data data(pbc) #select variables for the reproducable

Mice pool() function and coxph(): in mice.df (…) : large sample assumend?

随声附和 提交于 2020-01-13 18:03:50
问题 I used coxph() from the survival package in multiply imputed dataset and encountered a warning when trying to pool the results. The warning message states: "In mice.df(m, lambda, dfcom, method) : Large sample assumed. A reproducible example is below (with publically available data, without worrying to much about the appropriateness of using both mice and coxph is these data): library(mice) library(survival) #load publically available data data(pbc) #select variables for the reproducable