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
[EMAIL PROTECTED]
www.iq.harvard.edu
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html