Skip to content
Snippets Groups Projects
Commit 49492918 authored by Seseke, David's avatar Seseke, David :floppy_disk:
Browse files

Init

parents
No related branches found
No related tags found
No related merge requests found
.envrc 0 → 100644
watch_file flake.nix
watch_file flake.lock
use flake . --impure
/.direnv/
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1716137900,
"narHash": "sha256-sowPU+tLQv8GlqtVtsXioTKeaQvlMz/pefcdwg8MvfM=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "6c0b7a92c30122196a761b440ac0d46d3d9954f1",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}
{
description = "Initial draft for flake-based Nix&R deployments.";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ ];
# see https://github.com/nix-community/poetry2nix/tree/master#api for more functions and examples.
pkgs = nixpkgs.legacyPackages.${system};
in
{
packages = {
default = self.packages.${system}.myapp;
};
devShells.default = pkgs.mkShell {
packages = with pkgs; [
R
rPackages.RSiena
];
};
});
}
#!/usr/bin/env Rscript
################################################################################
################################################################################
### file Test_RSiena_Installation.R
################################################################################
################################################################################
################################################################################
### Check if RSiena can be loaded and the main estimation algorithm ###
################################################################################
# load RSiena package
library(RSiena)
rsienaversion <- getNamespaceVersion("RSiena")
print(paste("RSiena version", rsienaversion, "could be loaded."))
# Use internal data set to test RSiena algorithm (in particular avgroup effect)
mynet <- sienaDependent(array(c(s502, s503), dim=c(50, 50, 2)))
mybeh <- sienaDependent(s50a[,2:3], type="behavior")
mydata <- sienaDataCreate(mynet, mybeh)
mymodel <- getEffects(mydata)
p <- 1
mymodel <- setEffect(mymodel,avGroup, name='mybeh', parameter=p, verbose=FALSE)
mycontrols <- sienaAlgorithmCreate(projname=NULL)
ans <- siena07(mycontrols, batch=TRUE, silent = TRUE, data=mydata, effects=mymodel)
print("RSiena::siena07 runs without error")
# Calculate the mean behavior to test any behavior effect statistic
mbh <- mean(mybeh)
# Calculate c_p for testing the average group parameter
c_p <- ifelse(p <= 0.5, 0, p - mbh)
# Check the target statistics
if (isFALSE(all.equal(sum(mybeh[,,2] - mbh), ans$targets[5]))){
stop("Linear shape target statistic is not correct")
}
if (isFALSE(all.equal(sum((mybeh[,,2] - mbh)^2), ans$targets[6]))){
stop("Quadratic shape target statistic is not correct")
}
if (isFALSE(all.equal(sum((mybeh[,,2]-mbh)*(mean((mybeh[,,2]-mbh))-c_p)), ans$targets[7]))){
stop("Average Group target statistic is not correct")
}
print("Target statistics have been calculated correctly")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment