Skip to content

Commit

Permalink
version 1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
G. Cornu authored and cran-robot committed Mar 18, 2014
1 parent 2bd23af commit d54781f
Show file tree
Hide file tree
Showing 53 changed files with 1,672 additions and 785 deletions.
29 changes: 13 additions & 16 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
Package: SCGLR
Type: Package
Title: Supervised Component Generalized Linear Regression (SCGLR)
Version: 1.1
Date: 2012-11-21
Version: 1.2
Date: 2014-02-21
Author: Mortier F., Trottier C., Cornu G., Bry X.
Maintainer: G. Cornu <gcornu@cirad.fr>
Contact: F. mortier <fmortier@cirad.fr> and G. Cornu <gcornu@cirad.fr>
and C. Trottier <catherine.trottier@univ-montp3.fr>
Maintainer: "G. Cornu" <gcornu@cirad.fr>
Contact: "F. Mortier" <fmortier@cirad.fr> and "G. Cornu"
<gcornu@cirad.fr> and "C. Trottier"
<catherine.trottier@univ-montp3.fr> and "X. Bry"
<xavier.bry@univ-montp2.fr>
Description: SCGLR extends the Fisher Scoring Algorithm so as to combine PLS
regression with GLM estimation in the multivariate context.
License: CeCILL-2
Depends: Formula,expm,ROCR,ggplot2
Imports: ggplot2,graphics,grid, stringr
Suggests: parallel,testthat
License: CeCILL-2 | GPL-2
Depends: R (>= 3.0.0)
Imports: Matrix,Formula,expm,graphics,ggplot2,grid,stringr,ROCR
Suggests: parallel
LazyData: yes
Collate: 'data.r' 'f2x.r' 'scglr.r' 'utils.r' 'plot.r' 'kComponents.r'
'multivariateGlm.fit.r' 'oneComponent.r' 'critConvergence.r'
'multivariateFormula.r' 'scglrCrossVal.r'
'multivariatePredictGlm.r' 'infoCriterion.r' 'metric.r'
'multivariateGlm.r' 'print.r' 'summary.r'
Packaged: 2013-08-01 10:54:11 UTC; cornu
Packaged: 2014-03-18 09:42:05 UTC; cornu
NeedsCompilation: no
Repository: CRAN
Date/Publication: 2013-08-01 13:58:25
Date/Publication: 2014-03-18 11:44:18
86 changes: 42 additions & 44 deletions MD5
Original file line number Diff line number Diff line change
@@ -1,52 +1,50 @@
cd877f4d121fddca68ea27123994f83d *DESCRIPTION
aa611912aad7c7c5b6ee97dbf9235114 *NAMESPACE
d16247931f88ded16fb00afdb9e3afbf *R/critConvergence.r
f5209b7d93d0cb2ff426ff79144019a4 *R/data.r
832f9d9e53b88274bd970f66826d957e *R/f2x.r
21ed50a3efc5a14b1064ac8049da47dc *R/infoCriterion.r
35c862bdd3a5200df45e37e4b572ca25 *R/kComponents.r
75a27bc0b0a4fff94aaca1ea37091b99 *R/metric.r
d22fbf85bd9b227c39ef41c235983581 *R/multivariateFormula.r
b9cb8f19ec765c9073892cc0449aebc0 *R/multivariateGlm.fit.r
fc612f54373b2db4ca9626a8f55f984a *R/multivariateGlm.r
4c82299d4fbd1e0ef6962cb9e73e4130 *R/multivariatePredictGlm.r
e24a82814b7bc947d4f30c93efc1835f *R/oneComponent.r
c863427f136e1c1118d15f0fd943fa55 *R/plot.r
89d07a9b80905ec09ef9375e77354384 *R/print.r
37331188923c048f0b74afbb142b1568 *R/scglr.r
306c95f7503e9257328387518fccbc6f *R/scglrCrossVal.r
f3ef6ed4b6e5f13f0ef09f6dec8d2ab6 *R/summary.r
024c193656421f4ccd65eb81359c531f *R/utils.r
22fafb0e29932530db904dc4ac769dd7 *DESCRIPTION
5b276e12421ccba73aedfbcff1fec732 *NAMESPACE
0e3e33861096acb17a23427da77d9780 *R/critConvergence.r
4f9de2b0fb5d5f8c406eb0c4ea45679f *R/data.r
e1545ea41fe2959052292b554d25d8ba *R/f2x.r
416bd61514d52323209a62dbd8916160 *R/infoCriterion.r
cdf86f32ce50c657a8999be3fbbe745a *R/kComponents.r
58868746ee7485ae4a561700bfde1369 *R/metric.r
632c86a07ea571b3d6fe36c841ec33f4 *R/multivariateFormula.r
26ff07ca0c50f66a4007594d68b2f46b *R/multivariateGlm.fit.r
3a5c41707e779dae512967e5583c3658 *R/multivariateGlm.r
1623faa4d4209c3440489386c65f04fd *R/multivariatePredictGlm.r
30464b02cb580afab80d14f59c3b7f02 *R/oneComponent.r
23a23a4be562ec875a37286a1cf48605 *R/package.r
70f8bba5c062a2f0a12832f1bd104277 *R/plot.r
262c34c9eef94d2fb02bdfd82191a6cb *R/print.r
79757bdb68af4becbcf1b1a8cabcaf5c *R/scglr.r
ad21d512066a8c0f81e1493d2d2e6773 *R/scglrCrossVal.r
b6a6a4fcd2d3a166d9c94c9ba06c6360 *R/summary.r
bc6ce52c4c87329eb6e0aeb4dcdaf977 *R/utils.r
dec380453004ab40ba23b0d57287da99 *build/vignette.rds
b454e91b945abf3eaaa1d2ddf9c52cfc *data/genus.rda
7228f976812aee4fdd60f7ac760b4a43 *demo/00Index
7ff42f88c9d37c33feb1dea01efbeebe *demo/scglr.r
725274da96c067732984971ed539f43d *demo/scglrCrossVal.r
619f968ac2ad86861dcb639dcc703aa8 *demo/scglrPlots.r
48f76694c3c4fb155d98846af530bf70 *demo/scglrPrediction.r
e52b9d7a956182d4006ca7e141e67c0a *inst/doc/index.html
d68073bb32e2ad6f6653784793d0eeee *inst/doc/scglrJss.pdf
f42b1d5ded8aac352618c1d24ab5d607 *demo/scglrPrediction.r
86646a041ca3f5e2be92496231802aae *inst/doc/scglrVignettes.R
7439805d8b7c345345eb8b09adb229c0 *inst/doc/scglrVignettes.pdf
16e8bebb00aab52f05f737a4d789c933 *inst/doc/scglrVignettes.rnw
725274da96c067732984971ed539f43d *inst/examples/exCrossVal.r
619f968ac2ad86861dcb639dcc703aa8 *inst/examples/exPlots.r
48f76694c3c4fb155d98846af530bf70 *inst/examples/exPrediction.r
f42b1d5ded8aac352618c1d24ab5d607 *inst/examples/exPrediction.r
7ff42f88c9d37c33feb1dea01efbeebe *inst/examples/exScglr.r
6ba2dcf16373185f6210a87b4412af9c *man/barplot.SCGLR.Rd
0b2a3368dc311b11961d40383d5d9df4 *man/critConvergence.Rd
817e3d77be9b91b141d178f0e7321593 *man/f2x.Rd
e518eb01227aa85a575128573edf6209 *man/genus.Rd
0e14990ab7b77cbaebda46965f521361 *man/infoCriterion.Rd
06cdf85b5ea3d922cd4aa9384004d5cf *man/kComponents.Rd
77d495773150608671851b92384577ab *man/metric.Rd
01114b16f8f7d038602a7a6f7b3d4167 *man/metricBloc.Rd
655b4573236a861a9759b57cd1e84ba3 *man/multivariateFormula.Rd
19139893f117e69d8aa6d843ecc3260b *man/multivariateGlm.Rd
3b62dc99b2ef035d1fc751d115bb32f0 *man/multivariateGlm.fit.Rd
0cd40195714681edbf9791fa584eaf17 *man/multivariatePredictGlm.Rd
d800e9139afd06158f43a9c3f2cdb8f9 *man/oneComponent.Rd
2e5ecbec80d447b6f30e86d834b9c493 *man/pairs.SCGLR.Rd
15b3fc8cc44677f6ea5161704bbe1dd4 *man/plot.SCGLR.Rd
c9a14368af5383c4d175388cf3a1a71b *man/print.SCGLR.Rd
9da8afeccf87037a24ef35aafc35f094 *man/scglr.Rd
296356d50a40ccccf0cfa17fae762f4c *man/scglrCrossVal.Rd
dcfdca164febe45cd241a4f7d4fd07e2 *man/summary.SCGLR.Rd
ca2a3472f67fcc1315026280468579d6 *man/wtCenter.Rd
2c2e17ac2e94d5ee2b6e6d1e47cc6d50 *man/wtScale.Rd
efe4660e89d3f7a8a48942377006d5e7 *man/barplot.SCGLR.Rd
d28e9af64ae418aae507b7f58bfc106b *man/critConvergence.Rd
d541c67056c9b94c0c6e811c77f6d977 *man/genus.Rd
84bf979373387ee46ecdae7dbbeade80 *man/infoCriterion.Rd
6587703cc35632041588eec0a83c2782 *man/multivariateFormula.Rd
3416d2207c1b015ca75148352cf0a6af *man/multivariateGlm.Rd
c42a9863f30ecb8d0e149007158017db *man/multivariatePredictGlm.Rd
8121d257d4e66c8a63a5194281c3f64d *man/pairs.SCGLR.Rd
30250ccd180a7a7a27ea042ba70b0119 *man/plot.SCGLR.Rd
3ecaa356e70e58defc59d8d7d274ad31 *man/print.SCGLR.Rd
a3049d54125a480aea8ec0d4199e7fd7 *man/scglr-package.Rd
11cfcd36bf73bcea83bf995e897bd2a9 *man/scglr.Rd
87c6c1f825baf63b53c4f4983bf4ea68 *man/scglrCrossVal.Rd
af77eb78cca2f9fdb5e7586307e1e883 *man/summary.SCGLR.Rd
3088a2c384aac3c5287caca92e3cbf07 *vignettes/bibScglr.bib
16e8bebb00aab52f05f737a4d789c933 *vignettes/scglrVignettes.rnw
14 changes: 6 additions & 8 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,21 @@ S3method(barplot,SCGLR)
S3method(pairs,SCGLR)
S3method(plot,SCGLR)
S3method(print,SCGLR)
S3method(print,summary.SCGLR)
S3method(summary,SCGLR)
export(critConvergence)
export(f2x)
export(infoCriterion)
export(kComponents)
export(metric)
export(metricBloc)
export(multivariateFormula)
export(multivariateGlm)
export(multivariateGlm.fit)
export(multivariatePredictGlm)
export(oneComponent)
export(scglr)
export(scglrCrossVal)
export(wtCenter)
export(wtScale)
import(Formula)
import(ROCR)
import(expm)
import(ggplot2)
import(graphics)
import(grid)
import(stringr)
importFrom(Matrix,bdiag)
importFrom(graphics,barplot)
13 changes: 7 additions & 6 deletions R/critConvergence.r
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#' @title Auxiliary function tuning the convergence of scglr
#' @description Function tuning the convergence of scglr
#' @title Auxiliary for controlling SCGLR fitting
#' @description Auxiliary function for \code{scglr} fitting used to
#' construct a convergence control argument.
#' @export
#' @param tol positive convergence threshold
#' @param maxit integer, maximum number of iterations
#' @return a list containing elements named as the arguments
#' @param tol positive convergence threshold.
#' @param maxit integer, maximum number of iterations.
#' @return a list containing elements named as the arguments.
critConvergence <- function (tol = 1e-6, maxit = 50)
{
if (!is.numeric(tol) || tol <= 0)
stop("value of 'tolerance' must be > 0")
if (!is.numeric(maxit) || maxit <= 0)
stop("maximum number of iterations must be > 0")
list(tol = tol, maxit = maxit)
}
}
33 changes: 18 additions & 15 deletions R/data.r
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
#' @title This is the data to be included into the package
#' @title Sample dataset of abundance of genera in tropical moist forest
#' @name genus
#' @docType data
#' @author CoForChange project
#' @references \url{http://www.coforchange.eu/fr/}
#' @keywords data
# @keywords datasets
#' @note The use of this dataset for publication must make reference to the CoForChange project.
#' @description genus gives the abundance of 27 common tree genera in the tropical moist forest
#' @description Genus gives the abundance of 27 common tree genera in the tropical moist forest
#' of the Congo-Basin and 40 geo-referenced environmental variables on one thousand 8 by 8 km plots
#' (observations). Each plot's data was obtained by aggregating the data measured on a variable
#' number of previously sampled 0.5 ha sub-plots. Geo-referenced environmental variables were
#' used to describe the physical factors as well as vegetation characteristics.
#' 14 physical factors were used pertaining the description of topography, geology and rainfall
#' of each plot. Vegetation is characterized through 16-days enhanced vegetation index (EVI) data.
#' @param gen1 to gen27 are the abundance of the 27 common genera on each plot
#' @param altitude is the above-sea level in meters
#' @param pluvio_yr is the mean annual rainfall
#' @param forest forest type classified into seven classes
#' @param pluvio_1 to pluvio_12 are the monthly rainfalls
#' @param geology is a 5-level factor giving the geological substrate
#' @param evi_1 to evi_23 are the means over 10 years of the enhanced vegetation indexes
#' for each successive 16 days period using MODIS images
#' @param lon and lat are the longitude/latitude of the plot centers
#' @param surface is the surface of the sampled area contained in each 8 by 8 kms aggregated plot
#' of each plot. Vegetation is characterized through 16-days enhanced vegetation index (EVI) data.
#' @source \url{http://www.coforchange.eu/fr/}
#' @format
#' \tabular{ll}{
#' \code{gen1 to gen27} \tab abundance of the 27 common genera.\cr
#' \code{altitude} \tab above-sea level in meters.\cr
#' \code{pluvio_yr} \tab mean annual rainfall.\cr
#' \code{forest} \tab classified into seven classes.\cr
#' \code{pluvio_1 to pluvio_12} \tab monthly rainfalls.\cr
#' \code{geology} \tab 5-level geological substrate.\cr
#' \code{evi_1 to evi_23} \tab 16-days enhanced vegetation indexes.\cr
#' \code{lon and lat} \tab position of the plot centers.\cr
#' \code{surface} \tab sampled area.\cr
#' }
#'
NULL
22 changes: 11 additions & 11 deletions R/f2x.r
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#' @title Regression coefficients conversion
#' @description converts the regression coefficients associated with the components
#' into coefficients associated with the initial regressors
#' @export
#' @param Xcr matrix of the standardized regressors
#' @param centerx vector of the regressors' means
#' @param invsqrtm metric matrix M^(-1/2)
#' @param gamma (generalized) regression coefficients associated with the components
#' @param u matrix of the component coordinates on Xcr (component = Xcr * u)
#' @param comp matrix of the components
#' @return beta matrix containing the regression coefficients associated with the regressors X
# @title Regression coefficients conversion
# @description converts the regression coefficients associated with the components
# into coefficients associated with the initial regressors
# @export
# @param Xcr matrix of the standardized regressors
# @param centerx vector of the regressors' means
# @param invsqrtm metric matrix M^(-1/2)
# @param gamma (generalized) regression coefficients associated with the components
# @param u matrix of the component coordinates on Xcr (component = Xcr * u)
# @param comp matrix of the components
# @return beta matrix containing the regression coefficients associated with the regressors X
f2x <- function(Xcr,centerx,invsqrtm,gamma,u,comp)
{
n <- dim(Xcr)[1]
Expand Down
10 changes: 5 additions & 5 deletions R/infoCriterion.r
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#' @title Function that calculates cross-validation selection criteria
#' @export
#' @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 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
#' identifying the distribution families of the dependent variables.
#' "bernoulli", "binomial", "poisson" or "gaussian" are allowed.
#' @param type information criterion used. Likelihood, aic, bic, aicc or
#' Mean Square Prediction Error (mspe) are defined. auc also defined for Bernoulli cases only.
#' Mean Square Prediction Error (mspe) are defined. Area Under ROC Curve (auc) also defined for Bernoulli cases only.
#' @param size describes the number of trials for the binomial dependent variables.
#' A (number of statistical units * number of binomial dependent variables) matrix is expected.
#' @param npar number of parameters used for penalisation
#' @param npar number of parameters used for penalisation.
#' @return a matrix containing the criterion value for each dependent variable (row)
#' and each number of components (column)
#' and each number of components (column).
infoCriterion <- function(ynew,pred,family,type,size=NULL,npar=0)
{
if(type=="auc")
Expand Down
45 changes: 23 additions & 22 deletions R/kComponents.r
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
#' @title Estimation algorithm for K components
#' @description calculates the K components by iteratively calling function oneComponent
#' @export
#' @param X matrix (n*p) containing the standardized covariates
#' @param Y matrix (n*q) containing dependent variables
#' @param AX matrix of additional covariates used in the generalized regression but not entering the linear
#' combinations giving components
#' @param K integer specifying the number of components
#' @param family a vector of the same length as the number of responses containing characters
#' identifying the distribution families of the dependent variables.
#' "bernoulli", "binomial", "poisson" or "gaussian" are allowed.
#' @param size matrix of size statistical units * number of binomial responses, giving the number of trials
#' for binomial dependent variables.
#' @param offset used for the poisson dependent variables.
#' A vector or a matrix of size: number of observations * number of Poisson dependent variables is expected
#' @param crit a list of maxit and tol, default is 50 and 10e-6. If responses are bernoulli variables only, tol should generally be increased
#' @return a list
#' @return \item{u}{matrix of size (number of regressors * number of components), contains the component-loadings,
#' i.e. the coefficients of the regressors in the linear combination giving each component}
#' @return \item{comp}{matrix of size (number of statistical units * number of components) having the components as column vectors}
#' @return \item{compr}{matrix of size (number of statistical units * number of components) having the standardized components as column vectors}
#' @return \item{ds}{the final value of the regularization degree}
# @title Estimation algorithm for K components
# @description calculates the K components by iteratively calling function oneComponent
# @export
# @param X matrix (n*p) containing the standardized covariates
# @param Y matrix (n*q) containing dependent variables
# @param AX matrix of additional covariates used in the generalized regression but not entering the linear
# combinations giving components
# @param K integer specifying the number of components
# @param family a vector of the same length as the number of responses containing characters
# identifying the distribution families of the dependent variables.
# "bernoulli", "binomial", "poisson" or "gaussian" are allowed.
# @param size matrix of size statistical units * number of binomial responses, giving the number of trials
# for binomial dependent variables.
# @param offset used for the poisson dependent variables.
# A vector or a matrix of size: number of observations * number of Poisson dependent variables is expected
# @param crit crit a list of two elements : maxit and tol, describing respectively the maximum number of iterations and
# the tolerance convergence criterion for the Fisher scoring algorithm. Default is set to 50 and 10e-6 respectively.
# @return a list
# @return \item{u}{matrix of size (number of regressors * number of components), contains the component-loadings,
# i.e. the coefficients of the regressors in the linear combination giving each component}
# @return \item{comp}{matrix of size (number of statistical units * number of components) having the components as column vectors}
# @return \item{compr}{matrix of size (number of statistical units * number of components) having the standardized components as column vectors}
# @return \item{ds}{the final value of the regularization degree}
kComponents <- function(X,Y,AX,K,family,size=NULL,offset=NULL,crit=list())
{
n<-dim(X)[1]
Expand Down
12 changes: 6 additions & 6 deletions R/metric.r
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#'@title Function that computes a submatrix of metric M^(-1/2)
#'@export
#'@param x the column vector of a regressor or factor
#@title Function that computes a submatrix of metric M^(-1/2)
#@export
#@param x the column vector of a regressor or factor
metricBloc <- function(x){
z <- model.matrix(~x)[,-1,drop=FALSE]
z <- scale(z,center=TRUE,scale=FALSE)
Expand All @@ -9,9 +9,9 @@ metricBloc <- function(x){
}


#'@title Function that computes M^(-1/2)
#'@export
#'@param data data.frame containing all covariates
#@title Function that computes M^(-1/2)
#@export
#@param data data.frame containing all covariates
metric <- function(data){
z <- sapply(data,metricBloc)
z <- bdiag(z)
Expand Down
16 changes: 8 additions & 8 deletions R/multivariateFormula.r
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#' @title Formula construction
#' @description Construction of the multivariate scglr formula
#' @description Construction of the multivariate scglr formula.
#' @export
#' @param namesY a vector of character containing the names of the dependent variables
#' @param namesY a vector of character containing the names of the dependent variables.
#' @param namesX a vector of character containing the names of the covariates (X) involved
#' in the components
#' @param namesSX a vector of character containing the names of the additional covariates
#' @return an object of class formula
multivariateFormula <- function(namesY,namesX,namesSX=NULL)
#' in the components.
#' @param namesAX a vector of character containing the names of the additional covariates.
#' @return an object of class \code{Formula}.
multivariateFormula <- function(namesY,namesX,namesAX=NULL)
{
forml <- paste(namesY,collapse="+")
formr <- paste(namesX,collapse="+")
if(!is.null(namesSX)){
formr2 <- paste(namesSX,collapse="+")
if(!is.null(namesAX)){
formr2 <- paste(namesAX,collapse="+")
form <- paste(paste(forml,"~",formr,sep=""),formr2,sep="|")
formula <- as.Formula(form)
}else{
Expand Down

0 comments on commit d54781f

Please sign in to comment.