bar graph with no raw data

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

bar graph with no raw data

peter link
Hello -

I would like to make a bar graph (with error bars).  I have the mean,
standard deviation, and N for each of the 2 groups, but no raw data.

I am running v11.5.

Suggestions on how to accomplish this are much appreciated.

Thanks,

Peter Link
VA San Diego Healthcare System
Reply | Threaded
Open this post in threaded view
|

Re: bar graph with no raw data

Marta García-Granero
Hi Peter

You can adapt Valentim Alferes' code to get t-tests from summary data
to generate a dataset with the same means & SD ans your summary data,
and then use an IGRAPH:

http://www.spsstools.net/Syntax/T-Test/TTestEffectSizeNonoverlapAndPower.txt

** METHOD 2: Reproducing the SPSS T Test standard output from
** summary statistics in published articles.

* I have adapted it a bit to suit your needs *.

* Enter, row by row, N, Mean, and SD for Groups 1 and 2.
DATA LIST LIST /N(F8.0) M(F8.2) SD(F8.2) group(A8).
BEGIN DATA
17  7.46  1.98 group1
15  5.34  2.14 group2
END DATA.

LOOP ID=1 TO N.
- XSAVE OUTFILE=XOUT1.
END LOOP.
EXECUTE.
GET FILE=XOUT1.
COMPUTE DV=M.
COMPUTE K=SQR((SD**2*(N-1))/2).
IF (ID=1) DV=M+K.
IF ID=2) DV=M-K.
EXECUTE.

* The graph you need *.
IGRAPH /VIEWNAME='Gráfico de barras'
 /X1 = VAR(group) TYPE = CATEGORICAL
 /Y = VAR(DV) TYPE = SCALE
 /COORDINATE = VERTICAL
 /X1LENGTH=3.0
 /YLENGTH=3.0 /X2LENGTH=3.0
 /CHARTLOOK='NONE'
 /CATORDER VAR(group) (ASCENDING VALUES OMITEMPTY)
 /BAR(MEAN) KEY=ON SHAPE = RECTANGLE BASELINE = AUTO
 /ERRORBAR SD(1.0)  DIRECTION = UP CAPWIDTH (45) CAPSTYLE = T.
EXE.

PL> I would like to make a bar graph (with error bars).  I have the mean,
PL> standard deviation, and N for each of the 2 groups, but no raw data.

Regards,
Marta

PD: there are a lot of arguments against the use of such graphs to
sumarize continuous data, but you were not asking for them, but for
the graph only...
Reply | Threaded
Open this post in threaded view
|

Re: bar graph with no raw data

peter link
Hi Marta -

Thanks for the response.  I am trying to figure out how this code works.  I
am unfamiliar with the computed quantity K.  What is its meaning (if there
is any)?

I also realize there are some problems associated with doing something like
this.  However, I would like to make a bar braph obtained from the 'Expected
Marginal Means' in the GLM Univariate procedure.  I didn't see another way
of doing this.  I would be open to other ideas of how to approach this
problem, keeping in mind I'm running v11.5.

Thanks Again,

Peter

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of
Marta Garcma-Granero
Sent: Monday, October 30, 2006 12:28 PM
To: [hidden email]
Subject: Re: bar graph with no raw data


Hi Peter

You can adapt Valentim Alferes' code to get t-tests from summary data
to generate a dataset with the same means & SD ans your summary data,
and then use an IGRAPH:

http://www.spsstools.net/Syntax/T-Test/TTestEffectSizeNonoverlapAndPower.txt

** METHOD 2: Reproducing the SPSS T Test standard output from
** summary statistics in published articles.

* I have adapted it a bit to suit your needs *.

* Enter, row by row, N, Mean, and SD for Groups 1 and 2.
DATA LIST LIST /N(F8.0) M(F8.2) SD(F8.2) group(A8).
BEGIN DATA
17  7.46  1.98 group1
15  5.34  2.14 group2
END DATA.

