simulating multivariate structures

Upload: diogo-mendes

Post on 06-Apr-2018

222 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/3/2019 Simulating Multivariate Structures

    1/3

    Simulating multivariate structures using R

    The following examples shows how to simulate a multivariate structure with a particular measurement model and a particular structural model. This example produces data suitablefor demonstrations of regression, correlation, factor analysis, or structural equation modeling. See the mvtnorm package for more elegant ways to simulate covariance matrices. The

    set of procedures shown here are meant to help the user think about structural models.

    The basic logic is in terms of a measurement (factor) model relating observed variables to a set of unobserved factors. Then we have an effects model that describes how the latent

    variables are interrelated. (This is the basic logic of structural equation modeling, but of course, here we are doing it in reverse.)

    First we create a function (mes) that does the work. Parameters to be passed to this function are a factor model (also known as a measurement model) relating how each item relates

    to a number of latent factors. Then we create an effects model, which is a set of path coefficients between the latent variables.

    In this page, as well as most of my examples, theblue text can be copied directly into R.

    mes

  • 8/3/2019 Simulating Multivariate Structures

    2/3

    0,0,.5),

    nrow=3,ncol=3,byrow=TRUE)

    effect

  • 8/3/2019 Simulating Multivariate Structures

    3/3

    GREA=round(observedscore[,3]*100+500,0)

    Ach=round(observedscore[,4]*10+50,0)

    Anx=round(-observedscore[,5]*10+50,0)

    Prelim=round(observedscore[,6]+10,0)

    GPA=round(observedscore[,7]*.5+4,2)

    MA=round(observedscore[,8]*.5+3,1)

    data=data.frame(GREV,GREQ,GREA,Ach,Anx,Prelim,GPA,MA)

    summary(data) #basic summary statistics

    round(cor(data),2) #show the resulting correlations

    #it is, of course, identical to the previous one

    #example 6 9 variables on 3 factors, with the first two predicting the 3rd

    # The particular example assumes that there are 3 measures of ability (GREV, GREQ, GREA), two measures of motivation (achievment #motivation and a

    title