log x and y bug?

14 views
Skip to first unread message

jc

unread,
Nov 24, 2009, 10:00:35 PM11/24/09
to ggplot2
Has anyone tried to generate graphs logging the X and Y axes using a
loess smooth? I can log the Y and plot just fine, but the X gives me
warnings like...

1: pseudoinverse used at 0.68857
2: neighborhood radius 0.69773
3: reciprocal condition number 5.2738e-16
4: There are other near singularities as well. 0.1644
5: In predLoess(object$y, object$x, newx, object$s, object
$weights, ... :
pseudoinverse used at 0.68857

The range of X values is 1:5.

The Y values run from about 200 to 1000

I can post my code but my dataset is very large.

p <- ggplot(s, aes(day, log(rt), linetype = endo))
p <- p + stat_smooth(method = 'loess')
p <- p + facet_wrap(~subj)
p <- p + coord_cartesian(ylim=c(5.6,6.5))
p

jc

unread,
Nov 25, 2009, 6:47:44 PM11/25/09
to ggplot2
It turns out that the subject of the post is misleading. If I log the
values, (1,2,3,4,5) first and just use the already transformed data
for my X-axes the problem persists. Perhaps it's just certain
floating point numbers? Ah, and there we have part of it, if I just
take day (the X-value) and divide it by 3 I don't get the problem.
And it's not the fact that I have a 0 in there (log(1)) because
subtracting 1 doesn't cause the problem either. So far, the only
special set of floating point values that won't work is the log of my
X values.

(I'd much rather use the axis scaling syntax but that also fails with
similar errors)

jc

unread,
Nov 25, 2009, 8:52:53 PM11/25/09
to ggplot2
OK, following up further if I take trunc(log(x)*100) that still has
the error. But lots of other mathematical transforms have no error.
It isn't floating point, it isn't anything but a log transform (any
base). It's a limited kind of error.

hadley wickham

unread,
Nov 25, 2009, 9:46:42 PM11/25/09
to jc, ggplot2
There's no way for us to help diagnose this error without a
reproducible example...

Hadley
> --
> You received this message because you are subscribed to the ggplot2 mailing list.
> To post to this group, send email to ggp...@googlegroups.com
> To unsubscribe from this group, send email to
> ggplot2+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/ggplot2



--
http://had.co.nz/

jc

unread,
Nov 26, 2009, 3:35:07 PM11/26/09
to ggplot2
I narrowed the data file down to a 100k or so zipped archive and
emailed you code and the data. I don't see a way to post the data
here. Anyone else who'd like to check it out I could also email.

hadley wickham

unread,
Dec 1, 2009, 5:43:09 PM12/1/09
to jc, ggplot2
It's a mystery:

# Manually fit the loess models so we can figure out exactly
# where the error is occuring
options(warn = 2)
smoothes <- dlply(s, c("subj", "endo"), function(df) {
loess(log(rt) ~ log(day), data = df)
}, .inform = T)
options(warn = 0)

# Problem is (at least) with subj BW & endo i
# So let's look at in more detail

prob <- subset(s, subj == "BW" & endo == "i")
qplot(day, rt, data = prob)
qplot(log(day), log(rt), data = prob)

qplot(log(day), log(rt), data = prob) + geom_smooth()

# I don't know what's the problem. The only think I
# can think of it's some numeric problem due to the discreteness
# of the x

qplot(jitter(log(day)), log(rt), data = prob) + geom_smooth()
Reply all
Reply to author
Forward
0 new messages