# Using minTriadicClosure in LOLOG Models

# Introduction

The `minTriadicClosure()` function defines a smoothed triadic closure statistic for use in LOLOG models. It counts how many nodes are part of at least `k` closed triangles, using a sigmoid function for smoothing.

# Integration with LOLOG

This statistic can be added to LOLOG model formulas. Below is an example using a small toy network.

    # Load required libraries
    library(MinTriadic)
    library(lolog)
    library(network)

    # Register the triadic change statistic
    registerMinTriadicClosure()

    # Load the Lazega collaboration network
    data(lazega, package = "lolog")

    # Fit LOLOG model with edges and minTriadicClosure
    model <- lolog(lazega ~ edges + minTriadicClosure(k = 2, alpha = 1.5), verbose = FALSE)

    ## Error in solve.default(var(auxStats)) :
    ##   Lapack routine dgesv: system is exactly singular: U[2,2] = 0

    ## Warning in lolog(lazega ~ edges + minTriadicClosure(k = 2, alpha = 1.5), :
    ## Singular statistic covariance matrix. Using diagnoal.

    ## Error in solve.default(var(auxStats)) :
    ##   Lapack routine dgesv: system is exactly singular: U[2,2] = 0

    ## Warning in lolog(lazega ~ edges + minTriadicClosure(k = 2, alpha = 1.5), :
    ## Singular statistic covariance matrix. Using diagnoal.

    ## Error in solve.default(var(auxStats)) :
    ##   Lapack routine dgesv: system is exactly singular: U[2,2] = 0

    ## Warning in lolog(lazega ~ edges + minTriadicClosure(k = 2, alpha = 1.5), :
    ## Singular statistic covariance matrix. Using diagnoal.

    ## Error in solve.default(var(auxStats)) :
    ##   Lapack routine dgesv: system is exactly singular: U[2,2] = 0

    ## Warning in lolog(lazega ~ edges + minTriadicClosure(k = 2, alpha = 1.5), :
    ## Singular statistic covariance matrix. Using diagnoal.

    ## Error in solve.default(var(auxStats)) :
    ##   Lapack routine dgesv: system is exactly singular: U[2,2] = 0

    ## Warning in lolog(lazega ~ edges + minTriadicClosure(k = 2, alpha = 1.5), :
    ## Singular statistic covariance matrix. Using diagnoal.

    ## Error in solve.default(var(auxStats)) :
    ##   Lapack routine dgesv: system is exactly singular: U[2,2] = 0

    ## Warning in lolog(lazega ~ edges + minTriadicClosure(k = 2, alpha = 1.5), :
    ## Singular statistic covariance matrix. Using diagnoal.

    ## Error in solve.default(var(auxStats)) :
    ##   Lapack routine dgesv: system is exactly singular: U[2,2] = 0

    ## Warning in lolog(lazega ~ edges + minTriadicClosure(k = 2, alpha = 1.5), :
    ## Singular statistic covariance matrix. Using diagnoal.

    ## Error in solve.default(var(auxStats)) :
    ##   Lapack routine dgesv: system is exactly singular: U[2,2] = 0

    ## Warning in lolog(lazega ~ edges + minTriadicClosure(k = 2, alpha = 1.5), :
    ## Singular statistic covariance matrix. Using diagnoal.

    # View model summary
    summary(model)

    ##                   observed_statistics     theta        se pvalue
    ## edges                             115  2.929975 0.7146951      0
    ## minTriadicClosure                  28 70.941143 5.4321625      0