Skip to content

Commit 3262b16

Browse files
Update v6_pedigree_model_fitting.Rmd
1 parent ccbd0a7 commit 3262b16

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

vignettes/v6_pedigree_model_fitting.Rmd

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ Before fitting a model, we need observed data. In practice, this would be measur
224224

225225
We define "true" variance components and use the relatedness matrices to construct the population covariance matrix, then sample from it.
226226

227-
```{r simulate-phenotype, eval = run_models}
227+
```{r simulate-phenotype, eval = has_mvtnorm}
228228
# True variance components (proportions of total variance)
229229
true_var <- list(
230230
ad2 = 0.50, # additive genetic
@@ -250,13 +250,23 @@ V_true <- true_var$ad2 * add_matrix +
250250
set.seed(123)
251251
y <- mvtnorm::rmvnorm(1, sigma = V_true)
252252
253+
253254
# Create named variable labels (required by OpenMx)
254255
ytemp <- paste("S", rownames(add_matrix))
256+
```
257+
258+
```{r show-phenotype}
259+
260+
if (is.null(y)) {
261+
y <- rep(NA, nrow(add_matrix))
262+
263+
}
255264
256-
cat("Simulated phenotype for", ncol(y), "individuals\n")
257-
cat("Mean:", round(mean(y), 3), " SD:", round(sd(y), 3), "\n")
258265
```
259266

267+
268+
We simulated phenotypic data for`r ncol(y)` individuals, with a mean of `r round(mean(y), 3)` and a standard deviation of `r round(sd(y), 3)`. The variance in this simulated phenotype arises from the specified genetic and environmental components according to the covariance structure we defined.
269+
260270
In practice, you would have data from multiple independently ascertained families. Here we simulate data from a single pedigree for simplicity, but the model-fitting functions support multiple pedigrees (shown in a later section).
261271

262272

@@ -295,6 +305,8 @@ vc_model <- buildPedigreeModelCovariance(
295305
Vam = FALSE, # do not estimate A x Mt interaction
296306
Ver = TRUE # estimate unique environment
297307
)
308+
vc_model
309+
298310
summary(vc_model)
299311
```
300312

@@ -336,6 +348,7 @@ full_model <- buildPedigreeMx(
336348
vars = start_vars,
337349
group_models = list(family_group)
338350
)
351+
full_model$submodels
339352
```
340353

341354

0 commit comments

Comments
 (0)