Re: [R] missing data imputation

From: Frank E Harrell Jr <f.harrell_at_vanderbilt.edu>
Date: Sat 09 Jul 2005 - 08:59:56 EST

Anders Schwartz Corr wrote:
> Dear R-help,
>
> I am trying to impute missing data for the first time using R. The norm
> package seems to work for me, but the missing values that it returns seem
> odd at times -- for example it returns negative values for a variable that
> should only be positive. Does this matter in data analysis, and/or is
> there a way to limit the imputed values to be within the minimum and
> maximum of the actual data? Below is the code I am using.
>
> Thanks,
>
> Anders Corr
> Ph.D. Candidate

Yes that matters. That's one reason I wrote the aregImpute function in the Hmisc package. By default it uses predictive mean matching so it can't produce illegal values.

Frank

>
>
> #DOWNLOAD DATA (61Kb)
> download.file("http://www.people.fas.harvard.edu/~corr/tc.csv","C:/R")
>
> #RUN NORM
> tc <- read.csv("tc.csv", header = TRUE)
> rngseed(1234567) #set random number generator seed
> s <- prelim.norm(tc)
> thetahat <- em.norm(s) #find the MLE for a starting value
> theta <- da.norm(s,thetahat,steps=20,showits=TRUE,return.ymis=TRUE) #take 20 steps
> ximp <- imp.norm(s,thetahat,tc) #impute missing data under the MLE
>

-- 
Frank E Harrell Jr   Professor and Chair           School of Medicine
                      Department of Biostatistics   Vanderbilt University

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Sat Jul 09 09:07:18 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:26 EST