OpenMx
Published on OpenMx (https://openmx.ssri.psu.edu)

Home > Finding R-squared for two different models

5 posts / 0 new
Log in [1] or register [2] to post comments
Last post [3]
Mon, 06/10/2019 - 18:53
#1 [4]
rranne2@uic.edu's picture
rranne2@uic.edu [5]
Offline
Joined: 12/11/2018 - 00:08
Finding R-squared for two different models
AttachmentSize
PDF icon Plan E Dissertation model general symptom building step 3 new way with latent.pdf [6]230.44 KB
PDF icon Dissertation model anxiety step 4.pdf [7]155.35 KB

Hello!

I have a question about how to calculate r-squared for two different kinds of models. One is correlational and the other models change over time, with just two time points. They both include latent constructs, with anxiety and depression in both models as latent variables derived from four items each. The models are identified and have a relatively good fit CFI of .944 and .954, respectively.

1) "Plan E" Correlational Model (attached visual)

I would like to have r-squared values to represent how much this model in entirety accounts for variance in each of three outcomes (anxiety, depression, and alcohol consumption)--as well as how much of the variance in each of these three outcomes is accounted for by each of the predictors (neuroticism, DT, and AS).

Here's how I built the model:

manifests <- c("transformed_Time3_consumption_conv_5_6", "Time4depression_1c", "Time4depression_1d", "Time4depression_1e", "Time4depression_1g", "Time4anxiety_1a", "Time4anxiety_1b", "Time4anxiety_1f", "Time4anxiety_1h", "per_neurot_y1f_centered", "asi3_total_centered", "dts_total_centered")
 
mydata10[ ,manifests]
 
latents<- c("Time4anxiety", "Time4depression" )
 
