Commit 0dc30e0c authored by Jean-Benoist Leger's avatar Jean-Benoist Leger

Automatization of documatentation

parent 66a80566
......@@ -16,7 +16,7 @@
5. Edit src/Makevars, add -Wall to PKG_CPPFLAGS
6. Compile your code. As your modification are in .h files, you must touch the
file src/dispatcher.h at each recompilation to force recompilation.
file src/dispatcher.cc at each recompilation to force recompilation.
cd ..
touch blockmodels/src/dispatcher.cc
......@@ -32,5 +32,7 @@
8. Write R documentation file.
If you want to submit your model, example must be runnable.
You can write by hand your documentation file in man/ or write a
documentation file in orig_man using macros and run the script gen_man.
9. Set export of you model in NAMESPACE.
#!/bin/bash
for f in orig_man/*.Rd
do
perl orig_man/gen_man.pl $(basename $f)
done
......@@ -4,20 +4,13 @@
\description{
With the provided network and blockmodel type, estimate number of groups,
parameters and node membership}
\usage{BM_bernoulli(membership_type, adj, verbosity=4, autosave="", plotting=character(0))}
\usage{BM_bernoulli(membership_type, adj, verbosity=4, autosave='', plotting=character(0))}
\arguments{
\item{membership_type}{The type of node membership, e.g. "SBM", "SBM_sym", "LBM"}
\item{membership_type}{The type of node membership, i.e. 'SBM', 'SBM_sym' or 'LBM'}
\item{adj}{The adjacency matrix}
\item{verbosity}{The verbosity level, 0 means quiet, by default 4}
\item{autosave}{If \var{autosave} != "", after each estimation, the model
object is writed into file \var{autosave}. The model object
is readable by the function \var{readRDS}. Use-it for long
computation to allow restarting the estimation on system
crash.}
\item{plotting}{Control plot of ICL values while the estimation is running.
If plotting==character(0) (the default), plots are done on screen, if
plotting=="", no plot are done, if plotting is a filename, plots are
done in this filename.}
\item{verbosity}{The verbosity level, 0 means quiet. Level 1 display the phase of reinitialization. Level 2 display the level 1 and the ascending and descending phase for the number of groups. Level 3 display the level 2 and the number current number of groups which is estimated. Level 4 display the level 3 and the steps inside the estimation. Level 5 display the level 4 and unformations about ICL founds, and current status of parallel running jobs. Default is level 4.}
\item{autosave}{If var{autosave} != '', after each estimation, the model object is writed into file \var{autosave}. The model object is readable by the function \var{readRDS}. Use-it for long computation to allow restarting the estimation on system crash. You can use it to alanyze the partial results when the estimation is running.
\item{plotting}{Control plot of ICL values while the estimation is running. If plotting==character(0) (the default), plots are done on screen, if plotting=='', no plot are done, if plotting is a filename, plots are done in this filename.}
}
\examples{
......
......@@ -4,20 +4,13 @@
\description{
With the provided network and blockmodel type, estimate number of groups,
parameters and node membership}
\usage{BM_gaussian(membership_type, adj, verbosity=4, autosave="", plotting=character(0))}
\usage{BM_gaussian(membership_type, adj, verbosity=4, autosave='', plotting=character(0))}
\arguments{
\item{membership_type}{The type of node membership, e.g. "SBM", "SBM_sym", "LBM"}
\item{membership_type}{The type of node membership, i.e. 'SBM', 'SBM_sym' or 'LBM'}
\item{adj}{The adjacency matrix}
\item{verbosity}{The verbosity level, 0 means quiet, by default 4}
\item{autosave}{If \var{autosave} != "", after each estimation, the model
object is writed into file \var{autosave}. The model object
is readable by the function \var{readRDS}. Use-it for long
computation to allow restarting the estimation on system
crash.}
\item{plotting}{Control plot of ICL values while the estimation is running.
If plotting==character(0) (the default), plots are done on screen, if
plotting=="", no plot are done, if plotting is a filename, plots are
done in this filename.}
\item{verbosity}{The verbosity level, 0 means quiet. Level 1 display the phase of reinitialization. Level 2 display the level 1 and the ascending and descending phase for the number of groups. Level 3 display the level 2 and the number current number of groups which is estimated. Level 4 display the level 3 and the steps inside the estimation. Level 5 display the level 4 and unformations about ICL founds, and current status of parallel running jobs. Default is level 4.}
\item{autosave}{If var{autosave} != '', after each estimation, the model object is writed into file \var{autosave}. The model object is readable by the function \var{readRDS}. Use-it for long computation to allow restarting the estimation on system crash. You can use it to alanyze the partial results when the estimation is running.
\item{plotting}{Control plot of ICL values while the estimation is running. If plotting==character(0) (the default), plots are done on screen, if plotting=='', no plot are done, if plotting is a filename, plots are done in this filename.}
}
\examples{
......
......@@ -4,22 +4,13 @@
\description{
With the provided network and blockmodel type, estimate number of groups,
parameters and node membership}
\usage{BM_poisson(membership_type, adj, verbosity=4, autosave="", plotting=character(0))}
\usage{BM_poisson(membership_type, adj, verbosity=4, autosave='', plotting=character(0))}
\arguments{
\item{membership_type}{The type of node membership, e.g. "SBM", "SBM_sym", "LBM"}
\item{adj}{The wieghted adjacency matrix}
\item{verbosity}{The verbosity level, 0 means quiet, by default 4}
\item{plotlevel}{More level is higher more plot of found values (as ICL
criterion), each time there are computed, are done. 0 means no plot.}
\item{autosave}{If \var{autosave} != "", after each estimation, the model
object is writed into file \var{autosave}. The model object
is readable by the function \var{readRDS}. Use-it for long
computation to allow restarting the estimation on system
crash.}
\item{plotting}{Control plot of ICL values while the estimation is running.
If plotting==character(0) (the default), plots are done on screen, if
plotting=="", no plot are done, if plotting is a filename, plots are
done in this filename.}
\item{membership_type}{The type of node membership, i.e. 'SBM', 'SBM_sym' or 'LBM'}
\item{adj}{The adjacency matrix}
\item{verbosity}{The verbosity level, 0 means quiet. Level 1 display the phase of reinitialization. Level 2 display the level 1 and the ascending and descending phase for the number of groups. Level 3 display the level 2 and the number current number of groups which is estimated. Level 4 display the level 3 and the steps inside the estimation. Level 5 display the level 4 and unformations about ICL founds, and current status of parallel running jobs. Default is level 4.}
\item{autosave}{If var{autosave} != '', after each estimation, the model object is writed into file \var{autosave}. The model object is readable by the function \var{readRDS}. Use-it for long computation to allow restarting the estimation on system crash. You can use it to alanyze the partial results when the estimation is running.
\item{plotting}{Control plot of ICL values while the estimation is running. If plotting==character(0) (the default), plots are done on screen, if plotting=='', no plot are done, if plotting is a filename, plots are done in this filename.}
}
\examples{
......
......@@ -5,20 +5,14 @@ aith covariates}
\description{
With the provided network and blockmodel type, estimate number of groups,
parameters and node membership, and impact vector of covariates}
\usage{BM_poisson_covariates(membership_type, adj, verbosity=4, autosave="", plotting=caracter(0))}
\usage{BM_poisson_covariates(membership_type, adj, covariates, verbosity=4, autosave='', plotting=character(0))}
\arguments{
\item{membership_type}{The type of node membership, e.g. "SBM", "SBM_sym", "LBM"}
\item{adj}{The wieghted adjacency matrix}
\item{verbosity}{The verbosity level, 0 means quiet, by default 4}
\item{autosave}{If \var{autosave} != "", after each estimation, the model
object is writed into file \var{autosave}. The model object
is readable by the function \var{readRDS}. Use-it for long
computation to allow restarting the estimation on system
crash.}
\item{plotting}{Control plot of ICL values while the estimation is running.
If plotting==character(0) (the default), plots are done on screen, if
plotting=="", no plot are done, if plotting is a filename, plots are
done in this filename.}
\item{membership_type}{The type of node membership, i.e. 'SBM', 'SBM_sym' or 'LBM'}
\item{adj}{The adjacency matrix}
\item{covariates}{Covariates matrix, or list of covariates matrices. Covariates matrix must have the same size than the adjacency matrix.}
\item{verbosity}{The verbosity level, 0 means quiet. Level 1 display the phase of reinitialization. Level 2 display the level 1 and the ascending and descending phase for the number of groups. Level 3 display the level 2 and the number current number of groups which is estimated. Level 4 display the level 3 and the steps inside the estimation. Level 5 display the level 4 and unformations about ICL founds, and current status of parallel running jobs. Default is level 4.}
\item{autosave}{If var{autosave} != '', after each estimation, the model object is writed into file \var{autosave}. The model object is readable by the function \var{readRDS}. Use-it for long computation to allow restarting the estimation on system crash. You can use it to alanyze the partial results when the estimation is running.
\item{plotting}{Control plot of ICL values while the estimation is running. If plotting==character(0) (the default), plots are done on screen, if plotting=='', no plot are done, if plotting is a filename, plots are done in this filename.}
}
\examples{
......
\name{BM_bernoulli}
\alias{BM_bernoulli}
\title{Perform estimation on blockmodels for bernoulli probability distribution}
\description{
With the provided network and blockmodel type, estimate number of groups,
parameters and node membership}
\usage{BM_bernoulli(MEMBERSHIP_ARG, SCALAR_MODEL_ARG, MODEL_ARG)}
\arguments{
MEMBERSHIP_ARG_ITEM
SCALAR_MODEL_ARG_ITEM
MODEL_ARG_ITEM
}
\examples{
##
## SBM
##
## generation of one SBM network
Z<-matrix(1,20,1)\%x\%diag(4)
P<-matrix(runif(16),4,4)
M<-1*(matrix(runif(80*80),80,80)<Z\%*\%P\%*\%t(Z)) ## adjacency matrix
## estimation
my_model <- BM_bernoulli("SBM",M)
my_model$estimate()
which.max(my_model$ICL)
##
## SBM symmetric
##
## generation of one SBM_sym network
Z<-matrix(1,20,1)\%x\%diag(4)
P<-matrix(runif(16),4,4)
P[lower.tri(P)]<-t(P)[lower.tri(P)]
M<-1*(matrix(runif(80*80),80,80)<Z\%*\%P\%*\%t(Z))
M[lower.tri(M)]<-t(M)[lower.tri(M)]
## estimation
my_model <- BM_bernoulli("SBM_sym",M)
my_model$estimate()
which.max(my_model$ICL)
##
## LBM
##
## generation of one LBM network
Z1<-matrix(1,20,1)\%x\%diag(3)
Z2<-matrix(1,25,1)\%x\%diag(6)
P<-matrix(runif(18),3,6)
M<-1*(matrix(runif(60*150),60,150)<Z1\%*\%P\%*\%t(Z2)) ## adjacency matrix
## estimation
my_model <- BM_bernoulli("LBM",M)
my_model$estimate()
which.max(my_model$ICL)
}
\name{BM_gaussian}
\alias{BM_gaussian}
\title{Perform estimation on blockmodels for gaussian probability distribution}
\description{
With the provided network and blockmodel type, estimate number of groups,
parameters and node membership}
\usage{BM_gaussian(MEMBERSHIP_ARG, SCALAR_MODEL_ARG, MODEL_ARG)}
\arguments{
MEMBERSHIP_ARG_ITEM
SCALAR_MODEL_ARG_ITEM
MODEL_ARG_ITEM
}
\examples{
##
## SBM
##
## generation of one SBM network
Z<-matrix(1,40,1)\%x\%diag(4)
Mu<-20*matrix(runif(16),4,4)
M<-matrix(rnorm(160*160,sd=10),160,160)+Z\%*\%Mu\%*\%t(Z) ## adjacency matrix
## estimation
my_model <- BM_gaussian("SBM",M)
my_model$estimate()
which.max(my_model$ICL)
##
## SBM symmetric
##
## generation of one SBM_sym network
Z<-matrix(1,40,1)\%x\%diag(4)
Mu<-20*matrix(runif(16),4,4)
Mu[lower.tri(Mu)]<-t(Mu)[lower.tri(Mu)]
M<-matrix(rnorm(160*160,sd=10),160,160)+Z\%*\%Mu\%*\%t(Z)
M[lower.tri(M)]<-t(M)[lower.tri(M)]
## estimation
my_model <- BM_gaussian("SBM_sym",M)
my_model$estimate()
which.max(my_model$ICL)
##
## LBM
##
## generation of one LBM network
Z1<-matrix(1,40,1)\%x\%diag(3)
Z2<-matrix(1,50,1)\%x\%diag(6)
Mu<-20*matrix(runif(18),3,6)
M<-matrix(rnorm(120*300,sd=20),120,300)+Z1\%*\%Mu\%*\%t(Z2) ## adjacency matrix
## estimation
my_model <- BM_gaussian("LBM",M)
my_model$estimate()
which.max(my_model$ICL)
}
\name{BM_poisson}
\alias{BM_poisson}
\title{Perform estimation on blockmodels for poisson probability distribution}
\description{
With the provided network and blockmodel type, estimate number of groups,
parameters and node membership}
\usage{BM_poisson(membership_type, SCALAR_MODEL_ARG, MODEL_ARG)}
\arguments{
MEMBERSHIP_ARG_ITEM
SCALAR_MODEL_ARG_ITEM
MODEL_ARG_ITEM
}
\examples{
#
# SBM
#
## generation of one SBM network
Z<-matrix(1,20,1)\%x\%diag(4)
L<-70*matrix(runif(16),4,4)
M_in_expectation<-Z\%*\%L\%*\%t(Z)
M<-matrix(
rpois(
length(as.vector(M_in_expectation)),
as.vector(M_in_expectation))
,80,80)
## estimation
my_model <- BM_poisson("SBM",M)
my_model$estimate()
which.max(my_model$ICL)
##
## SBM symmetric
##
## generation of one SBM_sym network
Z<-matrix(1,20,1)\%x\%diag(4)
L<-70*matrix(runif(16),4,4)
L[lower.tri(L)]<-t(L)[lower.tri(L)]
M_in_expectation<-Z\%*\%L\%*\%t(Z)
M<-matrix(
rpois(
length(as.vector(M_in_expectation)),
as.vector(M_in_expectation))
,80,80)
M[lower.tri(M)]<-t(M)[lower.tri(M)]
## estimation
my_model <- BM_poisson("SBM_sym",M)
my_model$estimate()
which.max(my_model$ICL)
##
## LBM
##
## generation of one LBM network
Z1<-matrix(1,20,1)\%x\%diag(3)
Z2<-matrix(1,25,1)\%x\%diag(6)
L<-70*matrix(runif(18),3,6)
M_in_expectation<-Z1\%*\%L\%*\%t(Z2)
M<-matrix(
rpois(
length(as.vector(M_in_expectation)),
as.vector(M_in_expectation))
,60,150)
## estimation
my_model <- BM_poisson("LBM",M)
my_model$estimate()
which.max(my_model$ICL)
}
\name{BM_poisson_covariates}
\alias{BM_poisson_covariates}
\title{Perform estimation on blockmodels for poisson probability distribution
aith covariates}
\description{
With the provided network and blockmodel type, estimate number of groups,
parameters and node membership, and impact vector of covariates}
\usage{BM_poisson_covariates(MEMBERSHIP_ARG, SCALAR_MODEL_ARG, COVARIATES_ARG, MODEL_ARG)}
\arguments{
MEMBERSHIP_ARG_ITEM
SCALAR_MODEL_ARG_ITEM
COVARIATES_ARG_ITEM
MODEL_ARG_ITEM
}
\examples{
##
## SBM
##
## generation of one SBM network
Z<-matrix(1,20,1)\%x\%diag(4)
L<-70*matrix(runif(16),4,4)
M_in_expectation_without_covariates<-Z\%*\%L\%*\%t(Z)
Y1 <- matrix(runif(80*80),80,80)
Y2 <- matrix(runif(80*80),80,80)
M_in_expectation<-M_in_expectation_without_covariates*exp(4.2*Y1-1.2*Y2)
M<-matrix(
rpois(
length(as.vector(M_in_expectation)),
as.vector(M_in_expectation))
,80,80)
## estimation
my_model <- BM_poisson_covariates("SBM",M,list(Y1,Y2))
my_model$estimate()
which.max(my_model$ICL)
##
## SBM symmetric
##
## generation of one SBM_sym network, we re-use one produced for SBM
Z<-matrix(1,20,1)\%x\%diag(4)
L<-70*matrix(runif(16),4,4)
L[lower.tri(L)]<-t(L)[lower.tri(L)]
M_in_expectation_without_covariates<-Z\%*\%L\%*\%t(Z)
Y1 <- matrix(runif(80*80),80,80)
Y2 <- matrix(runif(80*80),80,80)
Y1[lower.tri(Y1)]<-t(Y1)[lower.tri(Y1)]
Y2[lower.tri(Y2)]<-t(Y2)[lower.tri(Y2)]
M_in_expectation<-M_in_expectation_without_covariates*exp(4.2*Y1-1.2*Y2)
M<-matrix(
rpois(
length(as.vector(M_in_expectation)),
as.vector(M_in_expectation))
,80,80)
M[lower.tri(M)]<-t(M)[lower.tri(M)]
## estimation
my_model <- BM_poisson_covariates("SBM_sym",M,list(Y1,Y2))
my_model$estimate()
which.max(my_model$ICL)
##
## LBM
##
## generation of one LBM network
Z1<-matrix(1,20,1)\%x\%diag(3)
Z2<-matrix(1,25,1)\%x\%diag(6)
L<-70*matrix(runif(18),3,6)
M_in_expectation_without_covariates<-Z1\%*\%L\%*\%t(Z2)
Y1 <- matrix(runif(60*150),60,150)
Y2 <- matrix(runif(60*150),60,150)
M_in_expectation<-M_in_expectation_without_covariates*exp(4.2*Y1-1.2*Y2)
M<-matrix(
rpois(
length(as.vector(M_in_expectation)),
as.vector(M_in_expectation))
,60,150)
## estimation
my_model <- BM_poisson_covariates("LBM",M,list(Y1,Y2))
my_model$estimate()
which.max(my_model$ICL)
}
our %config;
$config{'MEMBERSHIP_ARG'} = "membership_type";
$config{'MODEL_ARG'} = "verbosity=4, autosave='', plotting=character(0)";
$config{'SCALAR_MODEL_ARG'} = "adj";
$config{'MEMBERSHIP_ARG_ITEM'} =
"\\item{membership_type}{The type of node membership, i.e. 'SBM', 'SBM_sym' or 'LBM'}";
$config{'MODEL_ARG_ITEM'} =
"\\item{verbosity}{The verbosity level, 0 means quiet. Level 1 display the phase of reinitialization. Level 2 display the level 1 and the ascending and descending phase for the number of groups. Level 3 display the level 2 and the number current number of groups which is estimated. Level 4 display the level 3 and the steps inside the estimation. Level 5 display the level 4 and unformations about ICL founds, and current status of parallel running jobs. Default is level 4.}\n".
"\\item{autosave}{If \var{autosave} != '', after each estimation, the model object is writed into file \\var{autosave}. The model object is readable by the function \\var{readRDS}. Use-it for long computation to allow restarting the estimation on system crash. You can use it to alanyze the partial results when the estimation is running.\n".
"\\item{plotting}{Control plot of ICL values while the estimation is running. If plotting==character(0) (the default), plots are done on screen, if plotting=='', no plot are done, if plotting is a filename, plots are done in this filename.}";
$config{'SCALAR_MODEL_ARG_ITEM'} =
"\\item{adj}{The adjacency matrix}";
$config{'COVARIATES_ARG'} = 'covariates';
$config{'COVARIATES_ARG_ITEM'} =
"\\item{covariates}{Covariates matrix, or list of covariates matrices. Covariates matrix must have the same size than the adjacency matrix.}";
#!/usr/bin/perl
require "orig_man/conf.pl";
my $man_name=$ARGV[0];
open(my $f,"<orig_man/$man_name");
my $man_content="";
while(<$f>)
{
$man_content.=$_;
}
close($f);
foreach my $key (keys(%config))
{
$man_content =~ s/[^A-Z_]\K$key(?=[^A-Z_])/$config{$key}/g;
}
open(my $g,">man/$man_name");
print $g $man_content;
close($g);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment