Install and run the Windows version of LatentGOLD 6.0 on a Mac device (Intel or Apple Silicon).
- link: https://brew.sh
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | |
# Example of simple SEM simulation # | |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | |
# # | |
# Author(s): # | |
# - Mihai Constantin ([email protected]) # | |
# # | |
# File description: # | |
# - This file contains the general workflow for a Structural Equation # | |
# Modeling (SEM) simulation, with an accent on sample size analysis. # |
# Libraries. | |
library(lavaan) | |
library(ggplot2) | |
library(patchwork) | |
# If not installed, then install as follows: | |
install.packages(c("lavaan", "ggplot2", "patchwork")) | |
# Model 1. | |
# |
# Phantom latent variables. | |
# Load the packages. | |
library(lavaan) | |
library(semPlot) | |
# Load data. | |
data(HolzingerSwineford1939) | |
# Store the data. |
# Load libraries. | |
library(lavaan) | |
# #region Helpers. | |
# These functions exist to make it more convenient for you to carry out the | |
# model specification without dealing with unintuitive `R` syntax and naming | |
# conventions. You can ignore this section and focus on the steps that follow | |
# (i.e., the actual model specification and estimation). |
# Please run the code top to bottom and follow the comments. | |
# Task function with errors or warnings. | |
naughty_task <- function(error = TRUE, warning = FALSE) { | |
# If warning. | |
if (warning) { | |
warning("Warning thrown.") | |
} | |
# If error. |
# A function to quickly grasp the `CRAN` daily downloads. | |
plot_cran_downloads_trend <- function(package, x_axis_frequency = "3 months") { | |
# Packages required. | |
packages <- c("cranlogs", "mgcv", "curl", "ggplot2", "scales") | |
# Load required packages. | |
sapply(packages, function(pkg) { | |
# Require the package. | |
status <- suppressPackageStartupMessages(require(pkg, character.only = TRUE)) |
Install and run the Windows version of LatentGOLD 6.0 on a Mac device (Intel or Apple Silicon).
library(mgcv) | |
#library(modules) #devtools::install_github(klmr/modules) | |
#mgcv<-import_package("mgcv") | |
mspline<-function(x,y,k=10,lower=NA,upper=NA){ | |
#fits a monotonic spline to data | |
#small values of k= more smoothing (flatter curves) | |
#large values of k= more flexible (wiggly curves) | |
#k is related to effective degrees of freedom and number of knots | |
#use unconstrained gam to get rough parameter estimates |
# # # Scope of the issue: | |
# | |
# - without the following line `object$parent_env <- environment()` (i.e., line 54 below), it throws an error: | |
# - `Error in { : task 1 failed - "object 'Work' not found"`. | |
# | |
# - I would like to know: | |
# 1. what are some potential pitfalls when assigning the `parent_env` inside `foreach` | |
# 2. why does it work in the first place | |
# Minimal reproducible example: |