Figures with nested data & multilevel modeling

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

Figures with nested data & multilevel modeling

Oliver
Hi everyone,

I'm interested in plotting the association between a continous Level 1
variable (PCS) and continous outcome (Diary_OCS). I've found the syntax
below online to generate the figure/scatterplot and it works well. However,
I would like to make sure that the syntax is adequate considering the nested
structure of my dataset. More specifically, I'd like to make sure that the
slope represents the "fixed" effect (i.e., the average slope of all
within-person slopes).

Thanks in advance for your support.
Oliver

GGRAPH
/GRAPHDATASET NAME="GraphDataset" VARIABLES= Lev1_PCS Lev1_Diary_OCS id
/GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
SOURCE: s=userSource(id( "GraphDataset" ) )
DATA: Lev1_PCS=col( source(s), name( "Lev1_PCS" ) )
DATA: Lev1_Diary_OCS=col( source(s), name( "Lev1_Diary_OCS" ) )
DATA: id = col(source(s), name("ID"), unit.category())
ELEMENT: point( position(Lev1_PCS * Lev1_Diary_OCS))
ELEMENT: line(position(smooth.linear(Lev1_PCS * Lev1_Diary_OCS)), shape(id))
END GPL.

<http://spssx-discussion.1045642.n5.nabble.com/file/t340718/Fig1.jpg>



--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Figures with nested data & multilevel modeling

Andy W
One simple way to show that would be to group de-mean the data (for both the
X and Y variables), and then plot those de-meaned values. So something like:

******************************************.
AGGREGATE OUTFILE=* MODE=ADDVARIABLES
  /BREAK GroupIndicator
  /MeanPCS = MEAN(PCS)
  /MeanDiary = MEAN(Diary_OCS).

COMPUTE DiffPCS = PCS - MeanPCS.
COMPUTE DiffDiary = Diary_OCS - MeanDiary.
******************************************.

And then in the scatterplot replace PCS with DiffPCS and Diary_OCS with
DiffDiary. Then the OLS line in the scatterplot will show the regression
slope when controlling for the fixed effects.

See also these blog posts of mine for other ideas about plotting multi-level
data:

 -
https://andrewpwheeler.wordpress.com/2014/07/13/smoothed-regression-plots-for-multi-level-data/
 -
https://andrewpwheeler.wordpress.com/2014/03/04/visualizing-multi-level-data-using-ellipses/




-----
Andy W
[hidden email]
http://andrewpwheeler.wordpress.com/
--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Andy W
apwheele@gmail.com
http://andrewpwheeler.wordpress.com/
Reply | Threaded
Open this post in threaded view
|

Re: Figures with nested data & multilevel modeling

Oliver
Hi Andy,

Thanks for your reply. It is very much appreciated.

Perhaps I was not clear in my previous post, but my goal is to create a
figure/regression slope that does represent the fixed effect (i.e., the
average slope of all within-person slopes). In that case, the syntax from my
previous post would make sense, right ?

Thanks again,
Oliver



--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Figures with nested data & multilevel modeling

Bruce Weaver
Administrator
Oliver, it might help if you showed the syntax for the model that generates
the fitted values.  It sounds like it might be a random intercept model,
possibly via MIXED.

HTH.


Oliver wrote

> Hi Andy,
>
> Thanks for your reply. It is very much appreciated.
>
> Perhaps I was not clear in my previous post, but my goal is to create a
> figure/regression slope that does represent the fixed effect (i.e., the
> average slope of all within-person slopes). In that case, the syntax from
> my
> previous post would make sense, right ?
>
> Thanks again,
> Oliver
>
>
>
> --
> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (not to SPSSX-L), with no body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send the command
> INFO REFCARD





-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.

--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.
Reply | Threaded
Open this post in threaded view
|

Re: Figures with nested data & multilevel modeling

