Creating a provisional model

12 views
Skip to first unread message

Dave Bell

unread,
Oct 22, 2019, 5:56:02 AM10/22/19
to lavaan
Good morning,

Is it possible to construct a SEM diagram on Lavaan before having your data? I am writing my thesis at the moment, and would like to construct a diagram to show my intentions. A picture of the diagram is attached, and what I believe to be the correct syntax is shown below.

Any advice much appreciated!

Dave

> model <- '

  # latent variables

Workload =~ Workload 1 + Workload 2 + Workload 3

Professional_Recognition =~ Recognition 1 + Recognition 2 + Recognition 3 + Recognition 4 + Recognition 5 + Recognition 6

Teacher Stress =~ Workload + Professional_Recognition

Student_Engagement =~ Student Engagement 1 + Student Engagement 2 + Student Engagement 3 + Student Engagement 4

Instructional_Strategies =~ Instructional Strategies 1 + Instructional Strategies 2 + Instructional Strategies 3 + Instructional Strategies 4

Teacher_Efficacy =~ Student_Engagement + Instructional_Strategies

Didactical_Pedagogical =~ Didactical Pedagogical 1 + Didactical Pedagogical 2 + Didactical Pedagogical 3 + Didactical Pedagogical 4 + Didactical Pedagogical 5 + Didactical Pedagogical 6 + Didactical Pedagogical 7

Cirricular_Autonomy =~ Cirricular Autonomy 1 + Cirricular Autonomy 2 + Cirricular Autonomy 3 + Cirricular Autonomy 4 + Cirricular Autonomy 5

Teacher Autonomy =~ Didactical_Pedagogical + Cirricular Autonomy

Teacher_Centrism =~ Teacher Centrism 1 + Teacher Centrism 2 + Teacher Centrism 3 + Teacher Centrism 4 + Teacher Centrism 5 + Teacher Centrism 6 + Teacher Centrism 7 + Teacher Centrism 8 + Teacher Centrism 9 + Teacher Centrism 10 + Teacher Centrism 11 + Teacher Centrism 12 + Teacher Centrism 13 + Teacher Centrism 14 + Teacher Centrism 15 + Teacher Centrism 16 + Teacher Centrism 17 + Teacher Centrism 18 + Teacher Centrism 19 + Teacher Centrism 20 + Teacher Centrism 21 + Teacher Centrism 22 + Teacher Centrism 23 + Teacher Centrism 24 + Teacher Centrism 25 + Teacher Centrism 26 + Teacher Centrism 27 + Teacher Centrism 28

# regressions

Teacher_Efficacy ~ Teacher_Stress

Teacher_Efficacy ~ Teacher_Autonomy

Teacher_Centrism ~ Teacher_Stress

Teacher_Centrism ~ Teacher_Autonomy

Teacher_Centrism ~ Teacher_Efficacy

Teacher_Stress ~ Teacher_Autonomy

> fit <- sem(model,data=PRETEND_DATA)

summary(fit)

20191022_105141.jpg

Yves Rosseel

unread,
Oct 22, 2019, 6:11:15 AM10/22/19
to lav...@googlegroups.com
On 10/22/19 11:56 AM, Dave Bell wrote:
> Good morning,
>
> Is it possible to construct a SEM diagram on Lavaan before having your
> data?

Yes.

> > fit <- sem(model,data=PRETEND_DATA)

Just remove the data= argument:

fit <- sem(model)

This will allow you the check/plot the model, without seeing any data.

Yves.

Dave Bell

unread,
Oct 22, 2019, 6:46:46 AM10/22/19
to lavaan
Thank you very much Yves!

I changed the data= argument to fit <- sem(model) as requested, but the model still isn't being produced. R instead shows + down the left hand side which I understand means it believes the code is incomplete. Is there anything missing from the code? I have proof read it for errors several times now!

library("stringr")

library("lavaan")

library("DiagrammeR")

library("dplyr")

library("semPlot")

model <- '

Workload =~ W1 + W2

Professional_Recognition =~ R1 + R2 + R3 + R4 + R5 + R6

Teacher_Stress =~ Workload + Professional_Recognition

Student_Engagement =~ SE1 + SE2 + SE3 + SE4

Instructional_Strategies =~ IS1 + IS2 + IS3 + IS4

Teacher_Efficacy =~ Student_Engagement + Instructional_Strategies

Didactical_Pedagogical =~ DP1 + DP2 + DP3 + DP4 + DP5 + DP6 + DP7

Cirricular_Autonomy =~ CA1 + CA2 + CA3 + CA4 + CA5

Teacher_Autonomy =~ Didactical_Pedagogical + Cirricular_Autonomy

Teacher_Centrism =~ TC1 + TC2 + TC3 + TC4 + TC5 + TC6 + TC7 + TC8 + TC9 + TC10 + TC11 + TC12 + TC13 + TC14 + TC15 + TC16 + TC17 + TC18 + TC19 + TC20 + TC21 + TC22 + TC23 + TC24 + TC25 + TC26 + TC27 + TC28

Teacher_Efficacy ~ Teacher_Stress

Teacher_Efficacy ~ Teacher_Autonomy

Teacher_Centrism ~ Teacher_Stress

Teacher_Centrism ~ Teacher_Autonomy

Teacher_Centrism ~ Teacher_Efficacy

Teacher_Stress ~ Teacher_Autonomy

fit <- sem(model)

summary(fit)


Regards,


Dave

Christopher Desjardins

unread,
Oct 22, 2019, 8:01:26 AM10/22/19
to lav...@googlegroups.com
You are missing a single quote after Teacher_Autonomy above the fit line. 

On Oct 22, 2019, at 6:46 AM, Dave Bell <davealex...@gmail.com> wrote:


--
You received this message because you are subscribed to the Google Groups "lavaan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lavaan+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lavaan/af4521f8-ff52-418d-8a5a-cae0afba424c%40googlegroups.com.

Dave Bell

unread,
Oct 22, 2019, 12:18:42 PM10/22/19
to lavaan
Thank you very much Christopher.

Apologies for the very entry level question (coding is not my strong suit), but having corrected that slight typo I still get a message saying Lavaan did not run (screenshot attached). Do you have any suggestion as to why this may be?

Kind regards,

Dave
To unsubscribe from this group and stop receiving emails from it, send an email to lav...@googlegroups.com.
Screenshot 2019-10-22 at 17.16.44.png

Christopher David Desjardins

unread,
Oct 22, 2019, 12:34:34 PM10/22/19
to lavaan

Hi Dave,

You didn’t pass your data to lavaan. Assuming your data are called PRETEND_DATA, you would run

fit <- sem(model = model, data = PRETEND_DATA)

It sounds like just want to get a path diagram based on your correspondence with Yves.

If so,

semPaths(fit)

might be what you want instead of the data argument.


To unsubscribe from this group and stop receiving emails from it, send an email to lavaan+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lavaan/e83fd520-1506-4190-9776-cdfb9c2ce895%40googlegroups.com.

Dave Bell

unread,
Oct 22, 2019, 12:59:56 PM10/22/19
to lavaan
Many thanks Christopher. That has worked now. The diagram itself is a real mess, so I'll get to work learning how to tidy them up.

Thanks again!

Dave

car...@web.de

unread,
Oct 22, 2019, 3:50:48 PM10/22/19
to lav...@googlegroups.com
To unsubscribe from this group and stop receiving emails from it, send an email to lavaan+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lavaan/8a6614c0-8f20-4308-bb12-6b3ce89395ee%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages