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

swh:1:snp:218ce733af7de6247148caa3cf8c71ef1c66e614
  • Code
  • Branches (8)
  • Releases (0)
    • Branches
    • Releases
    • HEAD
    • refs/heads/master
    • refs/tags/0.9
    • refs/tags/0.9.1
    • refs/tags/1.0.0
    • refs/tags/1.1.0
    • refs/tags/1.1.1
    • refs/tags/1.1.2
    • refs/tags/1.2.2
    No releases to show
  • 9d94644
  • /
  • man
  • /
  • predict.sns.Rd
Raw File Download

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
content badge Iframe embedding
swh:1:cnt:a94d2011ff42ddf0cc8a7fccd803019d034df972
directory badge Iframe embedding
swh:1:dir:fa1b373789ef2e5e427c708287fef5c27aed839d
revision badge
swh:1:rev:f1cf3c91ce3c9bdcfe74f4fb168e73fc44f55c93
snapshot badge
swh:1:snp:218ce733af7de6247148caa3cf8c71ef1c66e614

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: f1cf3c91ce3c9bdcfe74f4fb168e73fc44f55c93 authored by Alireza Mahani on 25 October 2016, 10:31:12 UTC
version 1.1.2
Tip revision: f1cf3c9
predict.sns.Rd
\name{predict.sns}
\alias{predict.sns}
\alias{summary.predict.sns}
\alias{print.summary.predict.sns}

\title{
Sample-based prediction using "sns" Objects
}

\description{
Method for sample-based prediction using the output of \code{\link{sns.run}}.
}

\usage{
\method{predict}{sns}(object, fpred
  , nburnin = max(nrow(object)/2, attr(object, "nnr"))
  , end = nrow(object), thin = 1, ...)
\method{summary}{predict.sns}(object
  , quantiles = c(0.025, 0.5, 0.975)
  , ess.method = c("coda", "ise"), ...)
\method{print}{summary.predict.sns}(x, ...)
}
%- maybe also 'usage' for other objects documented here.
\arguments{
  \item{object}{Object of class "sns" (output of \code{\link{sns.run}}) or "predict.sns" (output of \code{predict.sns}).}
  \item{fpred}{Prediction function, accepting a single value for the state vector and producing a vector of outputs.}
  \item{nburnin}{Number of burn-in iterations discarded for sample-based prediction.}
  \item{end}{Last iteration used in sample-based prediction.}
  \item{thin}{One out of \code{thin} iterations within the specified range are used for sample-based prediction.}
  \item{quantiles}{Values for which sample-based quantiles are calculated.}
  \item{ess.method}{Method used for calculating effective sample size. Default is to call \code{effectiveSize} from package \code{coda}.}
  \item{x}{An object of class "summary.predict.sns".}
  \item{...}{Arguments passed to/from other functions.}
}

\value{
\code{predict.sns} produces a matrix with number of rows equal to the length of prediction vector produces by \code{fpred}. Its numnber of columns is equal to the number of samples used within the user-specified range, and after thinning (if any). \code{summary.predict.sns} produces sample-based prediction mean, standard deviation, quantiles, and effective sample size.
}

\references{
Mahani A.S., Hasan A., Jiang M. &  Sharabiani M.T.A. (2016). Stochastic Newton Sampler: The R Package sns. Journal of Statistical Software, Code Snippets, 74(2), 1-33. doi:10.18637/jss.v074.c02
}

\author{
Alireza S. Mahani, Asad Hasan, Marshall Jiang, Mansour T.A. Sharabiani
}

\note{
See package vignette for more details on SNS theory, software, examples, and performance.
}

\seealso{
\code{\link{sns.run}}
}

\examples{

\dontrun{

# using RegressionFactory for generating log-likelihood and derivatives
library("RegressionFactory")

loglike.poisson <- function(beta, X, y) {
  regfac.expand.1par(beta, X = X, y = y,
    fbase1 = fbase1.poisson.log)
}

# simulating data
K <- 5
N <- 1000
X <- matrix(runif(N * K, -0.5, +0.5), ncol = K)
beta <- runif(K, -0.5, +0.5)
y <- rpois(N, exp(X \%*\% beta))

beta.init <- rep(0.0, K)
beta.smp <- sns.run(beta.init, loglike.poisson,
  niter = 1000, nnr = 20, mh.diag = TRUE, X = X, y = y)

# prediction function for mean response
predmean.poisson <- function(beta, Xnew) exp(Xnew \%*\% beta)
ymean.new <- predict(beta.smp, predmean.poisson,
                     nburnin = 100, Xnew = X)
summary(ymean.new)

# (stochastic) prediction function for response
predsmp.poisson <- function(beta, Xnew)
  rpois(nrow(Xnew), exp(Xnew \%*\% beta))
ysmp.new <- predict(beta.smp, predsmp.poisson
                    , nburnin = 100, Xnew = X)
summary(ysmp.new)

}

}


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