myModelplanEstep3<-mxModel(model="planEstepthree", type="RAM", manifestVars=manifests, latentVars=latents, 
mxPath(from="Time4anxiety", to="Time4anxiety_1a", arrows=1, free=TRUE, values=0.8476268, labels=c("anxanx1a")), 
mxPath(from="Time4anxiety", to="Time4anxiety_1b", arrows=1, free=TRUE, values=0.8577030, labels=c("anxanx1b")), 
mxPath(from="Time4anxiety", to="Time4anxiety_1f", arrows=1, free=TRUE, values=0.8541549, labels=c("anxanx1f")), 
mxPath(from="Time4anxiety", to="Time4anxiety_1h", arrows=1, free=TRUE, values=0.8378001, labels=c("anxanx1h")), 
mxPath(from = "Time4anxiety_1a", to = "Time4anxiety_1a", arrows = 2, free=TRUE, values = 0.5647315, labels=c("anx1avar")), 
mxPath(from = "Time4anxiety_1b", to = "Time4anxiety_1b", arrows = 2, free=TRUE, values = 0.2175539, labels=c("anx1bvar")), 
mxPath(from = "Time4anxiety_1f", to = "Time4anxiety_1f", arrows = 2, free=TRUE, values = 0.5079372, labels=c("anx1fvar")), 
mxPath(from = "Time4anxiety_1h", to = "Time4anxiety_1h", arrows = 2, free=TRUE, values = 0.5221816, labels=c("anx1hvar")), 
mxPath(from="Time4depression", to="Time4depression_1c", arrows=1, free=TRUE, values=0.9480274, labels=c("depdep1c")), 
mxPath(from="Time4depression", to="Time4depression_1d", arrows=1, free=TRUE, values=0.8447853, labels=c("depdep1d")), 
mxPath(from="Time4depression", to="Time4depression_1e", arrows=1, free=TRUE, values=0.9699102, labels=c("depdep1e")), 
mxPath(from="Time4depression", to="Time4depression_1g", arrows=1, free=TRUE, values=1.0418291, labels=c("depdep1g")), 
mxPath(from = "Time4depression_1c", to = "Time4depression_1c", arrows = 2, free=TRUE, values = 0.4604164, labels=c("dep1cvar")), 
mxPath(from = "Time4depression_1d", to = "Time4depression_1d", arrows = 2, free=TRUE, values = 0.8118473, labels=c("dep1dvar")), 
mxPath(from = "Time4depression_1e", to = "Time4depression_1e", arrows = 2, free=TRUE, values = 0.5773899, labels=c("dep1evar")), 
mxPath(from = "Time4depression_1g", to = "Time4depression_1g", arrows = 2, free=TRUE, values = 0.7959805, labels=c("dep1gvar")), 
mxPath(from="Time4anxiety", to="Time4depression", arrows=2, free=TRUE, values=.81, labels=c("T3anxT3dep")), 
mxPath(from = "Time4anxiety", to = "transformed_Time3_consumption_conv_5_6", arrows=2, free=TRUE , values=-.03, labels=c("T3anxT3alc")), 
mxPath(from ="Time4depression", to = "transformed_Time3_consumption_conv_5_6", arrows = 2, free=TRUE, values = .05, labels=c("T3depT3alc")), 
mxPath(from = "Time4anxiety", to = "Time4anxiety", arrows = 2, free=FALSE, values = 1, labels=c("T3anxvar")),
mxPath(from = "Time4depression", to = "Time4depression", arrows=2, free=FALSE, values = 1, labels=c("T3depvar")), 
mxPath(from = "transformed_Time3_consumption_conv_5_6", to = "transformed_Time3_consumption_conv_5_6", arrows = 2, free=TRUE, values = .3, labels=c("T3alcvar")), 
mxPath(from = "one", to = "Time4anxiety", arrows=1, free=FALSE, values = 0, labels=c("manxiety")), 
mxPath(from = "one", to = "Time4depression", arrows=1, free=FALSE, values = 0, labels=c("mdepression")), 
mxPath(from = "one", to = "transformed_Time3_consumption_conv_5_6", arrows=1, free=TRUE, values = 1.4, labels=c("malcohol")), 
mxPath(from = "one", to = "Time4anxiety_1a", arrows=1, free=TRUE, values = 2.22, labels=c("mT4anx1a")), 
mxPath(from = "one", to = "Time4anxiety_1b", arrows=1, free=TRUE, values = 1.60, labels=c("mT4anx1b")), 
mxPath(from = "one", to = "Time4anxiety_1f", arrows=1, free=TRUE, values = 1.81, labels=c("mT4anx1f")), 
mxPath(from = "one", to = "Time4anxiety_1h", arrows=1, free=TRUE, values = 1.65, labels=c("mT4anx1h")), 
mxPath(from = "one", to = "Time4depression_1c", arrows=1, free=TRUE, values = 2.71, labels=c("mT4dep1c")), 
mxPath(from = "one", to = "Time4depression_1d", arrows=1, free=TRUE, values = 3.15, labels=c("mT4dep1d")), 
mxPath(from = "one", to = "Time4depression_1e", arrows=1, free=TRUE, values = 2.37, labels=c("mT4dep1e")), 
mxPath(from = "one", to = "Time4depression_1g", arrows=1, free=TRUE, values = 2.34, labels=c("mT4dep1g")), 
mxPath(from ="per_neurot_y1f_centered", to = "Time4anxiety", arrows = 1, free=TRUE, values = .12, labels=c("NeurotT3anx")), 
mxPath(from ="per_neurot_y1f_centered", to = "Time4depression", arrows = 1, free=TRUE, values = .12, labels=c("NeurotT3dep")), 
mxPath(from ="per_neurot_y1f_centered", to = "transformed_Time3_consumption_conv_5_6", arrows = 1, free=TRUE, values = -.02, labels=c("NeurotT3alc")), 
mxPath(from = "per_neurot_y1f_centered", to = "per_neurot_y1f_centered", arrows = 2, free=TRUE, values = 8.86, labels=c("Neurotvar")), 
mxPath(from = "one", to = "per_neurot_y1f_centered", arrows=1, free=TRUE, values = 0.00, labels=c("mneurot")), 
mxPath(from ="per_neurot_y1f_centered", to = "asi3_total_centered", arrows = 2, free=TRUE, values = .5, labels=c("NeurotASI")), 
mxPath(from ="per_neurot_y1f_centered", to = "dts_total_centered", arrows = 2, free=TRUE, values = -.5, labels=c("NeurotDTS")), 
mxPath(from ="asi3_total_centered", to = "Time4anxiety", arrows = 1, free=TRUE, values = .5, labels=c("ASIT3anx")), 
mxPath(from ="asi3_total_centered", to = "Time4depression", arrows = 1, free=TRUE, values = .5, labels=c("ASIT3dep")), 
mxPath(from ="asi3_total_centered", to = "transformed_Time3_consumption_conv_5_6", arrows = 1, free=TRUE, values = .2, labels=c("ASIT3alc")), 
mxPath(from ="dts_total_centered", to = "Time4anxiety", arrows = 1, free=TRUE, values = -.2, labels=c("DTST3anx")), 
mxPath(from ="dts_total_centered", to = "Time4depression", arrows = 1, free=TRUE, values = -.5, labels=c("DTST3dep")), 
mxPath(from ="dts_total_centered", to = "transformed_Time3_consumption_conv_5_6", arrows = 1, free=TRUE, values = -.2, labels=c("DTST3alc")), 
mxPath(from ="dts_total_centered", to = "asi3_total_centered", arrows = 2, free=TRUE, values = .8, labels=c("asidts")), 
mxPath(from = "asi3_total_centered", to = "asi3_total_centered", arrows = 2, free=TRUE, values = 203.91, labels=c("ASIvar")), 
mxPath(from = "dts_total_centered", to = "dts_total_centered", arrows = 2, free=TRUE, values = 125.14, labels=c("DTSvar")), 
mxPath(from = "one", to = "asi3_total_centered", arrows=1, free=TRUE, values = 0, labels=c("mASI")), 
mxPath(from = "one", to = "dts_total_centered", arrows=1, free=TRUE, values = 0, labels=c("mDTS")), 
mxData(observed=mydata10, type="raw"))
 
