You are here

Error in running fixed effect TSSEM1 with clusters

5 posts / 0 new
Last post
myng's picture
Offline
Joined: 03/21/2017 - 02:58
Error in running fixed effect TSSEM1 with clusters

Dear Mike and others,

I would like to conduct a fixed effect MASEM with clusters and I am stuck when I try to run TSSEM1. At first I tried to use a cluster variable that I labeled, and then I tried to use the cluster variable without labels (just "0" and "1" codes). I got different error messages each time.

I don't use R much and I don't know how to format the data in exactly the same way they are formatted in the examples on Mike's website (all data in a single file). I was able to run a random effects TSSEM1 and TSSEM2 the way my data were formatted, without clusters.

I have pasted the error messages below and also attached the R script and data files.

Thank you in advance for your help with this,
Mei Yi

> #Run fixed-effect TSSEM1 according to cluster labels
> cluster1 <- tssem1(vector, n, method="FEM",
+ cluster=mod$IPT1)
Error in if (!all(isPD)) warning(paste("Group ", (1:no.groups)[!isPD], :
missing value where TRUE/FALSE needed
In addition: Warning message:
Unknown or uninitialised column: 'IPT1'.
> #Run fixed-effect TSSEM1 according to cluster labels
> cluster1 <- tssem1(vector, n, method="FEM",
+ cluster=mod$IPT)
Error in tssem1FEM(data.cluster[[i]], n.cluster[[i]], cor.analysis = cor.analysis, :
Lengths of "df" and "n" are different.
In addition: Warning message:
In split.default(x = seq_len(nrow(x)), f = f, drop = drop, ...) :
data length is not a multiple of split variable
> summary(cluster1)
Error in summary(cluster1) : object 'cluster1' not found

Mike Cheung's picture
Offline
Joined: 10/08/2009 - 22:37
Dear Mei Yi,

Dear Mei Yi,

I am not able to read the data. For example, v_pre_post.txt is not present; n <- read.table("vectormaxn.txt") returns n as a data frame.

Could you please check the script whether the data and sample sizes can be imported?

Best,
Mike

myng's picture
Offline
Joined: 03/21/2017 - 02:58
Dear Mike,

Dear Mike,

Thanks for your quick response, and apologies for the errors in my script. I have checked the script and made a few changes, the revised script is attached (cluster.R).

  1. v_pre_post.txt is changed to v_pre_posti.txt in the script and should be able to be imported (same data file that I have sent you)

  2. n <- read.table("vectormaxn.txt") was what I used to run random effects analyses successfully, so I had assumed it would be ok for fixed effects analyses. In case it is helpful I have attached my random effects script, random.R, which uses this syntax without problems.

  3. In case n being read as data frame was causing problems for fixed effects analyses, I have created another data file, nmod.txt that contains n and data for one moderator. The cluster.R script has been changed to read n using the syntax:
    nmod <- read.table("nmod.txt", header=TRUE)
    nmod$n

  4. I tried to run the fixed effects analyses, without cluster, and then with cluster, and now I am getting the error message below for TSSEM1 in both analyses:

Error in if (!all(isPD)) warning(paste("Group ", (1:no.groups)[!isPD], :
missing value where TRUE/FALSE needed

Thank you for your help with this issue,
Mei Yi

File attachments: 
myng's picture
Offline
Joined: 03/21/2017 - 02:58
Dear Mike,

Dear Mike,

Sorry to post so many messages, I have just realized that I may have gotten the above error message because I may have too much missing data in the correlation matrices. When I run is.pd I get TRUE for the matrices without missing data, and NA for the matrices with missing data. Thus I have rerun the fixed effects analyses without cluster, and then with cluster, and there were no longer any error messages, and openmx status was 0 for all analyses.

My questions now are:

  1. Is there a way to run the fixed effects analyses with clusters and include the matrices with missing data?

  2. For the fixed effects analyses with clusters that I have run, the Stage 1 fit is not good in one cluster or both clusters (depending on which dataset I use). However, Stage 2 fit is ok. I have already run random effects analyses (without clusters) and fit was good, but I wanted to see whether clusters could explain some of the heterogeneity. I also have hypotheses that the mediation model I was testing should apply in one cluster but not in the other--true enough, indirect effect was significant in one cluster but not in the other. Can I use this as evidence to support my hypotheses, or would that not be advisable given that the cluster stage 1 analyses showed poor fit?

In case it helps, I have attached the new script, correlation matrix data file, and sample size/moderator data file, where all matrices have no missing data.

Thanks so much,
Mei Yi

Mike Cheung's picture
Offline
Joined: 10/08/2009 - 22:37
Dear Mei Yi,

Dear Mei Yi,

The fixed-effects TSSEM is more sensitive to the presence of missing data. You may use the following code to conduct the fixed-effects model with missing data.
fixed1 <- tssem1(vector, nmod$n, method="REM", RE.type="Zero")

It does not work with the "cluster" argument yet. I hope to add it later.

Regards,
Mike

Log in or register to post comments