bar chart of estimated marginal means

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

bar chart of estimated marginal means

Wells, Christine

Greetings,

 

I have run an ANOVA using the unianova command, and I used the emmeans subcommand to get the estimated marginal means and standard errors for both of my categorical predictors.  I used OMS to output the estimated marginal means and standard errors to an SPSS data set, and now I would like to make a bar chart of these estimated marginal means.  I would also like to have error bars on this graph. 

 

I am having difficulty using ggraph and GPL syntax to do this.  (I don’t think that this can be done via the point-and-click interface, and I prefer to use syntax anyhow.)  I am using SPSS version 18. 

 

Any assistance with this task would be greatly appreciated!

 

My dataset looks like this:

 

Subtype_                                Label_                       Var1                  Mean  Std.Error  LowerBound  UpperBound

 

Estimated Marginal Means     1. type of school         public              51.318    .695       49.947           52.689

Estimated Marginal Means     1. type of school         private             52.305    1.619     49.112           55.498

Estimated Marginal Means     2. type of program      general             51.695    1.434     48.867           54.524

Estimated Marginal Means     2. type of program      academic         56.525    .964       54.625           58.425

Estimated Marginal Means     2. type of program      vocation          47.214    1.455     44.345           50.083

 

Best regards,

Christine Wells, Ph.D.
Statistical Consulting Group
UCLA Academic Technology Services
http://www.ats.ucla.edu/stat/

 

Reply | Threaded
Open this post in threaded view
|

Re: bar chart of estimated marginal means

Albert-Jan Roskam
Hi,

If you run the code below within a Begin-End program R block, you get this: http://nl.tinypic.com/r/28qt4qs/5

library(ggplot2)

df <- spssdata.GetDataFromSPSS()
attach(df)
limits <- aes(ymax=UpperBound, ymin=LowerBound)
p <- ggplot(df, aes(x=Group, y=Mean, fill=Group), stat="identity", position="dodge") + geom_bar()
d <- position_dodge(width=2)
p <- p + geom_bar(position=d) + geom_errorbar(limits, position=d, size=1, width=0.25)
p + opts(title = "A neat bar chart\n")
ggsave("c:/temp/barchart.png", scale=2)

Cheers!!
Albert-Jan

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a fresh water system, and public health, what have the Romans ever done for us?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

--- On Tue, 4/13/10, Wells, Christine <[hidden email]> wrote:

From: Wells, Christine <[hidden email]>
Subject: [SPSSX-L] bar chart of estimated marginal means
To: [hidden email]
Date: Tuesday, April 13, 2010, 6:54 PM

Greetings,

 

I have run an ANOVA using the unianova command, and I used the emmeans subcommand to get the estimated marginal means and standard errors for both of my categorical predictors.  I used OMS to output the estimated marginal means and standard errors to an SPSS data set, and now I would like to make a bar chart of these estimated marginal means.  I would also like to have error bars on this graph. 

 

I am having difficulty using ggraph and GPL syntax to do this.  (I don’t think that this can be done via the point-and-click interface, and I prefer to use syntax anyhow.)  I am using SPSS version 18. 

 

Any assistance with this task would be greatly appreciated!

 

My dataset looks like this:

 

Subtype_                                Label_                       Var1                  Mean  Std.Error  LowerBound  UpperBound

 

Estimated Marginal Means     1. type of school         public              51.318    .695       49.947           52.689

Estimated Marginal Means     1. type of school         private             52.305    1.619     49.112           55.498

Estimated Marginal Means     2. type of program      general             51.695    1.434     48.867           54.524

Estimated Marginal Means     2. type of program      academic         56.525    .964       54.625           58.425

Estimated Marginal Means     2. type of program      vocation          47.214    1.455     44.345           50.083

 

Best regards,

Christine Wells, Ph.D.
Statistical Consulting Group
UCLA Academic Technology Services
http://www.ats.ucla.edu/stat/

 


Reply | Threaded
Open this post in threaded view
|

Re: bar chart of estimated marginal means, again!!!

liang
In reply to this post by Wells, Christine
Hi All,

I came across the same problem. Is there a SPSS syntax that can work for this?
Any assistance will be appreciated!

Thanks
-Liang