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/ssfit
17 June 2022, 02:38:51 UTC
  • Code
  • Branches (6)
  • Releases (0)
  • Visits
    • Branches
    • Releases
    • HEAD
    • refs/heads/master
    • refs/tags/1.0
    • refs/tags/1.1
    • refs/tags/1.2
    • refs/tags/R-3.0.2
    • refs/tags/R-3.0.3
    No releases to show
  • 0b14dd3
  • /
  • R
  • /
  • fit.model.R
Raw File Download Save again
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
swh:1:cnt:29b4bbedb6344c514119f8de8ccc2404f11f3fd7
origin badgedirectory badge
swh:1:dir:f0f7b2074e5a9d7b11eec852a1d7c28544e1495c
origin badgerevision badge
swh:1:rev:42f54439c28c24e78abdc35e2fa21aacd41bde8c
origin badgesnapshot badge
swh:1:snp:7c37d4f8ff81f1c6ead0c0500f5781a908574398

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: 42f54439c28c24e78abdc35e2fa21aacd41bde8c authored by Christiana Kartsonaki on 21 August 2013, 00:00:00 UTC
version 1.1
Tip revision: 42f5443
fit.model.R
fit.model <-
function (p, q, n, r, starting_values, h_vector, data_true, sim_data, 
    features, n_iter, print_results = TRUE, variances = TRUE) 
{
    h <- list()
    for (s in 1:p) {
        h[[s]] <- h_vector[s]
    	}

    theta_0 <- list()
    for (s in 1:p) {
        theta_0[[s]] <- starting_values[s]
    	}

    k <- 2^ceiling(log2(p + 1))

    # library(survey)
    if (p == 1) {
        D <- matrix(c(1, -1), nrow = 2, ncol = 1)
    	}
    if (p > 1) {
        D <- 2 * hadamard(k - 1) - 1
        D <- D[, 2:(p + 1)]
    	}

    sim <- list()
    z <- list()

    results <- matrix(NA, nrow = n_iter, ncol = p)
    k_ones <- matrix(1, nrow = k, ncol = 1)
    r_ones <- matrix(1, nrow = r, ncol = 1)
    design.points <- list()
    z_data <- matrix(NA, nrow = 1, ncol = q)

    for (j in 1:q) {
        z_data[1, j] <- features(data_true)[j]
    }
    z_data <- t(z_data)

    if (variances == TRUE) {
	var_theta <- list()
        }

    for (iter in 1:n_iter) {

        for (d in 1:k) {
            sim[[d]] <- list()
            z[[d]] <- matrix(NA, nrow = r, ncol = q)
	    }

        for (d in 1:k) {
            design.points[[d]] <- list()
            for (s in 1:p) {
                design.points[[d]][[s]] <- theta_0[[s]] + (D[d, s] * h[[s]])
            	}
            for (i in 1:r) {
                sim[[d]][[i]] <- sim_data(n, design.points[[d]])
                }
            }

        for (d in 1:k) {
            for (i in 1:r) {
                z[[d]][i, ] <- features(sim[[d]][[i]])
            	}
            }

        zbar <- list()
        for (d in 1:k) {
            zbar[[d]] <- (t(r_ones) %*% z[[d]])/r
	    }

	Zbar <- matrix(unlist(zbar), nrow = q, byrow = F)

        ztilde <- list()
        sigma <- list()
        for (d in 1:k) {
		ztilde[[d]] <- z[[d]] - (r_ones %*% zbar[[d]])
 	        sigma[[d]] <- (t(ztilde[[d]]) %*% ztilde[[d]])/(r - 1)
	        }

	V <- Zbar %*% D

  	sigma_vv <- (1/k) * Reduce("+", sigma)
        sigma_inv <- solve(sigma_vv)

	lambda <- rep(NA, times = p)
        for (s in 1:p) {
            lambda[s] <- sqrt((t(V[, s]) %*% sigma_inv %*% V[, s]))
	    }

	L <- (1/lambda) * (sigma_inv %*% V)
	Ybar <- t(L) %*% Zbar
 
   	Y_data <- t(L) %*% z_data

        A <- (2/k) * (t(V) %*% L)
        for (u in 1:dim(A)[1]) {
            for (v in 1:dim(A)[2]) {
                A[u, v][u != v] <- 0
            	}
            }

        H <- matrix(0, nrow = p, ncol = p)
        for (s in 1:p) {
            H[s, s] <- h[[s]]
            }

        theta_hat <- matrix(NA, nrow = p, ncol = 1)
        th_0 <- matrix(unlist(theta_0))

        theta_hat <- th_0 + (2 * H %*% solve(A) %*% (Y_data - ((Ybar %*% k_ones)/k)))

        for (s in 1:p) {
 	       theta_0[[s]] <- theta_hat[s]
 	       }

        results[iter, ] <- t(theta_hat)

        if (variances == TRUE) {
		var_theta[[iter]] <- 4 * H %*% solve(A) %*% t(L) %*% sigma_vv %*% L %*% H %*% solve(A)
        	}

        if (print_results == TRUE) {
            	print(results[iter, ])
        	}
    }

        if (variances == FALSE) {
	    var_theta <- 4 * H %*% solve(A) %*% t(L) %*% sigma_vv %*% L %*% H %*% solve(A)
            }

    return(list(estimates = results, var_estimates = var_theta, L = L, sigma = sigma_vv, zbar = Zbar, z_D = z_data, ybar = Ybar, y_D = Y_data))

}

back to top

Software Heritage — Copyright (C) 2015–2026, 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