5,861 views

Skip to first unread message

Mar 6, 2019, 11:29:31 AM3/6/19

to lavaan

Hello,

I am using the code below when running a serial mediation model (See attached).

out=lavaan::sem(model1, data=dat, meanstructure=TRUE, missing="fiml",se="boot",bootstrap=1000)

summary(out, standardized=T, rsquare=T)

Questions:

1. the code above yields R-square for the two mediators and the outcome variable only. Is there a way to request the R-square for all predictors in the model?

2. Is it also possible to request a p-value for each r-square generated? My understanding is that this differs from the p-values included in the regression output.

3. I am interested in d21 (path between two mediators) and would also like to have an r-square for this--would this be possible?

Thank you in advance for your assistance

Mar 6, 2019, 3:08:06 PM3/6/19

to lavaan

1. the code above yields R-square for the two mediators and the outcome variable only. Is there a way to request the R-square for all predictors in the model?

You seem to be confused about what R-squared is. It is the variance explained in an outcome by an entire set of predictors. Thus, only endogenous variables have R-squared. Any exogenous variables have no predictors, and thus R-squared is 0 by definition.

2. Is it also possible to request a p-value for each r-square generated?

No, but you can use bootstrapLavaan() to obtain bootstrap CIs of any quantity you want.

3. I am interested in d21 (path between two mediators) and would also like to have an r-square for this--would this be possible?

R-squared is the variance explained by all predictors, not one predictor. It sounds like you want partial eta-squared, which is not returned by lavaan.

Terrence D. Jorgensen

Assistant Professor, Methods and Statistics

Research Institute for Child Development and Education, the University of Amsterdam

Mar 12, 2019, 3:04:20 PM3/12/19

to lav...@googlegroups.com

Thank you, as always, for your responses.

Apologize for not getting this readily but as a follow-up to #2:

How would I use bootstrapLavaan()to request the CI for Rsquared?

Code I used to request R squared:

out=lavaan::sem(model1, data=dat, meanstructure=TRUE, missing="fiml",se="boot",bootstrap=1000)

summary(out, standardized=T, rsquare=T)

R squared values produced by Lavaan: M1 (mediator 1) M2 (mediator 2) Y (DV)

--

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 post to this group, send email to lav...@googlegroups.com.

Visit this group at https://groups.google.com/group/lavaan.

For more options, visit https://groups.google.com/d/optout.

Mar 12, 2019, 5:44:55 PM3/12/19

to lav...@googlegroups.com

Thank you, as always, for your responses.

Apologize for not getting this readily but as a follow-up to #2:

Code I used to request R squared:

out=lavaan::sem(model1, data=dat, meanstructure=TRUE, missing="fiml",se="boot",bootstrap=1000)

summary(out, standardized=T, rsquare=T)

R squared values produced by Lavaan: M1 (mediator 1) M2 (mediator 2) Y (DV)

This may not be a Lavaan question but I'd appreciate any help with making sense of these findings.

Mar 21, 2019, 6:05:06 AM3/21/19

to lavaan

Question 1:How would I use bootstrapLavaan()to request the CI for Rsquared?

Is it possible to get CI's for these three R squared values? If so, what is the code I should use?

You can use the parameterEstimates() function, with rsquare = TRUE, then extract the values you want from the data.frame it returns.

`example(sem)`

(PE <- parameterEstimates(fit, rsquare = TRUE)) # the R-squared values are in rows where "op" is "r2"

PE$est[PE$op == "r2"]

As described on the help page, write a function that accepts your lavaan object, and returns what you want, then pass that to bootstrapLavaan()

`myFunc <- function(object) parameterEstimates(object, rsquare = TRUE)$est[PE$op == "r2"]`

bootOut <- bootstrapLavaan(fit, R = 1000, FUN = myFunc)

head(bootOut) # first few bootstraps of each R-squared, some NAs when estimated residual variance is negative

## percentile 95% CIs

apply(bootOut, 2, quantile, probs = c(.025, .975), na.rm = TRUE)

Question 2:On a slightly different note, when estimating the indirect effect in this model, I find that the p-value for the effect (a1d21b2) and the bootstrap CI (n=10000) do not agree. p=.055, CI=does not include 0

A product of multiple paths will not have a normal distribution. The p value uses the bootstrap SE but still assumes normality. Just use the CI, which does not assume normality or even symmetry.

Mar 21, 2019, 8:36:29 AM3/21/19

to lav...@googlegroups.com

This is incredibly helpful. Thank you.

2019년 3월 21일 (목) 오전 6:05, Terrence Jorgensen <tjorge...@gmail.com>님이 작성:

Jun 26, 2019, 6:56:34 AM6/26/19

to lavaan

Hi Terrence,

I have read quite a few of your posts on how to solve the Heywood case in models. If I understood it correctly, if the item error variance is reasonably small, and the CI crosses zero, then it is possible to assume that the true value is actually nonegative.

In light of that, I would like to perform a bootstrapping on that particular error variance. I tried to follow the code you provided in this post, however, since the value is in the row, I don't really know for sure how to write the syntax. Could you please help me out?

Thank you!

Jun 26, 2019, 9:17:05 AM6/26/19

to lavaan

If I understood it correctly, if the item error variance is reasonably small, and the CI crosses zero, then it is possible to assume that the true value is actually nonegative.

Well, you can't reject that null hypothesis. That is not the same as confirming it. But in my experience, it takes a hell of a lot of misspecification to cause a Heywood case when sampling error is clearly not the cause. So if your model fits even moderately well and your sample size is not quite large, I opine that sampling error is a more likely explanation.

I tried to follow the code you provided in this post, however, since the value is in the row, I don't really know for sure how to write the syntax.

The previous function also extracted rows. You just need to extract the one you are interested in. If your variable with negative residual variance is "foo", you look for the row with "foo" on both the left and right-hand side of the ~~ operator:

myFunc <- function(object) parameterEstimates(object, rsquare = TRUE)$est[PE$lhs == "foo" & PE$op == "~~" & PE$rhs == "foo"]

Jun 26, 2019, 8:45:27 PM6/26/19

to lav...@googlegroups.com

Hi Terrence,

Thank you very much for your quick reply.

The bi-factor model fits quite well, that's why I really want to make this model work. I have another question regarding this model if you don't mind. It is a bi-factor model, with a general factor predicting all the 33 items (N=1014) and eight specific factors predicting group items. I know that a lot of people advocate that specific factors are not supposed to be correlated with each other, but I have also read some emperical studies that correlated those specific factors. What is your thought?

Thank you!

--

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 post to this group, send email to lav...@googlegroups.com.

Visit this group at https://groups.google.com/group/lavaan.

To view this discussion on the web visit https://groups.google.com/d/msgid/lavaan/bada0e2e-e966-4583-bd2c-3605b727431e%40googlegroups.com.

Jun 27, 2019, 4:57:43 PM6/27/19

to lavaan

What is your thought?

That whether your model is empirically identified is a matter of a coin toss. But you can get more feedback about general questions on SEMNET:

Reply all

Reply to author

Forward

0 new messages

Search

Clear search

Close search

Google apps

Main menu