Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

https://github.com/cran/sparseFLMM
01 July 2021, 10:59:25 UTC
  • Code
  • Branches (9)
  • Releases (0)
  • Visits
    • Branches
    • Releases
    • HEAD
    • refs/heads/master
    • refs/tags/0.1.0
    • refs/tags/0.1.1
    • refs/tags/0.2.0
    • refs/tags/0.2.2
    • refs/tags/0.3.0
    • refs/tags/0.3.1
    • refs/tags/0.4.0
    • refs/tags/0.4.1
    No releases to show
  • d18745c
  • /
  • R
  • /
  • get_cross_products.R
Raw File Download
Take a new snapshot of a software origin

If the archived software origin currently browsed is not synchronized with its upstream version (for instance when new commits have been issued), you can explicitly request Software Heritage to take a new snapshot of it.

Use the form below to proceed. Once a request has been submitted and accepted, it will be processed as soon as possible. You can then check its processing state by visiting this dedicated page.
swh spinner

Processing "take a new snapshot" request ...

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
  • revision
  • snapshot
origin badgecontent badge Iframe embedding
swh:1:cnt:bdc8a6f8cb6f10219ef29c6debb5d3cac1714d20
origin badgedirectory badge Iframe embedding
swh:1:dir:ca88c084abe4a2a855a7fd17cd28a8b909270766
origin badgerevision badge
swh:1:rev:5f8586c66031f53974ac4cb296fe3f6c49923ba6
origin badgesnapshot badge
swh:1:snp:a7e81d59d1c390b08089952db41e90a1abb796ee

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
  • revision
  • snapshot
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Tip revision: 5f8586c66031f53974ac4cb296fe3f6c49923ba6 authored by Jona Cederbaum on 02 October 2019, 03:50:02 UTC
version 0.3.0
Tip revision: 5f8586c
get_cross_products.R
#####################################################################################################
# author: Jona Cederbaum and Fabian Scheipl
#####################################################################################################
# description: preparations for the covariance where only cross products of interest are constructed.
# uses functions in useful_functions.R.
#####################################################################################################

get_crossprods_fun <- function(y_tilde, curve_info, t, my_grid, d_grid, use_RI, I, J){

  ###################
  # initialize output
  ###################
  output <- list()

  if(!use_RI){
    ##################
    # for crossed fRIs
    res <- vector(mode = "list", length = I + J)
  }else{
    ###################################
    # for one fRI or independent curves
    res <- vector(mode = "list", length = I )
  }

  ##################################################
  # loop over subjects (first groupin_variable)
  # get all combinations on the same subjects
  # (same words or different words)
  # calls function make_crossprod_dt (defined below)
  ##################################################
  for(i in seq_len(I)){
    res[[i]] <- make_crossprod_dt(curve_info[subject_long == i, ], use_RI = use_RI)
  }

  if(!use_RI){
    ##################################################
    # loop over words (second grouping variable)
    # get all combinations on the same words
    # (same words or different subjects)
    # calls function make_crossprod_dt (defined below)
    ##################################################
    for(i in seq_len(J)){
      res[[I + i]] <- make_crossprod_dt(curve_info[word_long == i, ],
                                        preselection = "word", use_RI = use_RI)
    }
  }

  ret <- do.call(rbind, res)
  setkey(ret, id1, id2)

  #####################
  # take out id, y1, y2
  #####################
  set(ret, i = NULL, "id1", NULL)
  set(ret, i = NULL, "id2", NULL)

  set(ret, i = NULL, "y1", NULL)
  set(ret, i = NULL, "y2", NULL)

  ##################
  # rename t1 and t2
  ##################
  setnames(ret, old = c("t1", "t2"), new = c("row_t_bivariate", "col_t_bivariate"))

  #####################################
  # create indicators
  # same_word, same_subject, same_point
  #####################################
  if(!use_RI){
    ##################
    # for crossed fRIs
    output[["index"]] <- create_data_frame_bivariate_fun(index = ret)
  }else{
    ###################################
    # for one fRI or independent curves
    output[["index"]] <- create_data_frame_bivariate_RI_fun(index = ret)
  }

  #####################
  # construct grid data
  #####################
  grid_help <- create_grid_data_fun(my_grid = my_grid, d_grid = d_grid)

  output[["grid_row"]] <- grid_help$grid_row
  output[["grid_col"]] <- grid_help$grid_col

  output[["same_subject_grid"]] <- grid_help$same_subject
  if(!use_RI)
    output[["same_word_grid"]] <- grid_help$same_word
  output[["same_curve_grid"]] <- grid_help$same_curve_grid
  output[["same_point_grid"]] <- grid_help$same_point_grid

  rm(grid_help)

  ###############
  # return output
  ###############
  output
}

