I want to conduct a LOSEM twin analysis using OpenMX under R. (It's used in behavioral genetics and twin studies to investigate the genetic and environmental influences on traits and behaviors).

My Variables: a.res. and b.res(dependent variables [standardized]),z_age (age [standardized]), zygof1f2 (zygosity,MZ meaning monozygotic = 1, DZ meaning dizygotic = 2)

My Code:

\#Select dependent variables.
selDVs = c("a.res.", "b.res.")

\#Select moderator
moderator = "z_age"

\#Subset MZ and DZ data
mzData =subset(DS_HA, zygof1f2 =="MZ",c(selDVs, moderator))
dzData =subset(DS_HA, zygof1f2 =="DZ",c(selDVs, moderator))

\#Define LOSEM increments
targets = seq(from = -1.0, to = 2.0, by =.01)

\#Run and plot for specified windows
output\<-umxGxE_window(selDVs = selDVs, moderator = moderator, mzData = mzData, dzData = dzData, target = targets)

After executing the last command, the following error is displayed:

Error in if (target < min(modVar)) { : the condition has length > 1

I don't understand the error or how to solve it.

1

There are 1 best solutions below

2
On BEST ANSWER

That's a bug in the umxGxE_window function. You should report it to the author.

The help page for umxGxE_window says that target can be "A user-selected list of moderator values to test (default = NULL = explore the full range)", so your use of targets <- seq(from = -1.0, to = 2.0, by =.01) should be okay. But the function has the test in the error message, which is not legal when target is a vector like targets.

A workaround might be to put everything in a loop and pass in one target at a time, but that would be a lot of trouble, and might not give the result you want.