Skip to content

Commit

Permalink
version 2.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Cornu authored and cran-robot committed Mar 16, 2016
1 parent 0d09034 commit ec183e7
Show file tree
Hide file tree
Showing 33 changed files with 209 additions and 127 deletions.
19 changes: 11 additions & 8 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
Package: SCGLR
Type: Package
Title: Supervised Component Generalized Linear Regression
Version: 2.0.2
Date: 2014-02-21
Version: 2.0.3
Date: 2016-03-07
Authors@R: c(
person("Guillaume", "Cornu", role=c("cre","aut"),email="gcornu@cirad.fr"),
person("Frederic", "Mortier", role="aut", email="fmortier@cirad.fr"),
person("Catherine", "Trottier", role="aut", email="catherine.trottier@univ-montp3.fr"),
person("Xavier", "Bry", role="aut", email="xavier.bry@univ-montp2.fr"))
Description: The Fisher Scoring Algorithm is extended so as to combine Partial Least Squares
regression with Generalized Linear Model estimation in the multivariate context.
Description: The Fisher Scoring Algorithm is extended so as to combine Partial
Least Squares regression with Generalized Linear Model estimation in the
multivariate context.
License: CeCILL-2 | GPL-2
Depends: R (>= 3.0.0)
Imports: Matrix,Formula,expm,graphics,ggplot2,grid,pROC
Imports: Matrix,Formula,expm,graphics,grid,ggplot2 (>=
2.0.0),pROC,scales
Suggests: parallel,gridExtra,knitr
LazyData: yes
VignetteBuilder: knitr
Packaged: 2015-02-16 15:21:24 UTC; cornu
RoxygenNote: 5.0.1
NeedsCompilation: no
Packaged: 2016-03-16 15:36:12 UTC; cornu
Author: Guillaume Cornu [cre, aut],
Frederic Mortier [aut],
Catherine Trottier [aut],
Xavier Bry [aut]
Maintainer: Guillaume Cornu <gcornu@cirad.fr>
NeedsCompilation: no
Repository: CRAN
Date/Publication: 2015-02-16 17:45:46
Date/Publication: 2016-03-16 18:16:10
64 changes: 32 additions & 32 deletions MD5
Original file line number Diff line number Diff line change
@@ -1,56 +1,56 @@
f9bcb4976f157950ef97c4b1f226e687 *DESCRIPTION
dbde8a37f4c7fb6a9efecd3f12287875 *NAMESPACE
b89bab137bd1feaad34216cd2df44180 *NEWS
db31a13cecd4b6d470a1befe62a75351 *DESCRIPTION
4ba9c634508ab826c4382c5afaa44e73 *NAMESPACE
b14af99c4d1645c166b7bcc169884a74 *NEWS
fe407b16523faae1e21b97df7b7602ce *R/critConvergence.r
f7270f67b2a5ec01b786ce271a351dff *R/customize.r
c769fb69d1872f5bd808b5c35d5692a9 *R/data.r
f4253e5a2d3920e298ce31e34d0c4fe5 *R/f2x.r
a646dc9a8fb3aa5e6b8160b265e59fca *R/infoCriterion.r
2c64c6e90446cd513ea941d2382a6f8b *R/infoCriterion.r
3dbdb5168b05e9ec4e0da2776475ec4d *R/ingUtils.r
0349b37413d57e6d921c8d43efcc7eee *R/kComponents.r
4ba7230033c3a7490d0dd9cc79e2bd15 *R/methods.r
7bd55b5f836056a7a58f73375bf2d055 *R/metric.r
e1c5c0463afa92947f89b4bc9d45b53b *R/metric.r
e15ec931f554e11541a96ff4ee1e99f5 *R/multivariateFormula.r
26ff07ca0c50f66a4007594d68b2f46b *R/multivariateGlm.fit.r
a41599c03c0d126edecb0dca6bbd7a9d *R/multivariateGlm.r
476413c3061140b69bae791da7bc28c9 *R/multivariatePredictGlm.r
06aec9e8efcba1d2329a42797f7167e9 *R/multivariateGlm.fit.r
22771fc611fbe00de6de88f2ea8effa9 *R/multivariateGlm.r
ee5f8640fae5c3618002c4df0fb2404b *R/multivariatePredictGlm.r
658856a3e97ad270dcec6757f531fe5d *R/oneComponent.r
af3562bfd9a5f7d37359be6780899f5c *R/package.r
40bd86d9973e18d9cf60fd32fca625c8 *R/plot.r
ce526cb03a60470bb399ad4db6d8c89d *R/package.r
c28e5a9b122be63d02e32467fafc603b *R/plot.r
6b6c89a00bd175b725611565e868f1dd *R/print.r
f0e3d52b7a0e6868e7ee81991ac06c8c *R/scglr.r
fb8926305414a78135bf96b4f4a59e22 *R/scglrCrossVal.r
3d486ffb933f86ee95ff48460220f5f1 *R/summary.r
095ccd6b8d8b9434f8a71fbd7c3d52d9 *R/scglr.r
0e536fcc9b4828613ab2f6a136279204 *R/scglrCrossVal.r
7f0cf1c70134e4606b0b8be533447965 *R/summary.r
6134b8018a01f25abdacad8439433b4b *R/utils.r
a1baa945407de24483e5f6c5b0770ea4 *build/vignette.rds
f2fcc552a6233f3301847a057141801a *build/vignette.rds
b454e91b945abf3eaaa1d2ddf9c52cfc *data/genus.rda
7228f976812aee4fdd60f7ac760b4a43 *demo/00Index
7ff42f88c9d37c33feb1dea01efbeebe *demo/scglr.r
725274da96c067732984971ed539f43d *demo/scglrCrossVal.r
619f968ac2ad86861dcb639dcc703aa8 *demo/scglrPlots.r
bb881a7cd25753a10fb2af5b7b85beed *demo/scglrPrediction.r
c6e040e085bdd5205853378e106275d0 *inst/doc/scglrVignettes.R
2682315ff83e302194912d8c2fca551c *inst/doc/scglrVignettes.pdf
653cab14380859c07bed99b532c29f13 *inst/doc/scglrVignettes.R
4fb8b6c0594a58ade3a08a6696551e50 *inst/doc/scglrVignettes.pdf
0e57f56782f8048a2cf81a46c20af774 *inst/doc/scglrVignettes.rnw
725274da96c067732984971ed539f43d *inst/examples/exCrossVal.r
619f968ac2ad86861dcb639dcc703aa8 *inst/examples/exPlots.r
bb881a7cd25753a10fb2af5b7b85beed *inst/examples/exPrediction.r
7ff42f88c9d37c33feb1dea01efbeebe *inst/examples/exScglr.r
41b723814971ea3ae23c72e018592966 *man/barplot.SCGLR.Rd
942169004fe3d29b13b2aaa5254c059f *man/critConvergence.Rd
337143294908e9c7f41d07c76d1111f8 *man/customize.Rd
fae23e61ce55d56fd95088e3b002f572 *man/genus.Rd
885860d1502f83b3e5fa3fbccfe394cf *man/infoCriterion.Rd
d2d4758e6975a58f4bf0bfd12001edfd *man/method.Rd
e16c4519eac5481c61cb9593ca4f9290 *man/multivariateFormula.Rd
251425b7f53977e906245e2888d9cd87 *man/multivariateGlm.Rd
eb969fdb8b86ea9f364980dff2ce9fdc *man/multivariatePredictGlm.Rd
2e0383d57e3e9eba920110ba82172200 *man/pairs.SCGLR.Rd
56683bb246ae374589f4be164f91d254 *man/plot.SCGLR.Rd
b77acaeb5365ae2ae22568903f20c856 *man/print.SCGLR.Rd
63a59c5dff75029689a25dcae05ee672 *man/scglr-package.Rd
cf0386eb71df5bec37d842c3358a5dc3 *man/scglr.Rd
99bd0d94029e9d7d6001a1df89f57389 *man/scglrCrossVal.Rd
64a6acc2dfca6474d1978b4079eaf254 *man/summary.SCGLR.Rd
206778dfb44c78863d4c4d9378aa59ac *man/barplot.SCGLR.Rd
89b10c634cb3dccab7f0762c6c4f3cdd *man/critConvergence.Rd
65200f77b0a333685763c238aa357127 *man/customize.Rd
7461eef8fad93cd4ac157377ccf17192 *man/genus.Rd
47a337edb89a436f4a1028c3c993c43a *man/infoCriterion.Rd
23fea70f5b37cd428f5ef91ac344e863 *man/method.Rd
43c08f871673d7f1d661d8bc61507cf5 *man/multivariateFormula.Rd
5f1c2fdafac5921930a8e4da5222e462 *man/multivariateGlm.Rd
fb15281d171481ad3a0feb5c11a7b9a1 *man/multivariatePredictGlm.Rd
d867276eec5061ce9db9ceec190a98f5 *man/pairs.SCGLR.Rd
b1aff9203758ed32dd92ac307800c457 *man/plot.SCGLR.Rd
c59b7c2b1a1fa68d474ce4e19b2a6779 *man/print.SCGLR.Rd
41147a0a7a4d4ed29be57376c19947e9 *man/scglr-package.Rd
a745d02985c5e7130af05af1bba62976 *man/scglr.Rd
31dfe9c98b683b0ab27bb69b2728a287 *man/scglrCrossVal.Rd
aff812e2db18dc00f89e3404d9905ba8 *man/summary.SCGLR.Rd
3088a2c384aac3c5287caca92e3cbf07 *vignettes/bibScglr.bib
0e57f56782f8048a2cf81a46c20af774 *vignettes/scglrVignettes.rnw
21 changes: 19 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by roxygen2 (4.1.0): do not edit by hand
# Generated by roxygen2: do not edit by hand

