Re: [R] Error in mice package when trying to use subset of variables for imputation model

2020-07-21 Thread John Kane
I wonder if you have a non-ascii symbol in there somewhere? That may be
what this is trying to tell you.

Error in parse(text = x, keep.source = FALSE) :

  :1:1: unexpected '<'


I have no dea what "mice" is supposed to output but using your data,
renamed dat1,
I did

library(mice)
pred <- quickpred(dat1, mincor = .1, minpuc = 0, inc=inlist)

and got
 TSHS_1R TSHS_2R TSHS_3R TSHS_4R TSHS_5R TSHS_6R TSHS_7R TSHS_8R
TSHS_1R0   0   0   0   0   0   0   0
TSHS_2R0   0   0   0   0   0   0   0
TSHS_3R0   0   0   0   0   0   0   0
TSHS_4R0   0   0   0   0   0   0   0
TSHS_5R0   0   0   0   0   0   0   0
TSHS_6R1   1   1   1   1   0   1   1
TSHS_7R0   0   0   0   0   0   0   0
TSHS_8R0   0   0   0   0   0   0   0
TSHS_9R0   0   0   0   0   0   0   0
TSHS_10R   0   0   0   0   0   0   0   0
TSHS_11R   1   1   1   1   1   1   1   1
TSHS_12R   0   0   0   0   0   0   0   0
TSHS_13R   0   0   0   0   0   0   0   0
TSHS_14R   0   0   0   0   0   0   0   0
TSHS_15R   0   0   0   0   0   0   0   0
TSHS_16R   0   0   0   0   0   0   0   0
TSHS_17R   0   0   0   0   0   0   0   0
TSHS_18R   0   0   0   0   0   0   0   0
TSHS_19R   1   1   1   1   1   0   1   1
TSHS_20R   0   0   0   0   0   0   0   0
TSHS_21R   0   0   0   0   0   0   0   0
TSHS_22R   1   1   1   1   1   1   1   1
TSHS_23R   1   1   1   1   1   1   1   1
TSHS_24R   1   1   1   1   1   1   1   1
TSHS_25R   0   0   0   0   0   0   0   0
TSHS_26R   0   0   0   0   0   0   0   0
TSHS_27R   0   0   0   0   0   0   0   0
TSHS_28R   0   0   0   0   0   0   0   0
TSHS_29R   0   0   0   0   0   0   0   0
TSHS_30R   0   0   0   0   0   0   0   0
etc.

On Tue, 21 Jul 2020 at 11:09, Ian McPhail  wrote:

> Hello,
>
>
>
> I am attempting to create a multiple imputation model using the mice
> package in R. Here are some details about what I am specifically trying to
> do, and below is a subset of the data I am working with, the code I have
> tried, and the error that I am getting.
>
>
>
> In the dataset, labelled 'mturk.all', there are ~300 variables and around
> 1300 cases. For the multiple imputation model, I am trying to use only 33
> of the ~300 variables; these 33 variables are dichotomous (coded as 0 and 1
> in the dataset).
>
>
>
> Following the mice code provided at
> https://stefvanbuuren.name/fimd/sec-toomany.html (see section 9.1.6 on the
> linked website), I have tried the following code, which resulted in an
> error (also shown below):
>
>
>
>
>
> ```
>
> >library(mice)
>
> >pred <- quickpred(mturk.all, mincor = .1, minpuc = 0, inc=c("TSHS_1R",
> "TSHS_2R", "TSHS_3R", "TSHS_4R", "TSHS_5R", "TSHS_6R", "TSHS_7R",
> "TSHS_8R", "TSHS_9R", "TSHS_10R", "TSHS_11R", "TSHS_12R", "TSHS_13R",
> "TSHS_14R", "TSHS_15R", "TSHS_16R", "TSHS_17R", "TSHS_18R", "TSHS_19R",
> "TSHS_20R", "TSHS_21R", "TSHS_22R", "TSHS_23R", "TSHS_24R", "TSHS_25R",
> "TSHS_26R", "TSHS_27R", "TSHS_28R", "TSHS_29R", "TSHS_30R", "TSHS_31R",
> "TSHS_32R", "TSHS_33R"))
>
> There were 14 warnings (use warnings() to see them)
>
> > warnings()
>
> Warning messages:
>
> 1: In data.matrix(data) : NAs introduced by coercion
>
> 2: In data.matrix(data) : NAs introduced by coercion
>
> 3: In data.matrix(data) : NAs introduced by coercion
>
> 4: In data.matrix(data) : NAs introduced by coercion
>
> 5: In data.matrix(data) : NAs introduced by coercion
>
> 6: In data.matrix(data) : NAs introduced by coercion
>
> 7: In data.matrix(data) : NAs introduced by coercion
>
> 8: In data.matrix(data) : NAs introduced by coercion
>
> 9: In data.matrix(data) : NAs introduced by coercion
>
> 10: In data.matrix(data) : NAs introduced by coercion
>
> 11: In data.matrix(data) : NAs introduced by coercion
>
> 12: In data.matrix(data) : NAs introduced by coercion
>
> 13: In data.matrix(data) : NAs introduced by coercion
>
> 14: In data.matrix(data) : NAs introduced by coercion
>
> >mturk.all.imp <- mice(mturk.all, m = 40, method = 'logreg', pred = pred)
>
> Error in parse(text = x, keep.source = FALSE) :
>
>   :1:1: unexpected '<'
>
> 1: <
>
> 

[R] Error in mice package when trying to use subset of variables for imputation model

2020-07-21 Thread Ian McPhail
Hello,



I am attempting to create a multiple imputation model using the mice
package in R. Here are some details about what I am specifically trying to
do, and below is a subset of the data I am working with, the code I have
tried, and the error that I am getting.



In the dataset, labelled 'mturk.all', there are ~300 variables and around
1300 cases. For the multiple imputation model, I am trying to use only 33
of the ~300 variables; these 33 variables are dichotomous (coded as 0 and 1
in the dataset).



Following the mice code provided at
https://stefvanbuuren.name/fimd/sec-toomany.html (see section 9.1.6 on the
linked website), I have tried the following code, which resulted in an
error (also shown below):





```

