From: Ferdinand Alimadhi <falimadhi_at_iq.harvard.edu>

Date: Fri 14 Jul 2006 - 08:10:48 EST

Date: Fri 14 Jul 2006 - 08:10:48 EST

why dont you use "Amelia"?

It's an R package which deal with missing data in R
http://gking.harvard.edu/amelia/

Ferdinand Alimadhi wrote:

>You can deal with the missing values before performing any regression model.

*>if you dataset is :
**>
**> > D
**> X1 X2 X3
**>1 NA 2 4
**>2 1 NA NA
**>3 2 2 6
**>4 NA 34 NA
**>5 3 NA 7
**>
**>then the following will replace all NA with the mean value
**>
**> > f<-function(col){
**>+ col[is.na(col)]<-mean(col,na.rm=TRUE)
**>+ col}
**> > sapply(D,f)
**> X1 X2 X3
**>[1,] 2 2.00000 4.000000
**>[2,] 1 12.66667 5.666667
**>[3,] 2 2.00000 6.000000
**>[4,] 2 34.00000 5.666667
**>[5,] 3 12.66667 7.000000
**>
**>
**>Hope this is what you want.
**>
**>zhijie zhang wrote:
**>
**>
**>
**>>Dear Rusers,
**>>The default behavior in R when performing a regression model with missing
**>>values is to exclude any case that contains a
**>>missing value? How could i set the bahavior that R deal with missing values?
**>>e.g.:
**>>exclude cases listwise
**>>exclude cases pairwise
**>>replace with mean
**>>
**>>Thanks very much!
**>>
**>>
**>>
**>>
**>>
**>
**>
**>
**>
*

-- Ferdinand Alimadhi Programmer / Analyst Harvard University The Institute for Quantitative Social Science (617) 496-0187 falimadhi@iq.harvard.edu www.iq.harvard.edu [[alternative HTML version deleted]] ______________________________________________ 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.htmlReceived on Fri Jul 14 08:19:45 2006

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.1.8, at Fri 14 Jul 2006 - 10:14:33 EST.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*