myModelplanEstep3Run<-mxRun(myModelplanEstep3)
 
refMods<-mxRefModels(myModelplanEstep3Run, run = T)
 
summary(myModelplanEstep3Run, refModels=refMods)

2) Anxiety change model (attached visual)

I would like to have r-squared values to represent how much this model in entirety accounts for variance in the "e" represented in the visual model, which represents the change in anxiety (changeanx in the code below). I would also like to have the r-squared for how much variance each of the predictors (neuroticism, AS and DT) accounts for in change in anxiety.

Here's how I built the model:

latents<- c("Time2anxiety", "Time4anxiety" , "changeanxiety", "L1", "L2")
 
manifests <- c("Time2anxiety_1a","Time2anxiety_1b", "Time2anxiety_1f", "Time2anxiety_1h", "Time4anxiety_1a", "Time4anxiety_1b", "Time4anxiety_1f", "Time4anxiety_1h", "per_neurot_y1f_centered", "asi3_total_centered", "dts_total_centered")
 
mydata8[ ,manifests]
 
Finalmodelanxietystep4<-mxModel(model="finalmodelanxietystep4", type="RAM", manifestVars=manifests, latentVars=latents, 
mxPath(from="Time2anxiety", to="Time2anxiety_1a", arrows=1, free=TRUE, values=0.7, labels=c("anxanx1a")), 
mxPath(from="Time2anxiety", to="Time2anxiety_1b", arrows=1, free=TRUE, values=0.54, labels=c("anxanx1b")), 
mxPath(from="Time2anxiety", to="Time2anxiety_1f", arrows=1, free=TRUE, values=0.6, labels=c("anxanx1f")), 
mxPath(from="Time2anxiety", to="Time2anxiety_1h", arrows=1, free=TRUE, values=0.55, labels=c("anxanx1h")), 
mxPath(from="Time4anxiety", to="Time4anxiety_1a", arrows=1, free=TRUE, values=0.7, labels=c("anxanx1a")), 
mxPath(from="Time4anxiety", to="Time4anxiety_1b", arrows=1, free=TRUE, values=0.54, labels=c("anxanx1b")), 
mxPath(from="Time4anxiety", to="Time4anxiety_1f", arrows=1, free=TRUE, values=0.6, labels=c("anxanx1f")), 
mxPath(from="Time4anxiety", to="Time4anxiety_1h", arrows=1, free=TRUE, values=0.55, labels=c("anxanx1h")), 
mxPath(from = "L1", to = "Time2anxiety", arrows=1, free=FALSE , values=1, labels=c("L1T2anx")), 
mxPath(from = "L2", to = "Time4anxiety", arrows=1, free=FALSE , values=1, labels=c("L2T4anx")), 
mxPath(from = "L1", to = "L2", arrows=1, free=FALSE , values=1, labels=c("L1L2")), 
mxPath(from = "changeanxiety", to = "L2", arrows=1, free=FALSE , values=1, labels=c("changeanxT4L2")), 
mxPath(from ="L1", to = "changeanxiety", arrows = 2, free=TRUE, values = 0.335, labels=c("L1changeanx")), 
mxPath(from = "L1", to = "L1", arrows = 2, free=FALSE, values = 1, labels=c("L1var")), 
mxPath(from = "Time2anxiety", to = "Time2anxiety", arrows = 2, free=FALSE, values = 1, labels=c("T2anxvar")), 
mxPath(from = "changeanxiety", to = "changeanxiety", arrows = 2, free=TRUE, values = 0.328, labels=c("changeanxvar")), 
mxPath(from = "Time2anxiety_1a", to = "Time2anxiety_1a", arrows = 2, free=TRUE, values = 0.54, labels=c("anx1avar")), 
mxPath(from = "Time2anxiety_1b", to = "Time2anxiety_1b", arrows = 2, free=TRUE, values = 0.406, labels=c("T2anx1bvar")), 
mxPath(from = "Time2anxiety_1f", to = "Time2anxiety_1f", arrows = 2, free=TRUE, values = 0.5, labels=c("anx1fvar")), 
mxPath(from = "Time2anxiety_1h", to = "Time2anxiety_1h", arrows = 2, free=TRUE, values = 0.53, labels=c("anx1hvar")), 
mxPath(from = "Time4anxiety_1a", to = "Time4anxiety_1a", arrows = 2, free=TRUE, values = 0.54, labels=c("anx1avar")), 
mxPath(from = "Time4anxiety_1b", to = "Time4anxiety_1b", arrows = 2, free=TRUE, values = 0.258, labels=c("T4anx1bvar")), 
mxPath(from = "Time4anxiety_1f", to = "Time4anxiety_1f", arrows = 2, free=TRUE, values = 0.5, labels=c("anx1fvar")), 
mxPath(from = "Time4anxiety_1h", to = "Time4anxiety_1h", arrows = 2, free=TRUE, values = 0.53, labels=c("anx1hvar")), 
mxPath(from = "one", to = "changeanxiety", arrows=1, free=TRUE, values = 3.22, labels=c("mchangeanx")), 
mxPath(from = "one", to = "Time4anxiety", arrows=1, free=FALSE, values = 0, labels=c("mT4anx")), 
mxPath(from = "one", to = "Time2anxiety", arrows=1, free=FALSE, values = 0, labels=c("mT2anx")), 
mxPath(from = "one", to = "L1", arrows=1, free=FALSE, values = 0, labels=c("mL1")), 
mxPath(from = "one", to = "Time2anxiety_1a", arrows=1, free=TRUE, values = 2.29, labels=c("mT2anx1a")), 
mxPath(from = "one", to = "Time2anxiety_1b", arrows=1, free=TRUE, values = 1.68, labels=c("mT2anx1b")), 
mxPath(from = "one", to = "Time2anxiety_1f", arrows=1, free=TRUE, values = 1.85, labels=c("mT2anx1f")), 
mxPath(from = "one", to = "Time2anxiety_1h", arrows=1, free=TRUE, values = 1.68, labels=c("mT2anx1h")), 
mxPath(from = "one", to = "Time4anxiety_1a", arrows=1, free=FALSE, values = 0, labels=c("mT4anx1a")), 
mxPath(from = "one", to = "Time4anxiety_1b", arrows=1, free= FALSE, values = 0, labels=c("mT4anx1b")), 
mxPath(from = "one", to = "Time4anxiety_1f", arrows=1, free=FALSE, values = 0, labels=c("mT4anx1f")), 
mxPath(from = "one", to = "Time4anxiety_1h", arrows=1, free=FALSE, values = 0, labels=c("mT4anx1h")), 
mxPath(from = "per_neurot_y1f_centered", to = "L1", arrows=2, free=TRUE, values=1.45, labels=c("NeurotL1")), 
mxPath(from = "per_neurot_y1f_centered", to = "changeanxiety", arrows = 1, free=TRUE, values = -.02, labels=c("Neurotchangeanx")), 
mxPath(from = "per_neurot_y1f_centered", to = "per_neurot_y1f_centered", arrows = 2, free=TRUE, values = 8.39, labels=c("Neurotvar")),
mxPath(from = "one", to = "per_neurot_y1f_centered", arrows = 1, free=TRUE, values = 0, labels=c("mneurot")),  
mxPath(from = "per_neurot_y1f_centered", to = "asi3_total_centered", arrows = 2, free=TRUE, values = .5, labels=c("Nasi")), 
mxPath(from = "per_neurot_y1f_centered", to = "dts_total_centered", arrows = 2, free=TRUE, values = .5, labels=c("Ndts")), 
mxPath(from = "L1", to = "asi3_total_centered", arrows = 2, free=TRUE, values = .5, labels=c("L1asi")), 
mxPath(from = "L1", to = "dts_total_centered", arrows = 2, free=TRUE, values = .5, labels=c("L1dts")), 
mxPath(from = "asi3_total_centered", to = "dts_total_centered", arrows = 2, free=TRUE, values = .6, labels=c("asidts")), 
mxPath(from = "asi3_total_centered", to = "changeanxiety", arrows = 1, free=TRUE, values = .2, labels=c("asichangeanx")), 
mxPath(from = "dts_total_centered", to = "changeanxiety", arrows = 1, free=TRUE, values = .2, labels=c("dtschangeanx")), 
mxPath(from = "asi3_total_centered", to = "asi3_total_centered", arrows = 2, free=TRUE, values = 210.0017, labels=c("asivar")), 
mxPath(from = "dts_total_centered", to = "dts_total_centered", arrows = 2, free=TRUE, values = 118.2442, labels=c("dtsvar")), 
mxPath(from = "one", to = "asi3_total_centered", arrows = 1, free=TRUE, values = 0, labels=c("masi")), 
mxPath(from = "one", to = "dts_total_centered", arrows = 1, free=TRUE, values = 0, labels=c("mdts")), 
mxData(observed=mydata8, type="raw"))
 
 
Finalmodelanxietystep4Run <-mxRun(Finalmodelanxietystep4)
 
refMods<-mxRefModels(Finalmodelanxietystep4Run, run = T)
 
summary(Finalmodelanxietystep4Run, refModels=refMods)

Thank you so much for your help!

Top

Copyright © 2007-2021 The OpenMx Project

Powered by Drupal

Source URL: https://openmx.ssri.psu.edu/node/4509

Links
[1] https://openmx.ssri.psu.edu/user/login?destination=node/4509%23comment-form
[2] https://openmx.ssri.psu.edu/user/register?destination=node/4509%23comment-form
[3] https://openmx.ssri.psu.edu/node/4509#comment-8292
[4] https://openmx.ssri.psu.edu/node/4509
[5] https://openmx.ssri.psu.edu/user/42276
[6] https://openmx.ssri.psu.edu/sites/default/files/Plan%20E%20Dissertation%20model%20general%20symptom%20building%20step%203%20new%20way%20with%20latent.pdf
[7] https://openmx.ssri.psu.edu/sites/default/files/Dissertation%20model%20anxiety%20step%204.pdf