>library(mice)

>pred <- quickpred(mturk.all, mincor = .1, minpuc = 0, inc=c("TSHS_1R",
"TSHS_2R", "TSHS_3R", "TSHS_4R", "TSHS_5R", "TSHS_6R", "TSHS_7R",
"TSHS_8R", "TSHS_9R", "TSHS_10R", "TSHS_11R", "TSHS_12R", "TSHS_13R",
"TSHS_14R", "TSHS_15R", "TSHS_16R", "TSHS_17R", "TSHS_18R", "TSHS_19R",
"TSHS_20R", "TSHS_21R", "TSHS_22R", "TSHS_23R", "TSHS_24R", "TSHS_25R",
"TSHS_26R", "TSHS_27R", "TSHS_28R", "TSHS_29R", "TSHS_30R", "TSHS_31R",
"TSHS_32R", "TSHS_33R"))

There were 14 warnings (use warnings() to see them)

> warnings()

Warning messages:

1: In data.matrix(data) : NAs introduced by coercion

2: In data.matrix(data) : NAs introduced by coercion

3: In data.matrix(data) : NAs introduced by coercion

4: In data.matrix(data) : NAs introduced by coercion

5: In data.matrix(data) : NAs introduced by coercion

6: In data.matrix(data) : NAs introduced by coercion

7: In data.matrix(data) : NAs introduced by coercion

8: In data.matrix(data) : NAs introduced by coercion

9: In data.matrix(data) : NAs introduced by coercion

10: In data.matrix(data) : NAs introduced by coercion

11: In data.matrix(data) : NAs introduced by coercion

12: In data.matrix(data) : NAs introduced by coercion

13: In data.matrix(data) : NAs introduced by coercion

14: In data.matrix(data) : NAs introduced by coercion

>mturk.all.imp <- mice(mturk.all, m = 40, method = 'logreg', pred = pred)

Error in parse(text = x, keep.source = FALSE) :

  :1:1: unexpected '<'

1: <

^

```



Alternatively, I tried the following:



```

>inlist <- mturk.all[c("TSHS_1R", "TSHS_2R", "TSHS_3R", "TSHS_4R",
"TSHS_5R", "TSHS_6R", "TSHS_7R", "TSHS_8R", "TSHS_9R", "TSHS_10R",
"TSHS_11R", "TSHS_12R", "TSHS_13R", "TSHS_14R", "TSHS_15R", "TSHS_16R",
"TSHS_17R", "TSHS_18R", "TSHS_19R", "TSHS_20R", "TSHS_21R", "TSHS_22R",
"TSHS_23R", "TSHS_24R", "TSHS_25R", "TSHS_26R", "TSHS_27R", "TSHS_28R",
"TSHS_29R", "TSHS_30R", "TSHS_31R", "TSHS_32R", "TSHS_33R")]

>pred <- quickpred(mturk.all, mincor = .1, minpuc = 0, inc=inlist)

>mturk.all.imp <- mice(mturk.all, m = 40, method = 'logreg', pred = pred)

Error in parse(text = x, keep.source = FALSE) :

  :1:1: unexpected '<'