Andy W
In reply to this post by Oliver
People use the term fixed effects differently (not your fault), so let me try
to be clear what I am suggesting. So the graph you show in your original
code would be the simple linear regression of:

eq.1: Diary = Intercept + B1*PCS + e

So the slope in your original graph is B1. Pretend you only have two groups,
what I believe you want to plot is B1f below:

eq.2: Diary = B1f*PCS + B2*(Group = 1) + B3*(Group = 2) + e

B1 (what you show in your original plot) will not necessarily equal B1f. B1f
is the least squares dummy value way to control for the "fixed effects"
(what I call "fixed effects" are B2 and B3 in the above equation, not B1f).
Another way to accomplish this same estimate though is:

eq.3: Diary_j - Mean[Diary Group j] = B1f*(PCS_j - Mean[PCS Group j]) + e

Equation 2 and 3 will produce the same estimate of B1f, and so using the
group mean centered approach is an easy way to show the slope of the effect
controlling for between group means. You can't simply superimpose the slope
of B1f on the original variables PCS and Diary, because it won't have any
necessary relationship to the original point cloud. Example below:

**************************************************************************************************.
*Simulate multi-level data.
SET SEED 10.
INPUT PROGRAM.
LOOP #G = 1 TO 5.
  LOOP #i = 1 TO 20.
    COMPUTE Group = #G.
        COMPUTE PCS = 10 + RV.NORMAL(#G*5,1).
        END CASE.
  END LOOP.
END LOOP.
END FILE.
END INPUT PROGRAM.
DATASET NAME Sim.

COMPUTE #Within = PCS - (10 + Group*5).
*Between is positive, within is negative.
COMPUTE Diary = 5 + 2*Group - 1*#Within + RV.NORMAL(0,1).
FORMATS Diary PCS (F2.0).
EXECUTE.

******************************************************.
*Overall slope and scatterplot.
REGRESSION
  /DEPENDENT Diary
  /METHOD=ENTER PCS.

GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=PCS Diary
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  SOURCE: s=userSource(id("graphdataset"))
  DATA: PCS=col(source(s), name("PCS"))
  DATA: Diary=col(source(s), name("Diary"))
  GUIDE: axis(dim(1), label("PCS"))
  GUIDE: axis(dim(2), label("Diary"))
  ELEMENT: line(position(smooth.linear(PCS*Diary)))
  ELEMENT: point(position(PCS*Diary))
END GPL.
******************************************************.


******************************************************.
*Slope when controlling for the fixed effects.

*Controlling for group fixed effects.
*Least square dummy value approach.
VECTOR G(5,F1.0).
COMPUTE G(Group) = 1.
RECODE G1 TO G5 (SYSMIS = 0).
EXECUTE.  

REGRESSION
  /NOORIGIN
  /DEPENDENT Diary
  /METHOD=ENTER PCS G1 TO G5.

*Using the demeaned variables.
AGGREGATE OUTFILE=* MODE=ADDVARIABLES
  /BREAK Group
  /MeanPCS = MEAN(PCS)
  /MeanDiary = MEAN(Diary).
 
COMPUTE PCS_Diff = PCS - MeanPCS.
COMPUTE Diary_Diff = Diary - MeanDiary.
FORMATS Diary_Diff PCS_Diff (F2.0).

*Exact same slope as with the dummy variables, standard error is not correct
though.
REGRESSION
  /DEPENDENT Diary_Diff
  /METHOD=ENTER PCS_Diff.

*Now making a scatterplot of the group de-meaned variables to show this.
GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=PCS_Diff Diary_Diff
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  SOURCE: s=userSource(id("graphdataset"))
  DATA: PCS=col(source(s), name("PCS_Diff"))
  DATA: Diary=col(source(s), name("Diary_Diff"))
  GUIDE: axis(dim(1), label("PCS Group Mean Differenced"))
  GUIDE: axis(dim(2), label("Diary Group Mean Differenced"))
  ELEMENT: line(position(smooth.linear(PCS*Diary)))
  ELEMENT: point(position(PCS*Diary))
END GPL.
******************************************************.
**************************************************************************************************.

So here is the first graph, the way I constructed the data you can clearly
tell the difference between groups.

<http://spssx-discussion.1045642.n5.nabble.com/file/t329824/Multilev.png>

And here is the second graph of the group de-meaned variables, which more
clearly shows the negative linear relationship after taking into account the
group intercepts.

<http://spssx-discussion.1045642.n5.nabble.com/file/t329824/Multilev1.png>

You can do other plots to show both the group intercepts and slopes at the
same time, which I linked to in my prior answer.





-----
Andy W
[hidden email]
http://andrewpwheeler.wordpress.com/
--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Andy W
apwheele@gmail.com
http://andrewpwheeler.wordpress.com/
Reply | Threaded
Open this post in threaded view
|

Re: Figures with nested data & multilevel modeling

Oliver
In reply to this post by Bruce Weaver
Bruce & Andy: Thanks for your replies.

Bruce: Below you'll find the syntax used to analyse the association between
the two Level 1 variables. Essentially, what I'm trying to do is to come up
with a Figure/slope that depicts this association.

MIXED Lev1_Diary_OCS WITH Lev1_PCS
/PRINT=SOLUTION TESTCOV
/METHOD=ML
/FIXED= Lev1_PCS
/RANDOM INTERCEPT | SUBJECT(ID) COVTYPE (ID)
/REPEATED=Wave | SUBJECT(ID) COVTYPE(AR1) .
 




--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Figures with nested data & multilevel modeling

Robert L
Last time I tried to get graphs - basically predictions from MIXED - I didn't succeed at first. But the same analyses set up in GENLINMIXED where models can be saved as xml files and subsequently used in the Scoring Wizard (under Utilities) did the trick. Could that work for you as well?

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Oliver
Sent: Tuesday, May 15, 2018 5:54 AM
To: [hidden email]
Subject: Re: Figures with nested data & multilevel modeling

Bruce & Andy: Thanks for your replies.

Bruce: Below you'll find the syntax used to analyse the association between
the two Level 1 variables. Essentially, what I'm trying to do is to come up
with a Figure/slope that depicts this association.

MIXED Lev1_Diary_OCS WITH Lev1_PCS
/PRINT=SOLUTION TESTCOV
/METHOD=ML
/FIXED= Lev1_PCS
/RANDOM INTERCEPT | SUBJECT(ID) COVTYPE (ID)
/REPEATED=Wave | SUBJECT(ID) COVTYPE(AR1) .
 




--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Robert Lundqvist
Reply | Threaded
Open this post in threaded view
|

Re: Figures with nested data & multilevel modeling

Andy W
In reply to this post by Oliver
With random intercepts there is no simple analog to the group de-meaned
charted I suggested. So I might just say get the predicted values and
superimpose them on the chart, making either different colors for each group
or putting the groups into a set of small multiples.

**************************************************************************************************.
*Simulate multi-level data.
SET SEED 10.
INPUT PROGRAM.
LOOP #G = 1 TO 5.
  LOOP #i = 1 TO 20.
    COMPUTE Group = #G.
    COMPUTE PCS = 10 + RV.NORMAL(#G*5,1).
    COMPUTE Wave = #i.
    END CASE.
  END LOOP.
END LOOP.
END FILE.
END INPUT PROGRAM.
DATASET NAME Sim.

COMPUTE #Within = PCS - (10 + Group*5).
*Between is positive, within is negative.
COMPUTE Diary = 5 + 2*Group - 1*#Within + RV.NORMAL(0,1).
FORMATS Diary PCS (F2.0).
RENAME VARIABLES (Group = ID)(Diary = Lev1_Diary_OCS)(PCS = Lev1_PCS).
EXECUTE.

MIXED Lev1_Diary_OCS WITH Lev1_PCS
/PRINT=SOLUTION TESTCOV
/METHOD=ML
/FIXED= Lev1_PCS
/RANDOM INTERCEPT | SUBJECT(ID) COVTYPE (ID)
/REPEATED=Wave | SUBJECT(ID) COVTYPE(AR1)
/SAVE PRED(PredVal).

*If a small number of IDs, can superimpose onto the same plot.
FORMATS ID PredVal (F2.0).
GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=Lev1_PCS Lev1_Diary_OCS ID
PredVal
  /GRAPHSPEC SOURCE=INLINE
  /FRAME INNER=YES.
BEGIN GPL
  SOURCE: s=userSource(id("graphdataset"))
  DATA: Lev1_PCS=col(source(s), name("Lev1_PCS"))
  DATA: Lev1_Diary_OCS=col(source(s), name("Lev1_Diary_OCS"))
  DATA: ID=col(source(s), name("ID"), unit.category())
  DATA: PredVal=col(source(s), name("PredVal"))
  GUIDE: axis(dim(1), label("Lev1_PCS"))
  GUIDE: axis(dim(2), label("Lev1_Diary_OCS"))
  GUIDE: legend(aesthetic(aesthetic.color.interior), label("ID"))
  ELEMENT: line(position(Lev1_PCS*PredVal), color(ID), size(size."1"))
  ELEMENT: point(position(Lev1_PCS*Lev1_Diary_OCS), color.interior(ID))
END GPL.

*For a larger number would suggest small multiples.
GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=Lev1_PCS Lev1_Diary_OCS ID
PredVal
  /GRAPHSPEC SOURCE=INLINE
  /FRAME INNER=YES.
BEGIN GPL
  PAGE: begin(scale(1000px,700px))
  SOURCE: s=userSource(id("graphdataset"))
  DATA: Lev1_PCS=col(source(s), name("Lev1_PCS"))
  DATA: Lev1_Diary_OCS=col(source(s), name("Lev1_Diary_OCS"))
  DATA: ID=col(source(s), name("ID"), unit.category())
  DATA: PredVal=col(source(s), name("PredVal"))
  COORD: rect(dim(1,2), wrap())
  GUIDE: axis(dim(1), label("Lev1_PCS"))
  GUIDE: axis(dim(2), label("Lev1_Diary_OCS"))
  GUIDE: axis(dim(3), opposite())
  GUIDE: legend(aesthetic(aesthetic.color.interior), label("ID"))
  ELEMENT: line(position(Lev1_PCS*PredVal*ID), size(size."1"))
  ELEMENT: point(position(Lev1_PCS*Lev1_Diary_OCS*ID), size(size."3"))
  PAGE: end()
END GPL.
**************************************************************************************************.




-----
Andy W
[hidden email]
http://andrewpwheeler.wordpress.com/
--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Andy W
apwheele@gmail.com
http://andrewpwheeler.wordpress.com/
Reply | Threaded
Open this post in threaded view
|

Re: Figures with nested data & multilevel modeling

Oliver
Hi Andy,

Thanks again for trying to come up with solution. It seems like generating a
Figure displaying a Level 1 association in SPSS is not straightforward. I've
tried to come up with the same Figure as the ones you generated, but I was
not able. This is probably because of my limitations in terms of knowledge
when it gets to SPSS syntax. This is also possibly due to the fact that your
data were "simulated" and not based on my actual data.

Attached you'll find the dataset with the Level 1 independent variable
(Lev1_PCS), the outcome (Lev1_OCS), and the clustering (ID). Do you think it
would be possible to generate the Figure ? If it works, I could then try to
learn (and re-use) the syntax that is needed to generate the Figure.

Thanks again, Andy.
Oliver Dataset;_PCS_&_OCS.sav
<http://spssx-discussion.1045642.n5.nabble.com/file/t340718/Dataset%3B_PCS_%26_OCS.sav>  



--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Figures with nested data & multilevel modeling

Andy W
You changed your variable names from the initial post. If you do:

RENAME VARIABLES (Lev1_OCS = Lev1_Diary_OCS)(Wave_Day = Wave).

My code will work. Here are a few examples using your dataset (note you need
to change the FILE HANDLE location to your local machine). For this dataset
constraining the slopes to be equal does not seem too crazy, but allowing
the slopes to vary as well seems reasonable.

**************************************************************************************************.
DATASET CLOSE ALL.
OUTPUT CLOSE ALL.

FILE HANDLE data /NAME = "C:\Users\axw161530\Desktop\SPSS".
GET FILE = "data\Dataset;_PCS_&_OCS.sav".
DATASET NAME Nab.

RENAME VARIABLES (Lev1_OCS = Lev1_Diary_OCS)(Wave_Day = Wave).
EXECUTE.

MIXED Lev1_Diary_OCS WITH Lev1_PCS
/PRINT=SOLUTION TESTCOV
/METHOD=ML
/FIXED= Lev1_PCS
/RANDOM INTERCEPT | SUBJECT(ID) COVTYPE (ID)
/REPEATED=Wave | SUBJECT(ID) COVTYPE(AR1)
/SAVE PRED(PredVal).

*If a small number of IDs, can superimpose onto the same plot.
FORMATS ID PredVal (F2.0).
*For a larger number would suggest small multiples.
GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=Lev1_PCS Lev1_Diary_OCS ID
PredVal
  /GRAPHSPEC SOURCE=INLINE
  /FRAME INNER=YES.
BEGIN GPL
  PAGE: begin(scale(1000px,1000px))
  SOURCE: s=userSource(id("graphdataset"))
  DATA: Lev1_PCS=col(source(s), name("Lev1_PCS"))
  DATA: Lev1_Diary_OCS=col(source(s), name("Lev1_Diary_OCS"))
  DATA: ID=col(source(s), name("ID"), unit.category())
  DATA: PredVal=col(source(s), name("PredVal"))
  COORD: rect(dim(1,2), wrap())
  GUIDE: axis(dim(1), label("Lev1_PCS"))
  GUIDE: axis(dim(2), label("Lev1_Diary_OCS"))
  GUIDE: axis(dim(3), opposite())
  GUIDE: legend(aesthetic(aesthetic.color.interior), label("ID"))
  ELEMENT: line(position(Lev1_PCS*PredVal*ID), size(size."1"))
  ELEMENT: point(position(Lev1_PCS*Lev1_Diary_OCS*ID), size(size."3"))
  PAGE: end()
END GPL.

*Now lets allows both random intercept and random slope!.
MIXED Lev1_Diary_OCS WITH Lev1_PCS
/PRINT=SOLUTION TESTCOV
/METHOD=ML
/FIXED= Lev1_PCS
/RANDOM INTERCEPT Lev1_PCS | SUBJECT(ID) COVTYPE (ID)
/REPEATED=Wave | SUBJECT(ID) COVTYPE(AR1)
/SAVE PRED(PredRandSlope).

FORMATS PredRandSlope (F3.0).
GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=Lev1_PCS Lev1_Diary_OCS ID
PredRandSlope
  /GRAPHSPEC SOURCE=INLINE
  /FRAME INNER=YES.
BEGIN GPL
  PAGE: begin(scale(1000px,1000px))
  SOURCE: s=userSource(id("graphdataset"))
  DATA: Lev1_PCS=col(source(s), name("Lev1_PCS"))
  DATA: Lev1_Diary_OCS=col(source(s), name("Lev1_Diary_OCS"))
  DATA: ID=col(source(s), name("ID"), unit.category())
  DATA: PredRandSlope=col(source(s), name("PredRandSlope"))
  COORD: rect(dim(1,2), wrap())
  GUIDE: axis(dim(1), label("Lev1_PCS"))
  GUIDE: axis(dim(2), label("Lev1_Diary_OCS"))
  GUIDE: axis(dim(3), opposite())
  GUIDE: legend(aesthetic(aesthetic.color.interior), label("ID"))
  ELEMENT: line(position(Lev1_PCS*PredRandSlope*ID), size(size."1"))
  ELEMENT: point(position(Lev1_PCS*Lev1_Diary_OCS*ID), size(size."3"))
  PAGE: end()
END GPL.
**************************************************************************************************.

Here is a graph of the random intercepts plus slopes (the second graph).

<http://spssx-discussion.1045642.n5.nabble.com/file/t329824/RandomSlopes.png>



-----
Andy W
[hidden email]
http://andrewpwheeler.wordpress.com/
--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Andy W
apwheele@gmail.com
http://andrewpwheeler.wordpress.com/
Reply | Threaded
Open this post in threaded view
|

Re: Figures with nested data & multilevel modeling

Oliver
In reply to this post by Oliver
Hi everyone,

I'd like to plot the association between two continous Level 1 variables.
Attached is the dataset with the Level 1 independent variable (Lev1_PCS),
the outcome (Lev1_OCS), and the clustering (ID). It would be very much
appreciated if someone could provide me with some syntax in order to
generate a figure depicting the association based on the attached dataset.
Thanks in advance !
Oliver
Dataset.sav
<http://spssx-discussion.1045642.n5.nabble.com/file/t340718/Dataset.sav>  



--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Figures with nested data & multilevel modeling

Oliver
In reply to this post by Andy W
Hi Andy,

For some reason I had not seen your syntax based on my actual data/variable
names. Thank you so much for coming up with this syntax. I'm very grateful
for your support.

As you can see attached, I did get an error message from SPSS when I tried
to generate the plot/figure. SPSS says "unrecognizable setting FRAME". Do
you know what that means and/or where I made a mistake with the syntax ?
I've attached the dataset, syntax, & output with the error message.

Thanks again, Andy.
O. Dataset;_PCS_&_OCS.sav
<http://spssx-discussion.1045642.n5.nabble.com/file/t340718/Dataset%3B_PCS_%26_OCS.sav>  
Syntax.sps
<http://spssx-discussion.1045642.n5.nabble.com/file/t340718/Syntax.sps>  
Output.spv
<http://spssx-discussion.1045642.n5.nabble.com/file/t340718/Output.spv>  



--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Figures with nested data & multilevel modeling

Oliver
Andy,

I attached the wrong dataset.  My apologies for the confusion.

The proper dataset is attached. Dataset;_PCS_&_OCS_1.sav
<http://spssx-discussion.1045642.n5.nabble.com/file/t340718/Dataset%3B_PCS_%26_OCS_1.sav>  

Best,
O.



--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Figures with nested data & multilevel modeling

Andy W
In reply to this post by Oliver
Just delete the line

/FRAME INNER=YES.

and replace with just

.



-----
Andy W
[hidden email]
http://andrewpwheeler.wordpress.com/
--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Andy W
apwheele@gmail.com
http://andrewpwheeler.wordpress.com/
Reply | Threaded
Open this post in threaded view
|

Re: Figures with nested data & multilevel modeling

Oliver
Hi Andy,

Thanks for getting back to me. Your suggestion works, and I'm able to
generate Level 1 plots separately for each ID using the syntax you proposed.

Is there a way to generate a single plot for the entire sample ? Ideally,
I'd like to plot the "average" within-person slope, similar to what you did
when you simulated the data (see attached).

Is there a way to do this ? In most papers, we don't have enough room to
present separate figures for each ID, so a single one would be ideal.

Below is what I mean by a single plot:

Untitled.png
<http://spssx-discussion.1045642.n5.nabble.com/file/t340718/Untitled.png>  

Thanks again Andy.
O.



--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD