Skip to content

Commit

Permalink
Some update
Browse files Browse the repository at this point in the history
  • Loading branch information
thongphamthe committed Jul 5, 2017
1 parent b9e295a commit e4cedc2
Show file tree
Hide file tree
Showing 19 changed files with 481 additions and 34 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ os:
- linux
- osx

compiler:
- gcc

cache: packages

r_github_packages:
Expand Down
28 changes: 14 additions & 14 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,58 @@
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

.normalized_constant <- function(norm, degree, theta, f, offset_tk, offset) {
.Call('PAFit_normalized_constant', PACKAGE = 'PAFit', norm, degree, theta, f, offset_tk, offset)
.Call(PAFit_normalized_constant, norm, degree, theta, f, offset_tk, offset)
}

.normalized_constant_alpha <- function(norm, alpha, PA_offset, degree, theta, f, offset_tk, offset) {
.Call('PAFit_normalized_constant_alpha', PACKAGE = 'PAFit', norm, alpha, PA_offset, degree, theta, f, offset_tk, offset)
.Call(PAFit_normalized_constant_alpha, norm, alpha, PA_offset, degree, theta, f, offset_tk, offset)
}

.get_stats <- function(time_stamp, unique_stamp, in_node, out_node, all_node, ok_node, bin_vector, max_node_id, undirected, only_PA, time_vector, Sum_m_k, n_tk, m_tk, m_t, offset_tk, z_j, node_degree, offset_m_tk, only_true_deg, deg_max, center_bin, appear_time) {
.Call('PAFit_get_stats', PACKAGE = 'PAFit', time_stamp, unique_stamp, in_node, out_node, all_node, ok_node, bin_vector, max_node_id, undirected, only_PA, time_vector, Sum_m_k, n_tk, m_tk, m_t, offset_tk, z_j, node_degree, offset_m_tk, only_true_deg, deg_max, center_bin, appear_time)
.Call(PAFit_get_stats, time_stamp, unique_stamp, in_node, out_node, all_node, ok_node, bin_vector, max_node_id, undirected, only_PA, time_vector, Sum_m_k, n_tk, m_tk, m_t, offset_tk, z_j, node_degree, offset_m_tk, only_true_deg, deg_max, center_bin, appear_time)
}

.update_f <- function(f, non_zero_f, degree, theta, z_j, normalized_const, m_t, shape, rate, offset) {
.Call('PAFit_update_f', PACKAGE = 'PAFit', f, non_zero_f, degree, theta, z_j, normalized_const, m_t, shape, rate, offset)
.Call(PAFit_update_f, f, non_zero_f, degree, theta, z_j, normalized_const, m_t, shape, rate, offset)
}

.update_offset <- function(offset_n_tk, offset_m_tk, theta, normalized_const, m_t, shape, rate) {
.Call('PAFit_update_offset', PACKAGE = 'PAFit', offset_n_tk, offset_m_tk, theta, normalized_const, m_t, shape, rate)
.Call(PAFit_update_offset, offset_n_tk, offset_m_tk, theta, normalized_const, m_t, shape, rate)
}

.update_f_alpha <- function(f, non_zero_f, alpha, PA_offset, degree, theta, z_j, normalized_const, m_t, shape, rate) {
.Call('PAFit_update_f_alpha', PACKAGE = 'PAFit', f, non_zero_f, alpha, PA_offset, degree, theta, z_j, normalized_const, m_t, shape, rate)
.Call(PAFit_update_f_alpha, f, non_zero_f, alpha, PA_offset, degree, theta, z_j, normalized_const, m_t, shape, rate)
}

.update_f_new <- function(f, non_zero_f, degree, theta, z_j, normalized_const, m_t, shape, rate, offset, weight_f) {
.Call('PAFit_update_f_new', PACKAGE = 'PAFit', f, non_zero_f, degree, theta, z_j, normalized_const, m_t, shape, rate, offset, weight_f)
.Call(PAFit_update_f_new, f, non_zero_f, degree, theta, z_j, normalized_const, m_t, shape, rate, offset, weight_f)
}

.update_f_alpha_new <- function(f, non_zero_f, alpha, PA_offset, degree, theta, z_j, normalized_const, m_t, shape, rate, weight_f) {
.Call('PAFit_update_f_alpha_new', PACKAGE = 'PAFit', f, non_zero_f, alpha, PA_offset, degree, theta, z_j, normalized_const, m_t, shape, rate, weight_f)
.Call(PAFit_update_f_alpha_new, f, non_zero_f, alpha, PA_offset, degree, theta, z_j, normalized_const, m_t, shape, rate, weight_f)
}

.update_alpha_fast <- function(non_zero_theta, norm, f, PA_offset, theta, degree, m_t, Sum_m_k, offset_tk, offset, alpha_old) {
.Call('PAFit_update_alpha_fast', PACKAGE = 'PAFit', non_zero_theta, norm, f, PA_offset, theta, degree, m_t, Sum_m_k, offset_tk, offset, alpha_old)
.Call(PAFit_update_alpha_fast, non_zero_theta, norm, f, PA_offset, theta, degree, m_t, Sum_m_k, offset_tk, offset, alpha_old)
}

.var_alpha <- function(alpha, non_zero_theta, norm, f, PA_offset, theta, degree, m_t, Sum_m_k, offset_tk, offset) {
.Call('PAFit_var_alpha', PACKAGE = 'PAFit', alpha, non_zero_theta, norm, f, PA_offset, theta, degree, m_t, Sum_m_k, offset_tk, offset)
.Call(PAFit_var_alpha, alpha, non_zero_theta, norm, f, PA_offset, theta, degree, m_t, Sum_m_k, offset_tk, offset)
}

.coeff_theta <- function(degree, f, normalized_const, m_t, length_theta) {
.Call('PAFit_coeff_theta', PACKAGE = 'PAFit', degree, f, normalized_const, m_t, length_theta)
.Call(PAFit_coeff_theta, degree, f, normalized_const, m_t, length_theta)
}

.coeff_var <- function(degree, f, normalized_const, m_t, offset, length_theta) {
.Call('PAFit_coeff_var', PACKAGE = 'PAFit', degree, f, normalized_const, m_t, offset, length_theta)
.Call(PAFit_coeff_var, degree, f, normalized_const, m_t, offset, length_theta)
}

.cal_var_f <- function(cov_f, non_zero_f, degree, theta, f, z_j, normalized_const, m_t, shape) {
.Call('PAFit_cal_var_f', PACKAGE = 'PAFit', cov_f, non_zero_f, degree, theta, f, z_j, normalized_const, m_t, shape)
.Call(PAFit_cal_var_f, cov_f, non_zero_f, degree, theta, f, z_j, normalized_const, m_t, shape)
}

.cal_var_f_new <- function(cov_f, non_zero_f, degree, theta, f, z_j, normalized_const, m_t, shape, weight_f) {
.Call('PAFit_cal_var_f_new', PACKAGE = 'PAFit', cov_f, non_zero_f, degree, theta, f, z_j, normalized_const, m_t, shape, weight_f)
.Call(PAFit_cal_var_f_new, cov_f, non_zero_f, degree, theta, f, z_j, normalized_const, m_t, shape, weight_f)
}

4 changes: 2 additions & 2 deletions R/print.CV_Result.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
print.CV_Result <- function(x,...){
cat("\nContaining the cross validation result. \n");
if (!is.null(x$s_optimal))
print(paste0("Optimal r parameter is: ", x$r_optimal));
cat(paste0("Optimal r parameter is: ", x$r_optimal, "\n"));
if (!is.null(x$s_optimal))
print(paste0("Optimal s parameter is: ", x$s_optimal));
cat(paste0("Optimal s parameter is: ", x$s_optimal, "\n"));
}
4 changes: 2 additions & 2 deletions R/summary.CV_Result.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
summary.CV_Result <- function(object,...){
cat("\nContaining the cross validation result. \n");
if (!is.null(object$r_optimal))
print(paste0("Optimal r parameter is: ",object$r_optimal));
cat(paste0("Optimal r parameter is: ",object$r_optimal, "\n"));
if (!is.null(object$s_optimal))
print(paste0("Optimal s parameter is: ",object$s_optimal));
cat(paste0("Optimal s parameter is: ",object$s_optimal, "\n"));
}
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ environment:
USE_RTOOLS: true

