Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Samples with NA in covariates are silently removed #29

Closed
cpauvert opened this issue Feb 14, 2019 · 2 comments
Closed

Samples with NA in covariates are silently removed #29

cpauvert opened this issue Feb 14, 2019 · 2 comments
Labels

Comments

@cpauvert
Copy link
Collaborator

Hi again,

I just noticed that some samples were removed if NA were present in the covariates used (reprex below). Perhaps some users would like to know at least as a warning, like in the prepare_data function, before the #8 is solved, I guess. Otherwise, one can still check before including them.

data("trichoptera")
trichoptera <- prepare_data(trichoptera$Abundance, trichoptera$Covariate)
trichoptera$Pressure[29:32]<-NA
fit <- PLN(Abundance ~ 1 + Pressure + Temperature, data = trichoptera)

> dim(fitted(fit))
[1] 45 17
> dim(trichoptera$Abundance)
[1] 49 17

> data.frame(
+ fitted   = as.vector(fitted(fit)),
+ observed = as.vector(trichoptera$Abundance)
+ )
Error in data.frame(fitted = as.vector(fitted(fit)), observed = as.vector(trichoptera$Abundance)) : 
  les arguments impliquent des nombres de lignes différents : 765, 833
@mahendra-mariadassou
Copy link
Collaborator

mahendra-mariadassou commented Feb 14, 2019

This is the standard behavior for lm and glm.

data("trichoptera")
trichoptera <- prepare_data(trichoptera$Abundance, trichoptera$Covariate)
trichoptera$Pressure[29:32]<-NA
fit <- lm(Precipitation ~ Pressure, data = trichoptera)

> length(fitted(fit))
[1] 45
> nrow(trichoptera)
[1] 49

@jchiquet may have a different opinion but I think we should stick with lm here. Issue #8 is slightly different: we can handle missing data in the count matrix, not in the covariates.

@cpauvert
Copy link
Collaborator Author

cpauvert commented Feb 14, 2019

Alright. Thanks for the explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants