R Under development (unstable) (2024-09-21 r87186 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > > library(glmm) Loading required package: trust Loading required package: mvtnorm Loading required package: Matrix Loading required package: parallel Loading required package: doParallel Loading required package: foreach Loading required package: iterators > > #First, define checks for bernoulli > cum <- function(eta){ + if(eta>0) eta+log1p(exp(-eta)) + else log1p(exp(eta))} > cum<-Vectorize(cum) > cp <- function(eta) {1/(1+exp(-eta))} > cpp<-function(eta) {(1/(1+exp(-eta)))*(1/(1+exp(eta)))} > > > #check cum3 for a vector containing both positive and negative values of eta > eta<-seq(-1,1,.1) > neta<-length(eta) > ntrials <- wts<-rep(1,neta) > that<-.C(glmm:::C_cum3,eta=as.double(eta),neta=as.integer(neta), type=as.integer(1), ntrials=as.integer(ntrials), wts=as.double(wts),cumout=double(1)) > all.equal(sum(cum(eta)),that$cumout) [1] TRUE > > #check cp3 > that<-.C(glmm:::C_cp3,eta=as.double(eta),neta=as.integer(neta),type=as.integer(1), ntrials=as.integer(ntrials), cpout=double(neta)) > all.equal(cp(eta),that$cpout) [1] TRUE > > #check cpp3 > that<-.C(glmm:::C_cpp3,eta=as.double(eta),neta=as.integer(neta),type=as.integer(1), ntrials=as.integer(ntrials), cppout=double(neta)) > all.equal(cpp(eta),that$cppout) [1] TRUE > > ###################### > #now move onto Poisson > cum <- function(eta) exp(eta) > cp <- function(eta) exp(eta) > cpp<-function(eta) exp(eta) > eta<-c(4.5,5,5.5) > neta<-length(eta) > ntrials <- wts<-rep(1,neta) > > #check cum3 > that<-.C(glmm:::C_cum3, eta=as.double(eta), neta=as.integer(neta), type=as.integer(2), ntrials=as.integer(ntrials), wts=as.double(wts), cumout=double(1)) > all.equal(sum(cum(eta)),that$cumout) [1] TRUE > > #check cp3 > that<-.C(glmm:::C_cp3,eta=as.double(eta), neta=as.integer(neta), type=as.integer(2), ntrials=as.integer(ntrials), cpout=double(neta)) > all.equal(cp(eta), that$cpout) [1] TRUE > > #check cpp3 > that<-.C(glmm:::C_cpp3,eta=as.double(eta),neta=as.integer(neta),type=as.integer(2), ntrials=as.integer(ntrials), cppout=double(neta)) > all.equal(cpp(eta), that$cppout) [1] TRUE > > > proc.time() user system elapsed 1.28 0.17 1.39