Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

# Description

This update includes minor enhancements and bug fixes related to how string ids are handled in various functions.
This update includes minor enhancements and bug fixes related to how string ids are handled in various functions. It also now allows certain vignettes to not throw an error if openmx is not installed for older R versions. This should resolve r-oldrel-windows-x86_64 1.5.0 22.00 246.00 268.00 ERROR seen in the last CRAN check.

# Test Environments

1. Local OS: Windows 11 x64 (build 26220), R 4.5.2 (2025-10-31 ucrt)
2. **GitHub Actions**:
- [Link](https://github.com/R-Computing-Lab/BGmisc/actions/runs/20666823859)
- [Link](https://github.com/R-Computing-Lab/BGmisc/actions/runs/20786177599)
- macOS (latest version) with the latest R release.
- Windows (latest version) with the latest R release.
- Ubuntu (latest version) with:
Expand Down
59 changes: 54 additions & 5 deletions vignettes/v1_modelingvariancecomponents.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,18 @@ This vignette provides a detailed guide to specific functions within the `BGmisc

```{r setup, include=FALSE}
library(BGmisc)
require(EasyMx)
require(OpenMx)
if (!requireNamespace("EasyMx", quietly = TRUE)) {
message("Please install EasyMx to run the model fitting examples.")
} else {
require(EasyMx)
}
if (!requireNamespace("OpenMx", quietly = TRUE)) {
message("Please install OpenMx to run the model fitting examples.")
} else {
require(OpenMx)
}


```

Ensure that the `BGmisc` package is installed and loaded.
Expand All @@ -37,7 +47,7 @@ Ensure that the following dependencies are installed before proceeding as they p
- `OpenMx`


```{r}
```r
library(BGmisc)
library(EasyMx)
library(OpenMx)
Expand Down Expand Up @@ -88,11 +98,40 @@ identifyComponentModel(

As you can see the model is identified, now that we've added another group. Let us confirm by fitting a model. First we prepare the data.

```{r}
```{r, include=FALSE}
if (!requireNamespace("OpenMx", quietly = TRUE)) {
# if OpenMx isn't available
n_subjects <- 500
require(dplyr)
# require(purrr)

df_summary_data <- data.frame(
age_mean = 34.45,
age_sd = 10.12345,
ht1_mean = 1.662,
ht1_sd = 0.0896277,
ht2_mean = 1.694,
ht2_sd = 0.09903498
)
set.seed(12345)
twinData <- data.frame(
ht1 = rnorm(n_subjects, mean = df_summary_data$ht1_mean, sd = df_summary_data$ht1_sd),
zyg = rep(c(1, 3), each = n_subjects / 2)
)
twinData$ht2 <- twinData$ht1 * ifelse(twinData$zyg == 1, 1, 0.5) +
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)
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)

} else {

data(twinData, package = "OpenMx")
}

```

```{r}
require(dplyr)


selVars <- c("ht1", "ht2")

mzdzData <- subset(
Expand All @@ -104,11 +143,16 @@ mzdzData$RCoef <- c(1, NA, .5)[mzdzData$zyg]


mzData <- mzdzData %>% filter(zyg == 1)

```


Let us fit the data with MZ twins by themselves.

```{r}
if (!requireNamespace("EasyMx", quietly = TRUE)) {
print("Please install EasyMx to run the model fitting examples.")
} else {
run1 <- emxTwinModel(
model = "Cholesky",
relatedness = "RCoef",
Expand All @@ -118,11 +162,15 @@ run1 <- emxTwinModel(
)

summary(run1)
}
```

As you can see the model was unsuccessful because it was not identified. But when we add another group, so that the model is identified, the model now fits.

```{r}
if (!requireNamespace("EasyMx", quietly = TRUE)) {
print("Please install EasyMx to run the model fitting examples.")
} else {
run2 <- emxTwinModel(
model = "Cholesky",
relatedness = "RCoef",
Expand All @@ -132,4 +180,5 @@ run2 <- emxTwinModel(
)

summary(run2)
}
```
Loading
Loading