LOOP ID=1 TO N.
- XSAVE OUTFILE=XOUT1.
END LOOP.
EXECUTE.
GET FILE=XOUT1.
COMPUTE DV=M.
COMPUTE K=SQR((SD**2*(N-1))/2).
IF (ID=1) DV=M+K.
IF ID=2) DV=M-K.
EXECUTE.

* The graph you need *.
IGRAPH /VIEWNAME='Grafico de barras'
 /X1 = VAR(group) TYPE = CATEGORICAL
 /Y = VAR(DV) TYPE = SCALE
 /COORDINATE = VERTICAL
 /X1LENGTH=3.0
 /YLENGTH=3.0 /X2LENGTH=3.0
 /CHARTLOOK='NONE'
 /CATORDER VAR(group) (ASCENDING VALUES OMITEMPTY)
 /BAR(MEAN) KEY=ON SHAPE = RECTANGLE BASELINE = AUTO
 /ERRORBAR SD(1.0)  DIRECTION = UP CAPWIDTH (45) CAPSTYLE = T.
EXE.

PL> I would like to make a bar graph (with error bars).  I have the mean,
PL> standard deviation, and N for each of the 2 groups, but no raw data.

Regards,
Marta

PD: there are a lot of arguments against the use of such graphs to
sumarize continuous data, but you were not asking for them, but for
the graph only...
Reply | Threaded
Open this post in threaded view
|

Re: bar graph with no raw data

Marta García-Granero
Hi Peter

pl> Thanks for the response. I am trying to figure out how this code
pl> works. I am unfamiliar with the computed quantity K.  What is its
pl> meaning (if there is any)?

You should ask Valentim Alferes... Anyway, I think it is a method to
obtain a dataset with the same mean and standard deviation as your
original sample (from which you only have the summary data). Ignore
the steps between the LOOP and the second IF commands. Their purpose
is get samples with the same statistics your original data had, in
order to pass them to the graph command.

pl> I also realize there are some problems associated with doing
pl> something like this. However, I would like to make a bar braph
pl> obtained from the 'Expected Marginal Means' in the GLM Univariate
pl> procedure.

Where did you get the SD from then? The Marginal Means table gives you
the SEM (computed from the error MS of the ANOVA table) and the 95%CI
for both means. I suppose you have sound reasons to use the Expected
Marginal means instead of the original means (did you have to adjust
for one or more covariates?).

pl> I didn't see another way of doing this.  I would be open to other
pl> ideas of how to approach this problem, keeping in mind I'm running
pl> v11.5.

There is a better approach: an error bar graph showing both means with
their 95% confidence limits. It also has the advantage of being
created from the summary data, without having to expand them into a
false dataset. See the following example:

* Sample dataset (replace by your own data) *.
DATA LIST FREE/ group wgtgain (2 F5).
BEGIN DATA
1 123 1 132 1 149 1 151 1 175 1 179 1 187
1 200 1 206 1 206 1 218 1 219 1 234 1 248
2 142 2 176 2 195 2 199 2 211 2 214 2 216
2 236 2 249 2 253 2 262 2 302 2 311 2 337
END DATA.
VAR LABEL group 'Type of diet' / wgtgain 'Weight gain (pounds)'.
VALUE LABEL group 1 'Control' 2 'A Vit.'.
VAR LEVEL group (NOMINAL).

* ANOVA model *.
GLM wgtgain BY group
  /EMMEANS = TABLES(group)
  /DESIGN = group .

* You will get a table like this one:
*                    Std.   95% Confidence Interval
*           Mean    Error  Lower Bound  Upper Bound
* Control  187.643  12.533    161.880     213.406
* A Vit.   235.929  12.533    210.166     261.692

* Since you don't have SPSS 12 or newer (OMS command), you'll have
  to create the dataset from scratch *.

DATA LIST LIST/group(A8) mean lower upper (3 F8.3).
BEGIN DATA
Control 187.643 161.880 213.406
A-Vit.  235.929 210.166 261.692
END DATA.

