@@ -24,15 +24,16 @@ This vignette provides a detailed guide to specific functions within the `BGmisc
2424
2525``` {r setup, include=FALSE}
2626library(BGmisc)
27- if (!requireNamespace("EasyMx", quietly = TRUE)) {
28- message("Please install EasyMx to run the model fitting examples.")
29- } else {
30- require(EasyMx)
31- }
27+
3228if (!requireNamespace("OpenMx", quietly = TRUE)) {
3329 message("Please install OpenMx to run the model fitting examples.")
3430} else {
35- require(OpenMx)
31+ library(OpenMx)
32+ }
33+ if (!requireNamespace("EasyMx", quietly = TRUE)) {
34+ message("Please install EasyMx to run the model fitting examples.")
35+ } else {
36+ library(EasyMx)
3637}
3738```
3839
@@ -116,7 +117,12 @@ if (!requireNamespace("OpenMx", quietly = TRUE)) {
116117 zyg = rep(c(1, 3), each = n_subjects / 2)
117118 )
118119 twinData$ht2 <- twinData$ht1 * ifelse(twinData$zyg == 1, 1, 0.5) +
119- rnorm(n_subjects, mean = 0, sd = df_summary_data$ht2_sd) + .1 * rnorm(n_subjects, mean = df_summary_data$ht2_mean, sd = df_summary_data$ht2_sd)
120+ rnorm(n_subjects,
121+ mean = 0, sd = df_summary_data$ht2_sd) +
122+ .1 * rnorm(n_subjects,
123+ mean = df_summary_data$ht2_mean,
124+ sd = df_summary_data$ht2_sd)
125+
120126 twinData$ht2[twinData$zyg == 3] <- twinData$ht2[twinData$zyg == 3] + .5 * rnorm(sum(twinData$zyg == 3), mean = df_summary_data$ht2_mean, sd = df_summary_data$ht2_sd)
121127} else {
122128 data(twinData, package = "OpenMx")
@@ -147,6 +153,7 @@ Let us fit the data with MZ twins by themselves.
147153if (!requireNamespace("EasyMx", quietly = TRUE)) {
148154 print("Please install EasyMx to run the model fitting examples.")
149155} else {
156+ library(EasyMx)
150157 run1 <- emxTwinModel(
151158 model = "Cholesky",
152159 relatedness = "RCoef",
@@ -165,6 +172,7 @@ As you can see the model was unsuccessful because it was not identified. But whe
165172if (!requireNamespace("EasyMx", quietly = TRUE)) {
166173 print("Please install EasyMx to run the model fitting examples.")
167174} else {
175+ library(EasyMx)
168176 run2 <- emxTwinModel(
169177 model = "Cholesky",
170178 relatedness = "RCoef",
0 commit comments