I get a strange error when using se = FALSE in geom_smooth. Even
stranger is that it does not occur when using smaller subsamples of the
dataset. The dataset is attached.
Any ideas?
Best regards,
Thierry
> library(ggplot2)
> ggplot(test, aes(x = A, y = B, colour = C)) + geom_smooth()
> ggplot(test, aes(x = A, y = B, colour = C)) + geom_smooth(se = FALSE)
Error in class(output[[var]]) <- class(value) :
cannot set class to "array" unless the dimension attribute has length
> 0
> ggplot(tail(test, 3900), aes(x = A, y = B, colour = C)) +
geom_smooth(se = FALSE)
> ggplot(head(test, 3900), aes(x = A, y = B, colour = C)) +
geom_smooth(se = FALSE)
> ggplot(head(test, 4000), aes(x = A, y = B, colour = C)) +
geom_smooth(se = FALSE)
Error in class(output[[var]]) <- class(value) :
cannot set class to "array" unless the dimension attribute has length
> 0
> sessionInfo()
R version 2.11.1 (2010-05-31)
i386-pc-mingw32
locale:
[1] LC_COLLATE=Dutch_Belgium.1252 LC_CTYPE=Dutch_Belgium.1252
[3] LC_MONETARY=Dutch_Belgium.1252 LC_NUMERIC=C
[5] LC_TIME=Dutch_Belgium.1252
attached base packages:
[1] grid grDevices datasets splines graphics stats tcltk
[8] utils methods base
other attached packages:
[1] mgcv_1.6-2 ggplot2_0.8.8 proto_0.3-8 reshape_0.8.3
[5] plyr_1.0.3 survival_2.36-1
loaded via a namespace (and not attached):
[1] digest_0.4.2 lattice_0.19-9 Matrix_0.999375-43 nlme_3.1-96
[5] tools_2.11.1
> summary(test)
A B C
Min. : 1.00 Min. : 1.00 a:2723
1st Qu.: 13.00 1st Qu.:12.00 b:2723
Median : 19.00 Median :16.00 c:5446
Mean : 21.43 Mean :16.94
3rd Qu.: 27.00 3rd Qu.:21.00
Max. :130.00 Max. :50.00
------------------------------------------------------------------------
----
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie & Kwaliteitszorg
Gaverstraat 4
9500 Geraardsbergen
Belgium
Research Institute for Nature and Forest
team Biometrics & Quality Assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
Thierry....@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
Druk dit bericht a.u.b. niet onnodig af.
Please do not print this message unnecessarily.
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.
probably this is a bug in ggplot2:::predictdf.glm
the function should be
function (model, xseq, se, level)
{
pred <- stats::predict(model, newdata = data.frame(x = xseq),
se = se, type = "link")
if (se) {
std <- qnorm(level/2 + 0.5)
data.frame(x = xseq, y = model$family$linkinv(as.vector(pred$fit)),
ymin = model$family$linkinv(as.vector(pred$fit -
std * pred$se)), ymax =
model$family$linkinv(as.vector(pred$fit +
std * pred$se)), se = as.vector(pred$se))
}
else {
# the class of pred is array, so it shoud be coerce to vector
# data.frame(x = xseq, y = model$family$linkinv(pred))
data.frame(x = xseq, y = model$family$linkinv(as.vector(pred)))
}
}
the strange behavior is because StatSmooth choose "loess" as fitting
method when the number of cases < 1000 and without specifying the
method.
possibly this bug will be fixed in the next version of ggplot2.
> --
> You received this message because you are subscribed to the ggplot2 mailing list.
> Please provide a reproducible example: http://gist.github.com/270442
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2
>
I'm happy to make this change, but I would prefer to know why the
class of predict is an array - any ideas?
Hadley
--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/
I don't know the reason. But help of predict.gam says they return
array, and actually if argument type="term", the return value has to
be array. Anyway, the author of gam would know the reason.
I see I've done it everywhere else, so I obviously just missed that line.
Thanks for the fix and it's now included in the devel version.