1: <

^

```



I have also switched out the 'logreg' imputation method with 'pmm' and
received the same error message.



Here is a subset of the dataset, mturk.all, and the version of R Studio I
am using, plus the version of mice I am using.



```

> dput(mturk.all[425:434, 1:33])

structure(list(TSHS_1R = c(0, 1, 1, 0, 0, 0, 1, 1, 0, 1), TSHS_2R = c(0,

0, 0, 1, 0, 0, 0, 0, 0, 0), TSHS_3R = c(0, 1, 0, 0, 0, 0, 0,

0, 1, 0), TSHS_4R = c(0, 1, 0, 0, 0, 0, 1, 0, 1, 0), TSHS_5R = c(0,

0, 0, 1, 0, 0, 0, 0, 1, 0), TSHS_6R = c(0, 0, NA, NA, 0, 0, 1,

0, 0, 0), TSHS_7R = c(0, 0, 0, 1, 0, 1, 1, 0, 0, 0), TSHS_8R = c(1,

1, 0, 0, 1, 1, 1, 1, 0, 1), TSHS_9R = c(0, 0, 0, 0, 0, 0, 0,

1, 1, 0), TSHS_10R = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0), TSHS_11R = c(0,

0, NA, 0, 0, 0, 0, 1, 0, 0), TSHS_12R = c(1, 0, 1, 0, 1, 0, 0,

0, 0, 0), TSHS_13R = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 1), TSHS_14R = c(0,

0, 0, 0, 0, 0, 0, 0, 0, 0), TSHS_15R = c(0, 0, 1, 0, 0, 0, 0,

0, 0, 0), TSHS_16R = c(0, 0, 1, 0, 0, 0, 0, 0, 0, 0), TSHS_17R = c(0,

0, 0, 0, 0, 0, 0, 0, 0, 0), TSHS_18R = c(0, 0, 0, 0, 1, 0, 0,

0, 0, 0), TSHS_19R = c(0, 0, 0, NA, 0, 0, 0, 0, 0, 0), TSHS_20R = c(0,

0, 0, 1, 0, 0, 0, 0, 0, 0), TSHS_21R = c(0, 0, 0, 0, 1, 0, 0,

0, 0, 0), TSHS_22R = c(0, 1, 0, 0, NA, 1, 0, 0, 0, 0), TSHS_23R = c(0,

0, 0, 0, NA, 1, 0, 0, 0, 1), TSHS_24R = c(0, 0, 0, 1, NA, 1,

0, 1, 1, 0), TSHS_25R = c(1, 1, 1, 0, 1, 1, 1, 1, 1, 1), TSHS_26R = c(1,

0, 1, 0, 0, 0, 0, 1, 0, 1), TSHS_27R = c(1, 0, 0, 1, 0, 1, 1,

0, 0, 1), TSHS_28R = c(0, 0, 0, 0, 0, 0, 0, 0, 1, 0), TSHS_29R = c(1,

0, 0, 0, 1, 0, 0, 0, 0, 0), TSHS_30R = c(0, 0, 0, 0, 0, 0, 0,

0, 0, 0), TSHS_31R = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0), TSHS_32R = c(0,

0, 0, 0, 0, 0, 0, 0, 0, 0), TSHS_33R = c(0, 0, 0, 0, 0, 0, 0,

0, 0, 0)), row.names = c(NA, -10L), class = c("tbl_df", "tbl",

"data.frame"))

> rstudioapi::versionInfo()

$`citation`



To cite RStudio in publications use:



  RStudio Team (2018). RStudio: Integrated Development for R. RStudio,
Inc., Boston, MA URL http://www.rstudio.com/.



A BibTeX entry for LaTeX users is



  @Manual{,

title =

Re: [R] Error in mice

2012-06-26 Thread Prof Brian Ripley

On 26/06/2012 08:59, Anera Salucci wrote:

Hi all,

I am imputing missingness of  90 columns  in a  data frame using mice.
But "mice" gives back :

  Error in nnet.default(X, Y, w, mask = mask, size = 0, skip = TRUE, softmax = 
TRUE,  :   too many (1100) weights

Any idea to solve this error is welcome,


See ?nnet (in package nnet).



Anera
[[alternative HTML version deleted]]



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.




--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Error in mice

2012-06-26 Thread Anera Salucci
Hi all,

I am imputing missingness of  90 columns  in a  data frame using mice.
But "mice" gives back :

 Error in nnet.default(X, Y, w, mask = mask, size = 0, skip = TRUE, softmax = 
TRUE,  :   too many (1100) weights

Any idea to solve this error is welcome,

Anera
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.