stat_smooth with method = "gamlss"

461 views
Skip to first unread message

Daniel Nvule

unread,
Jun 16, 2013, 6:47:35 PM6/16/13
to ggp...@googlegroups.com
Dear forumists,

My apologies if this has been addressed before. 

The following will illustrate the problem with pseudo data. I am using R 3.0.1.

library(ggplot2)
library(gamlss)
 r1=rnorm(100)
 r2=rnorm(100)
 d=data.frame(r1,r2)
 

p=ggplot(d,aes(r1,r2))+geom_point()+stat_smooth(method="gamlss", formula=y~x,family=NO,se=F)

print(p)
GAMLSS-RS iteration 1: Global Deviance = 274.2988 
GAMLSS-RS iteration 2: Global Deviance = 274.2988 
Error in data.frame(data, source = namelist) : 
  arguments imply differing number of rows: 80, 81


The gamlss package is fine in this case as this will show

mod1 = gamlss(formula=r2~r1,family=NO,data=d)

GAMLSS-RS iteration 1: Global Deviance = 274.2988 
GAMLSS-RS iteration 2: Global Deviance = 274.2988 

summary(mod1)  yields the model estimate as expected

What do I need to do to get stat_smooth to work with the gamlss method?

Daniel

Ista Zahn

unread,
Jun 17, 2013, 4:05:16 PM6/17/13
to Daniel Nvule, ggplot2
Hi Daniel,

The easy way is


d$predicted <- predict(gamlss(formula=r2~r1,family=NO,data=d))
ggplot(d,aes(r1,r2))+geom_point()+geom_smooth(aes(y=predicted), stat="identity")

Best,
Ista



--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
 
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2
 
---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages