JASP - Structural Equation Modeling

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys so we have a quick break from our mediation and moderation series and I'm going to talk about how to do a structural equation model in Jess so first things first the sim functions that Jaffe's writing in the background are Levon which is an hour package that you can learn about on our YouTube channel and I wanted to first start by looking at the Levon page because I think it's really fantastic set of tutorials if you are trying to learn how to do this better it's why I recommend going I just type live on in and take a goal and this takes you to the page that they have set up for it you can click on tutorials to look at a bunch of different examples now it's those to show this to you and are but the way that you write the model syntax is the same so you can use it to help you find how to write models because jazz will handle all of the analysis part for you so this is a good resource for you if you're trying to learn how to do something specific the other quick thing that you can look at it's our own website so stats tools to click on learn statistics and then click on structural equation modeling I have my entire eight-week summer course or this would be a full 16 week course in a regular semester on Livan it actually teaches it to you and our but you could use these tutorials to help you learn more about just the basic concepts in Tsim so there are lectures for each one there are also examples of how to run these in our which you could use to learn the model syntax code to pour in the Jass and then there are actually examples of assignments that we do in this class worked for for people so I have my entire course in order online linked for you guys and you can find the files I'm going to use today in our oh s F folder which is also linked at the top here so you can use a little vine website or you can use some of my lectures to help you say let's say I want to do a a a multi group CFA so you could learn how to write some of the code for for that that being said let's go over to Jass pand look at how this works I've also got a worksheet here that we're going to go over but let's start with Jessie so I'm gonna pull in the holzinger data set which is a really classic data set that's included in the LaVon package the other thing you can do is open a data set from Jass but that talks about the sim functionality so let's look at that one first and then go into doing our own so you click file you can click data library this is in the newest version of Jasper so I if you don't see this be sure you download an update click sim and the political democracy data set is also included as part of LaVon so also a great data set I can click to open the Jazz file and then it's got some examples and then kind of an already or write our example of all the things that you might see if you want to learn like what they're doing here you click on the actual analysis and it'll show you over here how they ran it so that's another resource for you but if I wanted to do this from scratch I would not close gasp oops open gasp I'm going to open my holzinger data set that I downloaded from our and what's in this data set is like a children's rate like scores on text analysis and like visual reading speed a couple other things this example is the one on the LaVon help page so that you can match that data set to an example in Jasper but if you're looking here at just your main options under Jasper you won't see a sim so you've to click on the little plus here and then click sim and it has the only option would just live on so this top section here is where we're gonna write the model syntax code so this is the part that really just takes a little bit of learning because after that the point-and-click options below are really great so like what do I write here to make the magic happen basically and so that's where our handy chichi is gonna come in so some basics spacing doesn't matter the lines matter so you need to hit enter to get a new equation I put equation in quotes because what we're gonna do is sort of write what we expect the model to look like and those are obviously equations so every time you need a new latent variable or a new regression you will enter it on a new line but otherwise spacing doesn't matter so you can hit the space bar between variable names and pluses I do that because it's easier for me to read but that's not required so the main components here are gonna be and the one you use the most is definitely equals tilde so equals tilde creates a latent variable and that's described on lavon's help page this is is measured by so you can make a big equals tilde as this latent variable is measured by all these other variables what this really means is that the prediction is going from the latent variable to the manifest variables so let's add that here so prediction is is that latent variable predicts the manifest variables I am assuming you know a little bit about sim if you're here watching this video but latent variables are ones that are not measured in your data set they're normally represented by circles on a diagram a structural equation modeling diagram manifest variables are data the big data that's in your data set there physically management measured variables and those are easily represented by squares on a diagram and so if you do equals tilde the arrow is gonna go from the latent variable to the manifest variables and I'm in Psych so this is the way that most people think about some of psychological phenomenon that IQ is this thing that we possess that predicts the scores or the behavioral output so this direction is generally that we think the latent variable is the cause for the measurement that we see but you can do it actually the other way and this is less common I talk about this in my class but I personally never used this syntax in a paper which is less than tilde and so it kind of looks like if you write model code correctly quote-unquote in R you do the less than symbol on the dash this is very similar to that and so what you would do is type that the latent variables the latent variable is predicted by D manifest variables so here we would say that the prediction is that the latent variable is predicted by manifest variables sometimes these are called composite variables where let's say you're trying to create a composite of a picture of someone you might use socioeconomic status education some other things that create that latent variable and that prediction kind of makes sense we're building a picture of maybe a person's potential achievement or something now what do I write here so I've talked about the equals tilde and I've talked about the less than tilde what you write is the name of the latent variable on the left and all the name of the manifest variables on the right the latent variable can be any name as long as it's not something in the data set or Lovano Cobourg because it needs to you're building a variable here so you name it is what I mean by that so you come up with something everything on the right variable one variable two needs to be the name of the derrial from the data set so if it doesn't have a corresponding column in the data set this will not run a couple of other options that you can use as a single tilde this is used as a regression so that format is y tilde X which means that Y is predicted by X or you can say X predicts y either way and the difference between this equals tilde and this tilde is that this is creating a latent variable where the prediction goes from the latent to the manifest variables so from left to right however when you use a single tilde the prediction is that X predicts Y so it's actually going from the right to the left and so sometimes I have students have a trouble with this because basically it's one symbol different but the direction of the prediction is the opposite and that's because of me first two you're really you're creating a variable and so that's why there's this equals or this less than sign here we're using two names of things that are in the data in the model already so why is predicted by X if you're familiar with R this is the same order that you write it in R now here the names on the left and the right need to be defined in the data set or a previous model line so you can use Layton's to predict each other and it's like a fully structural model but you do need to define the Leighton before you use it so the order of the lines in your model syntax also matters so you can't use a latent variable before you have to find it - till days indicates covariance or correlation or residuals so this is really like the kind of variance options and so it depends on what you use this with but generally this does not order does it doesn't matter what order you write it in because we remember with correlation you can call one x and y but we don't have a direction of the prediction so we're just saying they're correlated to each other these names do need to be defined in the data set or a previously defined latent variable so again the order matters you can set the variance of a variable specifically by using and let's do this so that it's clear what's going on let's say variable tilde tilde sum number twelve times the variable so if you have problems with haywood cases which are improbable solutions you could set the variance of a variable to a specific number you could set it to zero you could turn it off so you can actually set the coefficients directly generally you're gonna add these double till days because you want to add a correlation between two variables that may be our correlated error terms so you have two items that measure approximately the same thing you might do this to turn off the automatic correlation between some some types of variables over a couple of other instances so this is something that you will use and then one last one anytime you see variable the way this would look is variable tilde one that indicates that you're just talking about the intercept for that variable I have not used the intercept code very often but if you see it that's what it is so 90% of the work it's gonna be with the latent variable creation and regression so let's go over here and just do a really simple model so you can actually also import variance covariance matrix like if you're doing this from a book so a lot of these structural equation model books provide the variance covariance matrix and you can actually recreate models from books by telling it to pull the variance covariance matrix out of you're out of a dataset so you would have to type it into CSV and then use this but that's a really fantastic thing about reproducing these models is that you just need the variance covariance you don't need the raw data but you have to rotate it go ahead and use it as a quick reminder what are the variables in this data set so I'm not gonna use any of this other gender or any of that I'm gonna stick with X one two three four five six seven eight nine so one thing you can do let me show you go back to lavon's homepage here on their tutorial there's a little bit of stuff but they give you this model syntax and gives you some examples of how all this works it's basically what I just very briefly cover but they have a CFA example and this talks about this holzinger data set and so when we were talking about equals till days what's happening is when I create this visual variable I called it visual that's not in the data set equals tilde X 1 plus X 2 plus X 3 see how the arrows go from the visual variable to the manifest variables X 1 2 3 so that I say that the prediction is that this visual factor predicts the scores on 1 2 3 anytime you see these double-headed arrows what you're getting is covariance or correlation so we expect these to be correlated and I have several videos on like basics of CFA basics of what liván does in the background that you can watch but it will automatically correlate all these all of these types of variables so these are um exogenous variables meaning the arrows only go out and they don't come in so the arrows only go out so will automatically correlate those which sometimes is a surprise if you're writing a model you've never seen that before so this is what a model syntax might look like so I'm gonna highlight all this so you don't have to watch me type just paste it in now spacing doesn't matter so I could have run the entire line together and I don't think I can make the font any bigger unfortunately so if we come back over here I can make this bigger what's happening is I've typed visual I've named it visual I could call this Swiss cheese if I wanted to equals till then so it's 1 2 & 3 add it together so I put plus signs between the names of the variables in the data set to indicate that though that visual variable is comprised of all three of these hit enter and you'll get you can type their next one so what I mean by each equation gets a new line is like this is the first equation I am creating this visual variable the next equation is that I'm creating this text variable and what's going to happen is because these don't have any predictions between each other or correlations between them it's going to auto add the correlations so they're not just floating in space and so you'll automatically get this covariance between them you can't turn that off but it wouldn't be a little weird your variable names cannot have spaces so one thing about the Livan tutorial over here is they're talking about it being latent variable that's fine you don't use faces in your names of your variables so I could change this to be Swiss cheese if I wanted to any name you want that's not in the dataset I'll go back to having it be visual and then I'm gonna hit Apple or command enter I think it's control-enter on windows machines and it will run the model for you so let's look at quick here what output I get so I can delete this one because this is before I entered any kind of models and I just hit remove oh not all analyses I just want you to go away let's see what happens when I click remove all I haven't tried it yet ah it went away okay come back so here's a clue that spacing doesn't matter this still ran okay so the very first thing you'll see here is the main fit statistics for the model now it's just gonna show me the degrees of freedom hey I see B I see these are really great for model comparison chi-square change in chi-square which is a little odd because I haven't really added anything to this model and if that chi score is significant which is a bit useless because chi-square is negatively impacted by sample size then next thing without editing any of the options here gives me the parameter estimates I was trying to make this bigger but I don't think I can so it kind of keeps going over here but the parameter estimates give you a clue as to the coding of how this works so visual till equals tilde that matches what we did over here so visual related to X one label here is a label that you can apply if you want to and we'll do that in just a second estimate one okay why is this a one well this is where I really recommend watching a bunch of the videos on like the background of Sim but this is the marker variable sometimes it's called the scaler scaling variable because the default is to scale the data based on them on our scale the model based on the indicators for each factor we could change that if we wanted to and look at standardizing the entire model based on the variances but it gives me each one of these if you're used to looking at LaVon code this looks a little different I think this is actually a bit neater because I can copy this chart over but I get each of the factor loadings basically it's what they are now this isn't the scale of the data the more useful option is way over here under standardized all standardized always like the completely standardized solution this you can interpret like an exploratory factor analysis another option you can use a standardized LaVon oh I'm sorry not lavond latent variable this would be if you put the scaling on the variance of the latent variable instead of on the marker variable so you're actually gonna see all the possible combinations of standardization or scaling right away and this is what I teach people to do when I run this in R because then you can see all of them and you don't have to reprogram it to only show you one of them all right you get the standard error for each variable and then if the parameter estimates are significant down here we're going to see X 1 tilde tilde X 1 which looks a little weird that's the error variance for your your manifest variables here so this just shows you what that code would look like if you wanted to add it in so let's say I decided that this error variance is all wrong or it's negative and it shouldn't be in it's a Haywood case what I could do is type X 1 tilde tilde some number let's pick 2 times X 1 so by doing that what we've done is we've set the variance to X 1/2 okay command enter and it will update that model and you'll now see X 1 and it's now set to 2 and so it'll turn off estimating this for you because you set it to a number so quick and dirty on how to set specific parameter estimates and turn that off go back to the real model down here now visual till they tell a visual this is the variance for the latent variables skip down a little bit more now I've got Ville visual tilde tilde textual this is the covariance between the latent variables covariance very difficult to interpret so scroll Scroll scroll Scroll scroll Scroll scroll get all the way over here to standardize all that is the correlation between latent variables so you automatically get the correlations you'll notice here under standardize all the variances for the latent variables are set to 1 that's how it's standardizing it so it's kind of moving from them the marker variable to the latent variable now this labels thing what can I do labels are handy if you want to set two variables equal to each other so let's say I know X 1 and X 2 should be the same estimate okay all right I'm sorry let's do X 2 and X 3 so I know that those should probably be exactly the same for whatever reason I can call both of those parameter are those coefficients any word I want as long as it's not a name of some then the in the dataset so I'm gonna Co if times now if I just update the model now you'll see that I've labeled it as Co if maybe not so useful now what I can do though it's force and equality between the coefficients for 1 X 2 and X 3 by giving them the same name and by forcing that equality you'll see now that they have the exact same estimate so this is really nice if you have an unidentified model because you don't have maybe you only have two manifest variables and you need to set them the same to deal with identification I have a whole video on that specific problem and this is how you might fix it so there really it's really handy to deal with potential model issues with identification or scaling all right now quick let's get into one of the options down here so I can do different types of error calculation I could get additional fetch measures which to me is much more handy because now I can see my more common fit indices that are reported at least in Psych so the CFI is one of the big ones so it's a point 9 3 1 I often see the tli you get the NFI the NFIP f5 a little okay I have a whole video on what are all these alphabets oops if you want to learn more about the individual fit indices and what they are AI C and B I see again down here to our badness of fit statistics the rim see it's confidence interval and the SRM are some more popular one and some even more so you got way way more fit statistics you can also pick up the LaVon book Chris Layton for hirable modeling an R by boson who talks the where I got my lecture notes from you can't look at there's even more stuff the most common thing you're gonna pick as additional fit measures under options here this is where you could start working on grouping variables you can learn about multi group factor analysis you can't say quality constraints for all these different options so this is something you would want to maybe learn about multi group analysis first what is it how does it work and then this section will make a little more sense well you could pick to set some equality constraints on maybe let's say the loadings and you can look at each group one at a time if you wanted to change the way this is estimating so maximum likelihood generalized least squares weight least squares I'm Lea least squares I forget what the last one is the LaVon help page talks about what all of these are and how they work you can include mean structure that's gonna be really popular if you're gonna be useful if you have a grouping variable assume I'm factors uncorrelated will turn off those extra correlations so it would make visual to text 0 uh let's see here factor scaling I would honestly would tell you leave this one alone because if I change it to residual variance all I'm gonna see is that it'll change the main column to BST dlv so then the default here will show you all of the possible options on the on them the regular factor loading scaling on the latent variable or to me the more helpful one standardized all so you kind of see all of them already you don't necessarily need that option under advanced there was even more options so you can completely customize the analysis that normally you would do kind of through programming separate models a lot if you want to save the models that's different you can actually switch and name this one model too and then we can make some edits so how what would I might edit hmm I could always turn on modification indices and look at those down here on the bottom so modification indices are gonna tell me what options I might consider adding to the model to make it and this really depends on the model you're working with and the options and your field and theory and stuff but let's say we know x7 and x8 are very similar variables so I might consider adding that as a correlated error so I would type it as x7 tilde tilde x8 just like you see here so the left hand and right hand operators just taught me that directly go back there you go I didn't apply it x7 + x8 I'm gonna hit command enter or ctrl enter to run oops oh I did plus sorry tilde tilde by giving this a new name as model 2 down here under options it actually now will show me the differences between models so this is the ANOVA function in R but that shows me when I added this new equation now I can see the difference between models so the difference in chi-square here is between model one and model two what you can just see like or actually it's giving me model to two saturated but so now I can come down here and look at this last line and the difference here at 32 points is a difference between 85 and 53 here so we would say this is significant change but that doesn't mean a whole lot when it comes to sim alright let's come down here let's look at our fit indices so we could look at model ones fit indices in the model to fit indices and see which one we like better unfortunately I think it only shows you one models fit indices at a time so you have to go back to model one to look at those fit statistics or hit ok and run a completely different model here but when I updated that now you'll see x7 tilde tilde X 8 so this is added a correlated error the only other thing that I would love if Jasper would add here is there are some really great plotting options they're kind of hideous if you have lots and lots of squares but this would help you visualize how this might should look to make sure that you're writing the code correctly so that's the only thing I see otherwise I think this is a really great way to take normally completely our code and make it a little bit easier on make it point and click so one last plug if you really want to learn more about the actual nitty gritty for sim you can watch the the lectures on like the like just material and then if you watch some of the example videos you the very first thing I always do is talk about the model syntax so you could take that model syntax and type it into Jasper here and then you can ignore me when I talk about cfas and summaries but the the numbers you get should show up exactly the same as well as the interpretation of what's going on so you can kind of use some of this other these other demonstrations that I have to help you learn how to write the right type of model syntax as well as the Levon help page so Ruby a viewer request for sim in Jasper that's the short and dirty version if you have more specific requests just let me know so that's sim ingest using LaVon
Info
Channel: Statistics of DOOM
Views: 11,788
Rating: undefined out of 5
Keywords: statistics, jasp, just another statistics program, structural equation modeling, sem, lavaan, models, modeling, data science, data analysis
Id: eH6DBpLmvRg
Channel Id: undefined
Length: 30min 42sec (1842 seconds)
Published: Fri Jul 20 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.