S3method(barplot,SCGLR)
S3method(pairs,SCGLR)
Expand All @@ -19,7 +19,24 @@ export(scglrCrossVal)
import(Formula)
import(expm)
import(ggplot2)
import(grid)
import(pROC)
importFrom(Matrix,bdiag)
importFrom(graphics,barplot)
importFrom(grid,circleGrob)
importFrom(grid,gpar)
importFrom(grid,grid.layout)
importFrom(grid,grid.newpage)
importFrom(grid,pushViewport)
importFrom(grid,viewport)
importFrom(scales,percent_format)
importFrom(stats,aggregate)
importFrom(stats,as.formula)
importFrom(stats,coef)
importFrom(stats,cor)
importFrom(stats,dbinom)
importFrom(stats,dnorm)
importFrom(stats,dpois)
importFrom(stats,glm)
importFrom(stats,model.extract)
importFrom(stats,model.matrix)
importFrom(utils,combn)
5 changes: 5 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
* version 2.0.3
- added utils::globalVariables and @importFrom to keep CMD CHECK happy
- added plane parameter to barplot to have alternate coloring for selected components
- now require ggplot2 >= 2.0.0

* version 2.0.2
- fix bug in component optimization

Expand Down
2 changes: 2 additions & 0 deletions R/infoCriterion.r
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#' @title Function that calculates cross-validation selection criteria
#' @export
#' @importFrom stats dbinom dpois dnorm
#' @description Function that calculates cross-validation selection criteria
#' @param ynew data matrix corresponding to the observations used as test sample.
#' @param pred predicted value of the linear predictor obtained from Xnew and the estimated parameters.
#' @param family a vector of the same length as the number of responses containing characters
Expand Down
1 change: 1 addition & 0 deletions R/metric.r
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#@title Function that computes a submatrix of metric M^(-1/2)
#@export
#@param x the column vector of a regressor or factor
#' @importFrom stats model.matrix
metricBloc <- function(x){
z <- model.matrix(~x)[,-1,drop=FALSE]
z <- scale(z,center=TRUE,scale=FALSE)
Expand Down
1 change: 1 addition & 0 deletions R/multivariateGlm.fit.r
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#' @rdname multivariateGlm
#' @export
#' @importFrom stats as.formula glm
#' @param Y matrix of dependent variables.
#' @param comp matrix of covariates.
# @param family a vector of character giving the family distribution of each response
Expand Down
3 changes: 2 additions & 1 deletion R/multivariateGlm.r
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#' @description \code{multivariateGlm} is used to fit multivariate generalized linear models
#' specified by a symbolic formula together with the distributions of the responses.
#' This function performs a simple GLM fit for each dependent variable with the associated distribution.
#' @export
#' @export
#' @importFrom stats model.matrix model.extract
#' @param formula an object of class \code{Formula} (or one that can be coerced to that class): a symbolic description of the model to be fitted.
#' @param data the data frame to be modeled.
#' @param family a vector of character giving the family distribution of each response.
Expand Down
2 changes: 2 additions & 0 deletions R/multivariatePredictGlm.r
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#' @title Function that predicts the responses from the covariates for a new sample
#' @export
#' @importFrom stats as.formula model.matrix
#' @description Function that predicts the responses from the covariates for a new sample
#' @param Xnew a data frame containing the values of the covariates for the new sample.
#' @param family a vector of character specifying the distributions of the responses.
#' @param beta the matrix of coefficients estimated from the calibration sample.
Expand Down
2 changes: 1 addition & 1 deletion R/package.r
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#' @import Formula
#' @import expm
#' @importFrom graphics barplot
#' @import ggplot2 grid
#' @import ggplot2
#' @import pROC
NULL

Expand Down
74 changes: 61 additions & 13 deletions R/plot.r
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
# remove warnings due to ggplot2 syntax strangeness
utils::globalVariables(c("comp","y","label","angle","hjust"))
if(getRversion()>="2.15.1") {
# remove warnings due to ggplot2 syntax strangeness
utils::globalVariables(c("comp","y","label","angle","hjust"))
}


#' SCGLR generic plot
#' @export
#' @importFrom stats cor aggregate
#' @importFrom grid circleGrob gpar
#' @method plot SCGLR
#' @description SCGLR generic plot
#' @param x an object from SCGLR class.
#' @param \dots optional arguments (see \link{customize}).
#' @param style named list of values used to customize the plot (see \link{customize})
Expand Down Expand Up @@ -150,14 +156,21 @@ plot.SCGLR <- function(x, ..., style=getOption("plot.SCGLR"), plane=c(1,2)) {
# build base plot
p <- qplot((-1:1)*cust("expand",1.0), (-1:1)*cust("expand",1.0), geom="blank")+
coord_fixed()+
# thicker x unit arrow
xlab(paste(axis_names[1],"(",round(100*inertia[1],2),"%)")) +
geom_hline(yintercept=0)+
geom_segment(aes(x=-1.1,xend=1.1,y=0,yend=0),size=1,arrow=arrow(length=unit(0.02,"npc")))+
ylab(paste(axis_names[2],"(",round(100*inertia[2],2),"%)"))

if(observations) {
p <- p +
geom_hline(yintercept=0,size=0.5)+
geom_vline(xintercept=0,size=0.5)
}
if(covariates||predictors) {
p <- p +
# thicker x unit arrow
geom_segment(aes(x=-1.1,xend=1.1,y=0,yend=0),size=1,arrow=arrow(length=unit(0.02,"npc")))+
# thicker y unit arrow
ylab(paste(axis_names[2],"(",round(100*inertia[2],2),"%)")) +
geom_vline(xintercept=0)+
geom_segment(aes(y=-1.1,yend=1.1,x=0,xend=0),size=1,arrow=arrow(length=unit(0.02,"npc")))
geom_segment(aes(y=-1.1,yend=1.1,x=0,xend=0),size=1,arrow=arrow(length=unit(0.02,"npc")))
}

# plot title
if(has_cust("title", FALSE)) {
Expand Down Expand Up @@ -209,6 +222,8 @@ plot.SCGLR <- function(x, ..., style=getOption("plot.SCGLR"), plane=c(1,2)) {
alpha=cust("observations.alpha",1)
)
}
tmp <- data.frame(x=c(0,0),y=range(obs$y))
p <- p + geom_line(aes(x,y),data=tmp)
}

# add linear predictor arrows
Expand Down Expand Up @@ -364,7 +379,7 @@ plot.SCGLR <- function(x, ..., style=getOption("plot.SCGLR"), plane=c(1,2)) {

# draw labels ?
if(cust("factor.labels",TRUE)) {
p <- p + geom_text(
p <- p + geom_label(
aes_string(x="x",y="y",label=factor),
data=bary,
color=cust("factor.labels.color","black"),
Expand All @@ -380,20 +395,52 @@ plot.SCGLR <- function(x, ..., style=getOption("plot.SCGLR"), plane=c(1,2)) {
#' @title Barplot of percent of overall X variance captured by component
#' @export
#' @method barplot SCGLR
#' @description A custom plot for SCGLR objetcs
#' @param height object of class 'SCGLR', usually a result of running \code{\link{scglr}}.
#' @param \dots optional arguments.
#' @param plane a size-2 vector (or comma separated string) indicating which components are plotted (eg: c(1,2) or "1,2").
#' @return an object of class ggplot.
#' @seealso For barplot application see examples in \code{\link{plot.SCGLR}}.
barplot.SCGLR <- function(height, ...) {
inertia <- data.frame(inertia=height$inertia,comp=1:length(height$inertia))
qplot(comp, inertia, data=inertia, geom="bar", stat="identity", width=0.5) +
#' @importFrom scales percent_format
barplot.SCGLR <- function(height, ..., plane=NULL) {
if(!is.null(plane)) {
# process plane
if(is.character(plane)) {
plane <- as.integer(trim(unlist(strsplit(plane, ","))))
}

# sanity checking
if(length(plane) !=2 ) {
stop("Plane should have two components!")
}
if((min(plane)<1) || (max(plane)>length(height$inertia))) {
stop("Invalid components for plane!")
}
}

# build data frame from inertia
inertia <- data.frame(
inertia=height$inertia,
comp=1:length(height$inertia),
plane_color="black",
stringsAsFactors = F)

# recolor unused component in gray
if(!is.null(plane))
inertia$plane[-plane] <- "gray"

ggplot(data=inertia)+geom_bar(aes(comp,inertia),fill=inertia$plane,stat="identity",width=0.5) +
scale_x_discrete(labels=names(height$inertia),limits=1:length(inertia$comp))+
labs(x="Components", y="Inertia", title="Inertia per component\n", ...)
scale_y_continuous(labels=percent_format())+
labs(x="Components", y="Inertia", title="Inertia per component\n", ...)#+
#geom_text(aes(comp,inertia,label=round(100*inertia,2)),vjust=0)
}

#' @title Pairwise scglr plot on components
#' @export
#' @importFrom utils combn
#' @method pairs SCGLR
#' @description Pairwise scglr plot on components
#' @param x object of class 'SCGLR', usually a result of running \code{\link{scglr}}.
#' @param \dots optionally, further arguments forwarded to \code{link{plot.SCGLR}}.
#' @param nrow number of rows of the grid layout.
Expand Down Expand Up @@ -441,6 +488,7 @@ pairs.SCGLR <- function(x, ..., nrow=NULL, ncol=NULL, components=NULL) {
}

## equivalent du par pour les ggplot2
#' @importFrom grid viewport grid.newpage pushViewport viewport grid.layout
vp.layout <- function(x, y) viewport(layout.pos.row=x, layout.pos.col=y)
arrange <- function(..., nrow=NULL, ncol=NULL, as.table=FALSE) {
dots <- list(...)
Expand Down
5 changes: 5 additions & 0 deletions R/scglr.r
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
if(getRversion()>="2.15.1") {
utils::globalVariables(c("na.omit","coef"))
}

#' @title Function that fits the scglr model
#' @description Calculates the components to predict all the dependent variables.
#' @export scglr
#' @importFrom stats model.matrix model.extract coef cor
#' @param formula an object of class \code{Formula} (or one that can be coerced to that class): a symbolic description of the model to be fitted.
#' @param data a data frame to be modeled.
#' @param family a vector of character of the same length as the number of dependent variables:
Expand Down
5 changes: 5 additions & 0 deletions R/scglrCrossVal.r
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
if(getRversion()>="2.15.1") {
utils::globalVariables(c("na.omit","coef"))
}

#' Function that fits and selects the number of component by cross-validation.
#' @export
#' @importFrom stats model.matrix model.extract coef cor
#' @param formula an object of class "Formula" (or one that can be coerced to that class): a symbolic description of the model to be fitted.
#' @param data the data frame to be modeled.
#' @param family a vector of character of length q specifying the distributions of the responses. Bernoulli, binomial, poisson and gaussian are allowed.
Expand Down
2 changes: 2 additions & 0 deletions R/summary.r
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#' @export
#' @importFrom stats cor
#' @importFrom utils combn
#' @title Summarizing SCGLR fits
#' @description Summary method for class "SCGLR".
#' @method summary SCGLR
Expand Down
Binary file modified build/vignette.rds
Binary file not shown.

0 comments on commit ec183e7

Please sign in to comment.