############################################################################################

make_crossprod_dt <- function(curve_info, preselection = c("none", "subject", "word"), use_RI){

  preselection <- match.arg(preselection)
  setkey(curve_info, id)

  ####################
  # take  combinations
  ####################
  combinations <- with(curve_info, CJ(id = id, id2 = id))

  if(!use_RI){
    tmp1 <- curve_info[combinations, list(id1 = id, subj1 = subject_long, word1 = word_long,
                                          rep1 = combi_long, n1 = n_long)]
  }else{
    tmp1 <- curve_info[combinations, list(id1 = id, subj1 = subject_long, n1 = n_long)]
  }

  if(!use_RI){
    tmp2 <- curve_info[combinations[, list(id = id2)],
                       list(id2 = id, subj2 = subject_long, word2 = word_long, rep2 = combi_long,
                            n2 = n_long)]
  }else{
    tmp2 <- curve_info[combinations[, list(id = id2)],
                       list(id2 = id, subj2 = subject_long, n2 = n_long)]
  }

  if(!use_RI){
    crosstable <- tmp1[, `:=`(id2 = tmp2$id2, subj2 = tmp2$subj2, word2 = tmp2$word2, rep2 = tmp2$rep2,
                              n2 = tmp2$n2)]
  }else{
    crosstable <- tmp1[, `:=`(id2 = tmp2$id2, subj2 = tmp2$subj2, n2 = tmp2$n2)]
  }

  ################################
  # remove irrelevant combinations
  ################################
  # NOTE: if preselection is "none" all subjects and words are used
  ## if preselection is "subject" only the subset of crosstable is used for which word1 != word2
  ## if preselection is "word" only  the subset of crosstable is used for which subj1 != subj2

  if(preselection == "none") {

  }
  if(preselection == "subject") {
    crosstable <- crosstable[word1 != word2, ]
  }
  if(preselection == "word") {
    crosstable <- crosstable[subj1 != subj2, ]
  }

  ###############################
  # add y and t to the data.table
  ###############################
  # once for id1 ordering and once for id2 ordering
  # leading to t1, t2, y1, y2 (when use_tri = TRUE also an indicator for t is added for both ordering)
  # NOTE: using the id key, we can directly assign the right values

  # add t1, y1, and (t_ind1)
  crosstable[, id := id1]
  setkey(crosstable, "id")
  crosstable <- crosstable[curve_info[, list(id, y_tilde, t)], ]
  setnames(crosstable, old = c("id1", "y_tilde", "t"),
           new = c("id1", "y1", "t1"))

  # add t2, y2, and (t_ind2)
  crosstable[, id := id2]
  setkey(crosstable, "id")
  crosstable <- crosstable[curve_info[, list(id, y_tilde, t)], ]
  if(!use_RI){
    setnames(crosstable, old = c("id", "y_tilde", "t", "subj1", "subj2", "word1", "word2", "rep1", "rep2"),
             new = c("id2", "y2", "t2", "row_subject_bivariate",
                   "col_subject_bivariate", "row_word_bivariate", "col_word_bivariate", "row_combi_bivariate", "col_combi_bivariate"))
  }else{
    setnames(crosstable, old = c("id", "y_tilde", "t", "subj1", "subj2"),#, "n1", "n2"),
             new = c("id2", "y2", "t2", "row_subject_bivariate",
                   "col_subject_bivariate"))#, "row_curve_bivariate",
                   #"col_curve_bivariate"))
    crosstable[, row_curve_bivariate := n1]
    crosstable[, col_curve_bivariate := n2]
  }

  #################################
  # redo sort (again sorted by id1)
  #################################
  setkey(crosstable, "id1")

  (crosstable[, cross_vec_bivariate := y1 * y2])

  ##############################
  # sort data table first by id1
  # and then by id2
  ##############################
  setkey(crosstable, id1, id2)

  ###############
  # return output
  ###############
  crosstable
}

back to top

Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API