You want na.action = na.exclude. Or remove rows with NA values from your 
dataset. Which is IMHO the safest way to build a model.

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and 
Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium
+ 32 2 525 02 51
+ 32 54 43 61 85
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not ensure 
that a reasonable answer can be extracted from a given body of data.
~ John Tukey


-----Oorspronkelijk bericht-----
Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens 
jpm miao
Verzonden: dinsdag 21 oktober 2014 10:29
Aan: r-help
Onderwerp: [R] Dealing with NAs in lm or gmm

Hi,

   My question is about NAs in the function "gmm", but I believe that the same 
issues occur in the case of "lm".

   I try to estimate a model by "gmm" function (GMM, generalized method of 
moments). Each of the  variables has 94 rows, but the resulting fitted model 
has only 89 rows. Then the function removes the rows with NAs.  I want to add a 
94*1 vector, ONI, to the resulting fitted values; I want to find the fitted 
value with NAs kept. How can I do it? na.action?

   Code:

   > gmm8<-gmm(y~RDR1+xx, xiv)
Warning message:
In getDat(object$g, object$x) :
  There are missing values. Associated observations have been removed

> ONI.gmm8<-fitted(gmm8)+0.85*ONI
Error in NextMethod(.Generic) :
  dims [product 89] do not match the length of object [94] In addition: Warning 
message:
In `+.default`(fitted(gmm8), 0.85 * ONI) :
  longer object length is not a multiple of shorter object length

Help on na.action:
na.action
a function which indicates what should happen when the data contain NAs.
The default is set by the na.action setting of options, and is na.fail if that 
is unset. The ‘factory-fresh’ default is na.omit. Another possible value is 
NULL, no action. Value na.exclude can be useful.

Thanks!

Miao

        [[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.
* * * * * * * * * * * * * D I S C L A I M E R * * * * * * * * * * * * *
Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en 
binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is 
door een geldig ondertekend document.
The views expressed in this message and any annex are purely those of the 
writer and may not be regarded as stating an official position of INBO, as long 
as the message is not confirmed by a duly signed document.
______________________________________________
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.

Reply via email to