[R] Changing model parameters in the mi package

Andrew Miles rstuff.miles at gmail.com
Wed Jul 14 17:20:21 CEST 2010


I figured this one out.  I'm sending the solution back to the help  
list so that there is a record of how to deal with this problem, since  
it does not seem to be documented elsewhere.

The mi.info object that you pass to the the mi() function contains a  
value called "params" which allows you to set the parameters used in  
each imputation model.  If you access it like so

info=mi.info(impute.data)
info[["min.func"]]$params

you are presented with a matrix showing a value for only two  
parameters that are passed to every model, n.iter and draw.from.beta.

You can add any other parameters that you want like so:

info[["min.func"]]$params$MaxNWts=3000

This will add the parameter MaxNWts to the min.func model.  This seems  
to have solved the problem I outlined below.

Andrew Miles


On Jul 14, 2010, at 10:33 AM, Andrew Miles wrote:

> I am trying to use the mi package to impute data, but am running  
> into problems with the functions it calls.
>
> For instance, I am trying to impute a categorical variable called  
> "min.func."  The mi() function calls the mi.categorical() function  
> to deal with this variable, which in turn calls the nnet.default()  
> function, and passes it a fixed parameter MaxNWts=1500.  However, as  
> you can see below, the min.func variable needs a higher threshold  
> than 1500.  Is there a way that I can change the MaxNWts parameter  
> that is being sent to nnet.default()?  I've investigated the mi()  
> and mi.info() functions and cannot see a way.
>
> Thanks for your help!  Error message and system info below:
>
> Beginning Multiple Imputation ( Wed Jul 14 10:25:06 2010 ):
> Iteration 1
> Imputation 1 : min.func*
>
> Error while imputing variable: min.func , model: mi.categorical
> Error in nnet.default(X, Y, w, mask = mask, size = 0, skip = TRUE,  
> softmax = TRUE,  :
>  too many (2608) weights
>
> System is Mac OS X 10.5.8, R version 2.9.2
>
>
> Andrew Miles
>
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list