It looks like gmm is not handling na.exclude correctly. You should contact the package maintainer.
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<mailto:thierry.onkel...@inbo.be> www.inbo.be<http://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 Van: jpm miao [mailto:miao...@gmail.com] Verzonden: dinsdag 21 oktober 2014 11:35 Aan: ONKELINX, Thierry CC: r-help Onderwerp: Re: [R] Dealing with NAs in lm or gmm I tries "na.action = na.exclude" but it returns a fitted vector with NAs removed. Is there any way to return the fitted vector with NAs (In my case, 94*1 matrix)? > gmm8<-gmm(y~RDR1+xx, xiv, na.action = na.exclude) Warning message: In getDat(object$g, object$x) : There are missing values. Associated observations have been removed > nrow(fitted(gmm8)) [1] 89 > nrow(xx) NULL > nrow(as.matrix(xx)) [1] 94 > nrow(RDR1) [1] 94 > nrow(y) [1] 94 2014-10-21 17:27 GMT+08:00 ONKELINX, Thierry <thierry.onkel...@inbo.be<mailto:thierry.onkel...@inbo.be>>: 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<tel:%2B%2032%202%20525%2002%2051> + 32 54 43 61 85<tel:%2B%2032%2054%2043%2061%2085> thierry.onkel...@inbo.be<mailto:thierry.onkel...@inbo.be> www.inbo.be<http://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> [mailto: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<mailto: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. * * * * * * * * * * * * * 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. [[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.