Skip to content

Instantly share code, notes, and snippets.

View wleoncio's full-sized avatar

Waldir Leoncio wleoncio

  • University of Oslo
  • Oslo
View GitHub Profile
@wleoncio
wleoncio / chemistry_quiz.c
Last active May 14, 2025 08:22
Example files for NRSE 2025
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*
* Chemistry Quiz Game
*
* This program is a simple console-based quiz game that tests the user's knowledge of chemistry.
* The game consists of a series of multiple-choice questions, each with four possible answers.
* Players must select the correct option (A, B, C, or D) to score points. The quiz contains five
@wleoncio
wleoncio / issue-114.R
Last active April 10, 2025 09:48
Testing a solution to issue 114 (TruncExpFam)
# Constants
max_si <- 100000L
tolerances <- c(0, 1e-9)
# Load required packages, create testing function
library(parallel)
test_me <- function(si, quiet = TRUE, fam = "chisq", tolerance = 0) {
set.seed(si)
results <- c()
@wleoncio
wleoncio / nlambda_eq_2.R
Created August 20, 2024 12:15
MADMMplasso issue 54
# Setting up objects =========================================================
set.seed(1235)
N <- 100
p <- 50
nz <- 4
K <- nz
X <- matrix(rnorm(n = N * p), nrow = N, ncol = p)
mx <- colMeans(X)
sx <- sqrt(apply(X, 2, var))
X <- scale(X, mx, sx)
@wleoncio
wleoncio / BayesSurvive_2S.R
Created August 19, 2024 04:26
BayesSurvive 2 sub-groups
s
)
)
# Run a Bayesian Cox model
## Initial value: null model without covariates
initial <- list("gamma.ini" = rep(0, ncol(dataset$X)))
initial_2S <- list(
initial,
list("gamma.ini" = rep(0, ncol(dataset_2S[[2]]$X)))
@wleoncio
wleoncio / readme-code-parallel.R
Last active August 16, 2024 09:42
MADMMplasso readme examples with `parallel = TRUE`
# Install and load the package, set the seed
remotes::install_github("ocbe-uio/MADMMplasso")
library(MADMMplasso)
set.seed(1235)
# Generate the data
N <- 100
p <- 50
nz <- 4
K <- nz
@wleoncio
wleoncio / readme_code.R
Last active June 25, 2024 12:51
README from MADMMplasso
# Install and load the package, set the seed
remotes::install_github("ocbe-uio/MADMMplasso@issue-17")
library(MADMMplasso)
set.seed(1235)
# Generate the data
N <- 100
p <- 50
nz <- 4
K <- nz
@wleoncio
wleoncio / issue50.md
Created April 24, 2024 13:04
Fix to issue #50
# Adapted from https://github.com/tmatta/lsasim/issues/50#issue-2254039296

# Package, Data and subset
remotes::install_github("tmatta/lsasim", "issue-50")
#> Using GitHub PAT from the git credential store.
#> Skipping install of 'lsasim' from a github remote, the SHA1 (28b71cf3) has not changed since last install.
#>   Use `force = TRUE` to force installation
library(lsasim)
#> This is lsasim 2.1.4-1713963651
@wleoncio
wleoncio / reprex.md
Created April 22, 2024 08:34
Issue 50 lsasim
# Setup
remotes::install_github("tmatta/lsasim", "issue-50")
#> Using GitHub PAT from the git credential store.
#> Downloading GitHub repo tmatta/lsasim@issue-50
#> 
#> ── R CMD build ─────────────────────────────────────────────────────────────────
#> * checking for file ‘/tmp/RtmpCKm8ak/remotes9c8f72a0c9f7/tmatta-lsasim-940c83a/DESCRIPTION’ ... OK
#> * preparing ‘lsasim’:
#> * checking DESCRIPTION meta-information ... OK
@wleoncio
wleoncio / test.R
Created March 20, 2024 10:32
Reducing calls to `solve()`
# Loading package ==============================================================
library("MADMMplasso")
message(paste("MADMMplasso version", packageVersion("MADMMplasso")))
# Loading data =================================================================
CRC_data <- readRDS("aux/CRC_data_300.rds") # change this manually, I won't bother with commandArgs()
X23 <- CRC_data$x
# log2 transfermation f or the expression levels
X1 <- (X23)
@wleoncio
wleoncio / issue-35.md
Created March 11, 2024 11:18
MADMMplasso issue 35
# Setup ========================================================================
rm(list = ls())
devtools::install_github("ocbe-uio/MADMMplasso", force = TRUE)
#> Downloading GitHub repo ocbe-uio/MADMMplasso@HEAD
#> 
#> ── R CMD build ─────────────────────────────────────────────────────────────────
#> * checking for file ‘/tmp/Rtmpr2fzD2/remotes149907717ef58/ocbe-uio-MADMMplasso-9896eeb/DESCRIPTION’ ... OK
#> * preparing ‘MADMMplasso’:
#> * checking DESCRIPTION meta-information ... OK