GithubHelp home page GithubHelp logo

scnext / scglr Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 1.0 9.08 MB

An extension of the Fisher Scoring Algorithm to combine PLS regression with GLM estimation in the multivariate context. Covariates can be grouped in themes.

Home Page: https://scnext.github.io/SCGLR/

R 96.66% TeX 3.28% CSS 0.06%
r package partial-least-squares-regression

scglr's People

Contributors

billy34 avatar tiemor75 avatar

Watchers

 avatar  avatar

Forkers

julien-gibaud

scglr's Issues

Bug in scglrTheme function

Describe the bug
Not updating linear predictors in Theme

In the loop for(t in seq(1, length(out))){ ...} line 373, did not work because "out" is a list of length 1 containing a list of themes. Then length(out) is always equal to one.

solutions :
a/ change length(out) by sum(H>0)
or
b/ modify out object itself

Formula to be changed in demo functions

Describe the bug
demo files have to be updated

Expected behavior
Missing A = for additional geology covariates in formula (cf scglr, scglrCrossVal demo functions)
current formula as form <- multivariateFormula(ny,c(nx,"I(latlon)"),c("geology")) must be replaced by
form <- multivariateFormula(ny,c(nx,"I(lat
lon)"),A=c("geology"))

plot bugs

  • setting title to FALSE should not display it

Theme function

Describe the bug
Linear predictors not well evaluated

replace line from 366 to 378 by


 # compute global linear predictors
  comp <- cbind(1,as.matrix(do.call("cbind",lapply(out$themes, function(x) x$comp))))
  if(additional) {
    comp <- cbind(comp, model.matrix(theme_A, data)[,-1])
  }
  # lin.pred.global <- multivariatePredictGlm(comp, family=family, beta=gamma, offset=offset)
  lin.pred.global <- comp%*%gamma
  # Linear predictors by theme
  for(t in seq_along(out$themes)) {
    # par <- out$themes[[t]]$gamma[1:(H[t]+1),]
    par <- out$themes[[t]]$gamma[2:(H[t]+1),]#without intercept
    # out$themes[[t]]$lin.pred <- multivariatePredictGlm(cbind(1,as.matrix(out$themes[[t]]$comp)), family=family, beta=par, offset=offset)
    out$themes[[t]]$lin.pred <- as.matrix(out$themes[[t]]$comp)%*%par
    out$themes[[t]]$gamma <- gamma
    out$themes[[t]]$beta <- beta
  }

Error when only one response variable considered

library(SCGLR) version 3.0

data(genus)
# depuis l'exemple scglrTheme
n <- names(genus)
n <-n[!n%in%c("geology","surface","lon","lat","forest","altitude")]
ny <- n[grep("^gen",n)]    # Y <- names that begins with "gen"
nx1 <- n[grep("^evi",n)]   # X <- remaining names
nx2 <- n[-c(grep("^evi",n),grep("^gen",n))]

keep first Y

form <- multivariateFormula(ny[1],nx1,nx2,A=c("geology"))
fam <- rep("poisson",1)#longueur 1
testthm <-scglrTheme(form,data=genus,H=c(2,2),family=fam,offset = genus$surface)

Error

Error in gamma[2:(sum(H) + 1), , drop = FALSE] : 
  incorrect number of dimensions

Remove expm

Describe the bug
Remove unneeded problematic dependency

Dependency expm has issues that are not corrected yet and may lead to archival of SCGLR on CRAN. Fortunately it appears that it is not used anymore in the package and can be safely removed.

Allow predefined observation groups for cross validation

Is your feature request related to a problem? Please describe.
Currently scglrCrossVal and themeBackward did not allow spatial cross validation.

Describe the solution you'd like
Provide clusters as a vector of sample size in folds parameter.

Error in apply

Hello
I am trying to use SCGLR package for a multivariate analysis that includes 3 dependent variables, 1 categorical dependent variable (burnt and unburnt), and two additional covariates (temperature and humidity), but I get this error when trying to complete the script:
Error in apply(x, 2, mean) : dim(X) must have a positive length

Can anyone tell me what is causing this?

I present my script (and its results) below:

build multivariate formula

ny <- c("taxa_pulsos","duracao","energia")
nx1 <- c("fogo")
nadd <- c("temperatura","umidade")
form <- multivariateFormula(ny,nx1,A=nadd)
form
Multivariate formula
taxa_pulsos + duracao + energia ~ fogo | temperatura + umidade
Response:
Y = taxa_pulsos + duracao + energia
Covariates:
T1 = fogo
A = temperatura + umidade

summary(form)
Length1 Length2 Class1 Class2
1 2 MultivariateFormula Formula
Class3 Mode
formula call

define family

fam <- rep("poisson",length(ny))
genus.scglr <- scglr(formula=form,,data = dados,family=fam)
Error in apply(x, 2, mean) : dim(X) must have a positive length

contrasts error in scglrTheme

Contrasts error generated when providing factor variable as Additional

Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) : 
  contrasts can be applied only to factors with 2 or more levels

Dependency on plsdepot

The plsdepot package that is used by mixed SCGLR is no longer available on CRAN.

We should provide an alternate method for component initialization.

Improve reaction to convergence error

Error message should be completed with iteration number and/or fold id in case of cross validation.

When in cross validation, errors should only invalidate current fold but allow others to complete (eg when asked to do 10 folds, returning 9 is maybe enough)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.