build_script:
- travis-tool.sh install_github hadley/devtools
- travis-tool.sh install_github hadley/devtools, TRUE
- travis-tool.sh install_github cran/RColorBrewer
- travis-tool.sh install_github cran/VGAM
- travis-tool.sh install_github HenrikBengtsson/R.rsp
Expand Down
9 changes: 0 additions & 9 deletions man/PAFit-package.Rd
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
\name{PAFit-package}
\alias{PAFit-package}
\alias{summary.CV_Data}
\alias{summary.PAFit_data}
\alias{summary.PAFit_result}
\alias{summary.CV_Result}
\alias{print.CV_Data}
\alias{print.PAFit_data}
\alias{print.PAFit_result}
\alias{print.CV_Result}
\alias{plot.PAFit_result}
\alias{PAFit}
\docType{package}
\title{Generative Mechanism Estimation in Temporal Complex Networks}
Expand Down
2 changes: 1 addition & 1 deletion man/joint_estimate.rd
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ joint_estimate(net_object ,
}

\value{
Outputs a list, which contains the following fields.
Outputs a \code{Full_PAFit_result} object, which is a list containing the following fields:
\itemize{
\item \code{cv_data}: a \code{CV_Data} object which contains the cross-validation data. Normally the user does not need to pay attention to this data.

Expand Down
2 changes: 1 addition & 1 deletion man/only_A_estimate.rd
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ only_A_estimate(net_object ,
}

\value{
Outputs a list, which contains the following fields.
Outputs a \code{Full_PAFit_result} object, which is a list containing the following fields:
\itemize{
\item \code{cv_data}: a \code{CV_Data} object which contains the cross-validation data. Normally the user does not need to pay attention to this data.

Expand Down
2 changes: 1 addition & 1 deletion man/only_F_estimate.rd
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ only_F_estimate(net_object ,
}

\value{
Outputs a list, which contains the following fields.
Outputs a \code{Full_PAFit_result} object, which is a list containing the following fields:
\itemize{
\item \code{cv_data}: a \code{CV_Data} object which contains the cross-validation data. Normally the user does not need to pay attention to this data.

Expand Down
103 changes: 103 additions & 0 deletions man/plot.PAFit_result.rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
\name{plot.PAFit_result}
\alias{plot.PAFit_result}
%- Also NEED an '\alias' for EACH other topic documented here.
\title{
Plotting the estimated attachment function and node fitness of a \code{PAFit_result} object
}
\description{
This function plots the estimated attachment function \eqn{A_k} and node fitness \eqn{eta_i}, together with additional information such as their confidence intervals or the estimated attachment exponent (\eqn{\alpha} when assuming \eqn{A_k = k^\alpha}) of a \code{PAFit_result} object. This object is stored in the field \code{$estimate_result} of a \code{Full_PAFit_result} object, which in turn is the returning value of \code{\link{only_A_estimate}}, \code{\link{only_F_estimate}} or \code{\link{joint_estimate}}.
}
\usage{
\method{plot}{PAFit_result}(x,
net_stat ,
true_f = NULL , plot = "A" , plot_bin = TRUE ,
line = FALSE , confidence = TRUE , high_deg_A = 1 ,
high_deg_f = 5 ,
shade_point = 0.5 , col_point = "grey25" , pch = 16 ,
shade_interval = 0.5 , col_interval = "lightsteelblue" , label_x = NULL ,
label_y = NULL ,
max_A = NULL , min_A = NULL , f_min = NULL ,
f_max = NULL , plot_true_degree = FALSE ,
...)
}
%- maybe also 'usage' for other objects documented here.
\arguments{
\item{x}{
An object of class \code{PAFit_result}.
}
\item{net_stat}{
An object of class \code{PAFit_data}, containing the summerized statistics.
}
\item{true_f}{
Vector. Optional parameter for the true value of node fitnesses (only available in simulated datasets). If this parameter is specified and \code{plot == "true_f"}, a plot of estimated \eqn{\eta} versus true \eqn{\eta} is produced (after a suitable rescaling of the estimated \eqn{f}).
}
\item{plot}{
String. Indicates which plot is produced.
\itemize{
\item If \code{"A"} then PA function is plotted.
\item If \code{"f"} then the histogram of estimated fitness is plotted.
\item If \code{"true_f"} then estimated fitness and true fitness are plotted together (require supplement of true fitness).
}
Default value is \code{"A"}.
}
\item{plot_bin}{Logical. If \code{TRUE} then only the center of each bin is plotted. Default is \code{TRUE}.}
\item{line}{
Logical. Indicates whether to plot the line fitted from the log-linear model or not. Default value is \eqn{TRUE}.
}
\item{confidence}{
Logical. Indicates whether to plot the confidence intervals of \eqn{A_k} and \eqn{eta_i} or not. If confidence == TRUE, a 2-sigma confidence interval will be plotted at each \eqn{A_k} and \eqn{eta_i}.
}
\item{high_deg_A}{Integer. The estimated PA function is plotted starting from \code{high_deg_A}. Default value is \code{1}.}

\item{high_deg_f}{Integer. If \code{plot == "true_f"}, only nodes whose number of edges acquired is not less than \code{high_deg_f} are plotted. Default value is \code{5}.}

\item{col_point}{String. The name of the color of the points. Default value is \code{"black"}.}

\item{shade_point}{
Numeric. Value between 0 and 1. This is the transparency level of the points. Default value is \code{0.5}.
}
\item{pch}{Numeric. The plot symbol. Default value is \code{16}.}
\item{shade_interval}{
Numeric. Value between 0 and 1. This is the transparency level of the confidence intervals. Default value is \code{0.5}.
}
\item{max_A}{Numeric. Specify the maximum of the axis of PA.}
\item{min_A}{Numeric. Specify the minimum of the axis of PA.}
\item{f_min}{Numeric. Specify the minimum of the axis of fitness.}
\item{f_max}{Numeric. Specify the maximum of the axis of fitness.}
\item{plot_true_degree}{Logical. The degree of each node is plotted or not.}
\item{label_x}{String. The label of x-axis.}
\item{label_y}{String. The label of y-axis.}
\item{col_interval}{String. The name of the color of the confidence intervals. Default value is \code{"lightsteelblue"}.}

\item{\dots}{
%% ~~Describe \code{\dots} here~~
}
}


\value{
Outputs the desired plot.
}
\author{
Thong Pham \email{thongpham@thongpham.net}
}
\examples{
## Since the runtime is long, we do not let this example run on CRAN
\dontrun{
library("PAFit")
set.seed(1)
# a network from Bianconi-Barabasi model
net <- generate_BB(N = 1000 , m = 50 ,
num_seed = 100 , multiple_node = 100,
s = 10)
net_stats <- get_statistics(net)
result <- joint_estimate(net, net_stats)
#plot A
plot(result$estimate_result , net_stats , plot = "A")
true_A <- c(1,result$estimate_result$center_k[-1])
lines(result$estimate_result$center_k + 1 , true_A , col = "red") # true line
legend("topleft" , legend = "True function" , col = "red" , lty = 1 , bty = "n")
#plot true_f
plot(result, net_stats , net$fitness, plot = "true_f")
}
}
44 changes: 44 additions & 0 deletions man/print.CV_Result.rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
\name{print.CV_Result}
\alias{print.CV_Result}
%- Also NEED an '\alias' for EACH other topic documented here.
\title{
Printing simple information of the cross-validation result
}
\description{
This function prints simple information of the cross-validation result stored in a \code{CV_Result} object. This object is the field \code{$cv_result} of a \code{Full_PAFit_result} object, which in turn is the returning value of \code{\link{only_A_estimate}}, \code{\link{only_F_estimate}} or \code{\link{joint_estimate}}.
}
\usage{
\method{print}{CV_Result}(x,...)
}
%- maybe also 'usage' for other objects documented here.
\arguments{
\item{x}{
An object of class \code{CV_Result}.
}

\item{\dots}{
%% ~~Describe \code{\dots} here~~
}
}


\value{
Prints simple information of the cross-validation result.
}
\author{
Thong Pham \email{thongpham@thongpham.net}
}
\examples{
## Since the runtime is long, we do not let this example run on CRAN
\dontrun{
library("PAFit")
set.seed(1)
# a network from Bianconi-Barabasi model
net <- generate_BB(N = 1000 , m = 50 ,
num_seed = 100 , multiple_node = 100,
s = 10)
net_stats <- get_statistics(net)
result <- joint_estimate(net, net_stats)
print(result$cv_result)
}
}
44 changes: 44 additions & 0 deletions man/print.CV_data.rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
\name{print.CV_Data}
\alias{print.CV_Data}
%- Also NEED an '\alias' for EACH other topic documented here.
\title{
Printing simple information of the cross-validation data
}
\description{
This function prints simple information of the cross-validation data stored in a \code{CV_Data} object. This object is the field \code{$cv_data} of a \code{Full_PAFit_result} object, which in turn is the returning value of \code{\link{only_A_estimate}}, \code{\link{only_F_estimate}} or \code{\link{joint_estimate}}.
}
\usage{
\method{print}{CV_Data}(x,...)
}
%- maybe also 'usage' for other objects documented here.
\arguments{
\item{x}{
An object of class \code{CV_Data}.
}

\item{\dots}{
%% ~~Describe \code{\dots} here~~
}
}


\value{
Prints simple information of the cross-validation data.
}
\author{
Thong Pham \email{thongpham@thongpham.net}
}
\examples{
## Since the runtime is long, we do not let this example run on CRAN
\dontrun{
library("PAFit")
set.seed(1)
# a network from Bianconi-Barabasi model
net <- generate_BB(N = 1000 , m = 50 ,
num_seed = 100 , multiple_node = 100,
s = 10)
net_stats <- get_statistics(net)
result <- joint_estimate(net, net_stats)
print(result$cv_data)
}
}
43 changes: 43 additions & 0 deletions man/print.PAFit_data.rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
\name{print.PAFit_data}
\alias{print.PAFit_data}
%- Also NEED an '\alias' for EACH other topic documented here.
\title{
Printing simple information on the statistics of the network stored in a \code{PAFit_data} object
}
\description{
This function prints simple information of the statistics stored in a \code{PAFit_data} object. This object is the returning value of \code{\link{get_statistics}}.
}
\usage{
\method{print}{PAFit_data}(x,...)
}
%- maybe also 'usage' for other objects documented here.
\arguments{
\item{x}{
An object of class \code{PAFit_data}.
}

\item{\dots}{
%% ~~Describe \code{\dots} here~~
}
}


\value{
Prints simple information of the network statistics.
}
\author{
Thong Pham \email{thongpham@thongpham.net}
}
\examples{
## Since the runtime is long, we do not let this example run on CRAN
\dontrun{
library("PAFit")
set.seed(1)
# a network from Bianconi-Barabasi model
net <- generate_BB(N = 1000 , m = 50 ,
num_seed = 100 , multiple_node = 100,
s = 10)
net_stats <- get_statistics(net)
print(net_stats)
}
}
Loading

0 comments on commit e4cedc2

Please sign in to comment.