* Now the graph *.
GRAPH /HILO(SIMPLE)=VALUE( upper lower mean ) BY group .



--
Regards,
Dr. Marta García-Granero,PhD           mailto:[hidden email]
Statistician

---
"It is unwise to use a statistical procedure whose use one does
not understand. SPSS syntax guide cannot supply this knowledge, and it
is certainly no substitute for the basic understanding of statistics
and statistical thinking that is essential for the wise choice of
methods and the correct interpretation of their results".

(Adapted from WinPepi manual - I'm sure Joe Abrahmson will not mind)
Reply | Threaded
Open this post in threaded view
|

Re: bar graph with no raw data

peter link
Thanks Marta.  I appreciate the insight.

Peter Link
VA San Diego Healthcare System

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of
Marta Garcma-Granero
Sent: Tuesday, October 31, 2006 3:04 AM
To: [hidden email]
Subject: Re: bar graph with no raw data


Hi Peter

pl> Thanks for the response. I am trying to figure out how this code
pl> works. I am unfamiliar with the computed quantity K.  What is its
pl> meaning (if there is any)?

You should ask Valentim Alferes... Anyway, I think it is a method to
obtain a dataset with the same mean and standard deviation as your
original sample (from which you only have the summary data). Ignore
the steps between the LOOP and the second IF commands. Their purpose
is get samples with the same statistics your original data had, in
order to pass them to the graph command.

pl> I also realize there are some problems associated with doing
pl> something like this. However, I would like to make a bar braph
pl> obtained from the 'Expected Marginal Means' in the GLM Univariate
pl> procedure.

Where did you get the SD from then? The Marginal Means table gives you
the SEM (computed from the error MS of the ANOVA table) and the 95%CI
for both means. I suppose you have sound reasons to use the Expected
Marginal means instead of the original means (did you have to adjust
for one or more covariates?).

pl> I didn't see another way of doing this.  I would be open to other
pl> ideas of how to approach this problem, keeping in mind I'm running
pl> v11.5.

There is a better approach: an error bar graph showing both means with
their 95% confidence limits. It also has the advantage of being
created from the summary data, without having to expand them into a
false dataset. See the following example:

* Sample dataset (replace by your own data) *.
DATA LIST FREE/ group wgtgain (2 F5).
BEGIN DATA
1 123 1 132 1 149 1 151 1 175 1 179 1 187
1 200 1 206 1 206 1 218 1 219 1 234 1 248
2 142 2 176 2 195 2 199 2 211 2 214 2 216
2 236 2 249 2 253 2 262 2 302 2 311 2 337
END DATA.
VAR LABEL group 'Type of diet' / wgtgain 'Weight gain (pounds)'.
VALUE LABEL group 1 'Control' 2 'A Vit.'.
VAR LEVEL group (NOMINAL).

* ANOVA model *.
GLM wgtgain BY group
  /EMMEANS = TABLES(group)
  /DESIGN = group .

* You will get a table like this one:
*                    Std.   95% Confidence Interval
*           Mean    Error  Lower Bound  Upper Bound
* Control  187.643  12.533    161.880     213.406
* A Vit.   235.929  12.533    210.166     261.692

* Since you don't have SPSS 12 or newer (OMS command), you'll have
  to create the dataset from scratch *.

DATA LIST LIST/group(A8) mean lower upper (3 F8.3).
BEGIN DATA
Control 187.643 161.880 213.406
A-Vit.  235.929 210.166 261.692
END DATA.

* Now the graph *.
GRAPH /HILO(SIMPLE)=VALUE( upper lower mean ) BY group .



--
Regards,
Dr. Marta Garcma-Granero,PhD           mailto:[hidden email]
Statistician

---
"It is unwise to use a statistical procedure whose use one does
not understand. SPSS syntax guide cannot supply this knowledge, and it
is certainly no substitute for the basic understanding of statistics
and statistical thinking that is essential for the wise choice of
methods and the correct interpretation of their results".

(Adapted from WinPepi manual - I'm sure Joe Abrahmson will not mind)