From noreply at r-forge.r-project.org Sun Sep 1 13:10:27 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 1 Sep 2013 13:10:27 +0200 (CEST) Subject: [spcopula-commits] r102 - / pkg pkg/R pkg/man pkg/src Message-ID: <20130901111028.05921183FB7@r-forge.r-project.org> Author: mappe Date: 2013-09-01 13:10:27 +0200 (Sun, 01 Sep 2013) New Revision: 102 Added: pkg/man/getNeighbours.experimental.Rd pkg/src/ pkg/src/Rinterface.h pkg/src/spatialPreparation.c thoughts-Marius/ Modified: pkg/NAMESPACE pkg/R/spatialPreparation.R Log: - added thoughts-Marius folder - added C implementation of getNeighbours() in getNeighbours.experimental() Modified: pkg/NAMESPACE =================================================================== --- pkg/NAMESPACE 2013-08-01 10:31:15 UTC (rev 101) +++ pkg/NAMESPACE 2013-09-01 11:10:27 UTC (rev 102) @@ -27,7 +27,7 @@ # export(setSizeLim) # spatial -export(getNeighbours,getStNeighbours) +export(getNeighbours,getNeighbours.experimental, getStNeighbours) export(calcBins) export(calcSpTreeDists, dropSpTree) Modified: pkg/R/spatialPreparation.R =================================================================== --- pkg/R/spatialPreparation.R 2013-08-01 10:31:15 UTC (rev 101) +++ pkg/R/spatialPreparation.R 2013-09-01 11:10:27 UTC (rev 102) @@ -98,6 +98,60 @@ predLocs, prediction, var)) } + + +getNeighbours.experimental = function (dataLocs, predLocs, var = names(dataLocs)[1], size = 5, + prediction = FALSE, min.dist = 0.01) +{ + stopifnot((!prediction && missing(predLocs)) || (prediction && + !missing(predLocs))) + stopifnot(min.dist > 0 || prediction) + if (missing(predLocs) && !prediction) + predLocs = dataLocs + stopifnot(is(predLocs, "Spatial")) + if (any(is.na(match(var, names(dataLocs))))) + stop("At least one of the variables is unkown or is not part of the data.") + nLocs <- length(predLocs) + size <- min(size, length(dataLocs) + prediction) + + allLocs <- matrix(0, nLocs, size) + allDists <- matrix(0, nLocs, size - 1) + result = .C("getNeighbours_2d", + allLocs = as.double(allLocs), + allDists = as.double(allDists), + as.double(coordinates(dataLocs)), + as.double(coordinates(predLocs)), + as.integer(length(dataLocs)), + as.integer(length(predLocs)), + as.double(min.dist), + as.integer(size), + as.integer(prediction), + PACKAGE="spcopula") + + if (!prediction) allData <- matrix(dataLocs[result$allLocs, var, drop = F]@data[[1]], nLocs, size) + else allData <- matrix(c(rep(NA,nLocs),dataLocs[result$allLocs[(nLocs+1):(nLocs*size)], var, drop = F]@data[[1]]), nLocs, size) + + if (!prediction) + predLocs <- NULL + + colnames(allData) <- paste(paste("N", rep(0:(size - 1), each = length(var)), + sep = ""), rep(var, size), sep = ".") + + + return(neighbourhood(allData, matrix(result$allDists,nLocs, size - 1), matrix(result$allLocs, nLocs, size), dataLocs, + predLocs, prediction, var)) +} + + + + + + + + + + + ############# ## BINNING ## ############# Added: pkg/man/getNeighbours.experimental.Rd =================================================================== --- pkg/man/getNeighbours.experimental.Rd (rev 0) +++ pkg/man/getNeighbours.experimental.Rd 2013-09-01 11:10:27 UTC (rev 102) @@ -0,0 +1,47 @@ +\name{getNeighbours.experimental} +\alias{getNeighbours.experimental} + +\title{ +Creating Local Neighbourhoods +} +\description{ +This function calculates a local neighbourhood to be used for fitting of spatial/spatio-temporal vine copulas and for prediction using spatial/spatio-temporal vine copulas. +} +\usage{ +getNeighbours.experimental(dataLocs, predLocs, var = names(dataLocs)[1], size = 5, prediction=FALSE, min.dist = 0.01) +} +\arguments{ + \item{dataLocs}{ +some spatial data frame holding the data used for estimation/prediction +} + \item{predLocs}{ +A spatial object defining the prediction locations, might be missing if the neighbourhood is used for fitting. +} + \item{var}{ +the variable name of interest, by default the first variable is used. +} + \item{size}{ +The size of the neighbourhood including the location of interest (for fitting as well for prediction). +} + \item{prediction}{whether the neighbourhood should be used for prediction (TRUE) or spatial/Spatio-temporal vine copula fitting.} + \item{min.dist}{ +the minimal distance for a location to be included. Must be larger than 0 for fitting purposes and might be 0 for prediction. +} +} +\value{ +An object of \code{\linkS4class{neighbourhood}}. +} +\author{ +Benedikt Graeler +} + +\seealso{ +See \code{\link{neighbourhood}} for the native constructor of a \code{\linkS4class{neighbourhood}} class. +} +\examples{ +spdf <- data.frame(x=c(112,154,212,289,345),y=c(124,198,85,168,346),measure=rlnorm(5)) +coordinates(spdf) <- ~x+y + +getNeighbours.experimental(spdf,size=4) +} +\keyword{ spatial } \ No newline at end of file Added: pkg/src/Rinterface.h =================================================================== --- pkg/src/Rinterface.h (rev 0) +++ pkg/src/Rinterface.h 2013-09-01 11:10:27 UTC (rev 102) @@ -0,0 +1,33 @@ + +#include +#include +#include + + + +#ifdef _WIN32 +#define R_EXPORT __declspec(dllexport) +#else +#define R_EXPORT +#endif + + + + +#ifdef __cplusplus +extern "C" { +#endif + +/* FORWARD DECLARATIONS */ + +void R_EXPORT distMatrix(double *out, double *xa, double *xb, int *na, int*nb, int *d); +void R_EXPORT distMatrix_2d(double *out, double *xa, double *xb, int *na, int*nb); +void R_EXPORT distMatrixInner(double *out, double *xa, int *na, int *d); +void R_EXPORT distMatrixInner_2d(double *out, double *xa, int *na); + +void R_EXPORT getNeighbours_2d(double *out_locs, double *out_dists, double *data_locs, double *pred_locs, int *n_data, int *n_pred, double *min_dist, int *k, int *prediction); + + +#ifdef __cplusplus +} +#endif \ No newline at end of file Added: pkg/src/spatialPreparation.c =================================================================== --- pkg/src/spatialPreparation.c (rev 0) +++ pkg/src/spatialPreparation.c 2013-09-01 11:10:27 UTC (rev 102) @@ -0,0 +1,244 @@ + +#include "Rinterface.h" + + + + + +/* Helper Functions */ +inline double dist_2d(double ax, double ay, double bx, double by) { + return(sqrt( (ax-bx)*(ax-bx) + (ay-by)*(ay-by) )); +} + + + +#ifdef __cplusplus +extern "C" { +#endif + + + + + + +/** +* Computes the distance matrix of two sets of n-dimensional points +* @param out result (na,nb) matrix (mast be allocated in R or in calling function before) +* @param xa coordinates of the 1st set of points, each row of this matrix is a point +* @param xb coordinates of the 2nd set of points, each row of this matrix is a point +* @param na number of points in xa +* @param nb number of points in xb +* @param d number of dimensions, equals the number of columns in xa and xb +**/ +void R_EXPORT distMatrix(double *out, double *xa, double *xb, int *na, int*nb, int *d) { + if (*d == 2) { + distMatrix_2d(out, xa, xb, na, nb); + } + else + { + for (int i=0;i<*na; ++i) { + for (int j=0;j<*nb; ++j) { + out[j * (*na) + i] = 0; + + for (int k=0; k<*d; ++k) { + out[j * (*na) + i] += (xa[k * (*na) + i] - xb[k * (*nb) + j]) * (xa[k * (*na) + i] - xb[k * (*nb) + j]); // In R: col major + + } + out[j * (*na) + i] = sqrt(out[j * (*na) + i]); + } + } + } +} + + + +/** +* Computes the distance matrix of two sets of 2-dimensional points +* @param out result (na,nb) matrix (mast be allocated in R or in calling function before) +* @param xa coordinates of the 1st set of points, each row of this matrix is a point +* @param xb coordinates of the 2nd set of points, each row of this matrix is a point +* @param na number of points in xa +* @param nb number of points in xb +**/ +void R_EXPORT distMatrix_2d(double *out, double *xa, double *xb, int *na, int*nb) { + for (int i=0;i<*na; ++i) { + for (int j=0;j<*nb; ++j) { + out[j * (*na) + i] = dist_2d(xa[i],xa[*na + i], xb[j], xb[*nb + j]); + } + } +} + + + +/** +* Computes the "inner" distance matrix of one set of n-dimensional points +* @param out result (na,na) matrix (mast be allocated in R or in calling function before) +* @param xa coordinates of the 1st set of points, each row of this matrix is a point +* @param na number of points in xa +* @param d number of dimensions, equals the number of columns in xa and xb +**/ +void R_EXPORT distMatrixInner(double *out, double *xa, int *na, int *d) { + if (*d == 2) { + distMatrixInner_2d(out, xa, na); + } + else + { + for (int i=0;i<*na; ++i) { + for (int j=i+1;j<*na; ++j) { + out[j * (*na) + i] = 0; + for (int k=0; k<*d; ++k) { + out[j * (*na) + i] += (xa[k * (*na) + i] - xa[k * (*na) + j]) * (xa[k * (*na) + i] - xa[k * (*na) + j]); // In R: col major + + } + out[j * (*na) + i] = sqrt(out[j * (*na) + i]); + out[i * (*na) + j] = out[j * (*na) + i]; + } + } + for (int i=0;i<*na; ++i) { + out[i * (*na) + i] = 0.0; + } + } +} + + + +/** +* Computes the "inner" distance matrix of one set of n-dimensional points +* @param out result (na,na) matrix (mast be allocated in R or in calling function before) +* @param xa coordinates of the 1st set of points, each row of this matrix is a point +* @param na number of points in xa +**/ +void R_EXPORT distMatrixInner_2d(double *out, double *xa, int *na) { + for (int i=0;i<*na; ++i) { + for (int j=i+1;j<*na; ++j) { + out[j * (*na) + i] = dist_2d(xa[i],xa[*na + i], xa[j], xa[*na + j]); + out[i * (*na) + j] = out[j * (*na) + i]; + } + } + // set diagonal to zero + for (int i=0;i<*na; ++i) { + out[i * (*na) + i] = 0.0; + } +} + + + + + + +/*for (i in 1:nLocs) { + tempDists <- spDists(dataLocs, predLocs[i, ]) + tempDists[tempDists < min.dist] <- Inf + spLocs <- order(tempDists)[1:(size - 1)] + + allLocs[i,] <- c(i, spLocs) + allDists[i,] <- tempDists[spLocs] + allData[i,(prediction+1):size] <- dataLocs[c(i[!prediction],spLocs), + var, drop = F]@data[[1]] + } + */ + +/** +* +* +* +* +* @param k size of the neighbourhood including the location of interest +*/ +void R_EXPORT getNeighbours_2d(double *out_locs, double *out_dists, double *data_locs, double *pred_locs, int *n_data, int *n_pred, double *min_dist, int *k, int *prediction) { + double *C = (double*)malloc((*n_data) * (*n_pred) * sizeof(double)); + double *knn_dists = (double*)malloc((*k-1) * sizeof(double)); + int *knn_idxs = (int*)malloc((*k-1) * sizeof(int)); + + // Depending on whether pred_locs are the same as data_locs, use optimized "inner" distance matrix calculation + if (!prediction) { + // Compute inner distance matrix and store in C + distMatrixInner_2d(C, data_locs, n_data); + } + else { + + // Compute distance matrix and store in C + distMatrix_2d(C, data_locs, pred_locs, n_data, n_pred); + } + + // for each pred location + for (int i=0; i<*n_pred; ++i) { + knn_dists[0] = INFINITY; + knn_idxs[0] = -1; + + for (int j=0; j<*n_data; ++j) { + if (C[i* (*n_data) + j] < *min_dist) continue; + int nbrank = 0; + while (C[i* (*n_data) + j] > knn_dists[nbrank] && nbrank < (*k-1)) ++nbrank; + if (nbrank < (*k-1)) { + for (int s=(*k-3); s >= nbrank; --s) { + knn_dists[s + 1] = knn_dists[s]; // shift array if new element in knn array + knn_idxs[s + 1] = knn_idxs[s]; + } + knn_dists[nbrank] = C[i* (*n_data) + j]; + knn_idxs[nbrank] = j+1; // Indices in R start with 1 + } + } + + out_locs[i] = i+1; // Indices in R start with 1 + for (int j=1; j<(*k); ++j) { + // Assign c(i, knn_idxs[1:size-1]) as i-th row in out_locs + out_locs[j*(*n_pred) + i] = knn_idxs[j-1]; + // Assign knn_dists[1:size-1] as i-th row in out_dists + out_dists[(j-1)*(*n_pred) + i] = knn_dists[j-1]; + } + + } + + free(knn_idxs); + free(knn_dists); + free(C); +} + + + + + + +/* +calcSpLagInd <- function(data, boundaries) { + lags <- vector("list",length(boundaries)) + + dists <- spDists(data) + nlocs <- length(data) + + for (i in 1:(nlocs-1)) { + for (j in (i+1):nlocs) { + d <- dists[i,j] + for ( k in 1:length(boundaries)) { + if (d < boundaries[k]) { + lags[[k]] <- rbind(lags[[k]],c(i,j,d)) + break() + } + } + } + } + return(lags) +} +*/ + +/** +* +* @ +* +* +* +* OpenMP? +*/ +// SEXP calcSpLagInd(double *o double *idata, double *iboundaries, int *in_boundaries) { + + + // for + +// } + + + +#ifdef __cplusplus +} +#endif \ No newline at end of file From noreply at r-forge.r-project.org Tue Sep 3 16:35:16 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 3 Sep 2013 16:35:16 +0200 (CEST) Subject: [spcopula-commits] r103 - pkg/R Message-ID: <20130903143516.C71BC185D26@r-forge.r-project.org> Author: mappe Date: 2013-09-03 16:35:16 +0200 (Tue, 03 Sep 2013) New Revision: 103 Added: pkg/R/zzz.R Log: - zzz.R added in order to load library of C functions while loading package Added: pkg/R/zzz.R =================================================================== --- pkg/R/zzz.R (rev 0) +++ pkg/R/zzz.R 2013-09-03 14:35:16 UTC (rev 103) @@ -0,0 +1,9 @@ + + +.onLoad <- function(libname, pkgname) { + library.dynam("spcopula", pkgname, libname) +} + +.onUnload <- function(libpath) { + library.dynam.unload("spcopula", libpath) +} \ No newline at end of file From noreply at r-forge.r-project.org Tue Sep 3 16:40:41 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 3 Sep 2013 16:40:41 +0200 (CEST) Subject: [spcopula-commits] r104 - pkg Message-ID: <20130903144041.EC57618513B@r-forge.r-project.org> Author: mappe Date: 2013-09-03 16:40:41 +0200 (Tue, 03 Sep 2013) New Revision: 104 Modified: pkg/DESCRIPTION Log: - zzz.R added in order to load library of C functions while loading package Modified: pkg/DESCRIPTION =================================================================== --- pkg/DESCRIPTION 2013-09-03 14:35:16 UTC (rev 103) +++ pkg/DESCRIPTION 2013-09-03 14:40:41 UTC (rev 104) @@ -34,3 +34,4 @@ stVineCopula.R utilities.R returnPeriods.R + zzz.R From noreply at r-forge.r-project.org Sun Sep 8 11:17:15 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 8 Sep 2013 11:17:15 +0200 (CEST) Subject: [spcopula-commits] r105 - pkg/src Message-ID: <20130908091715.2F6F3180922@r-forge.r-project.org> Author: mappe Date: 2013-09-08 11:17:14 +0200 (Sun, 08 Sep 2013) New Revision: 105 Modified: pkg/src/Rinterface.h Log: - Converted line breaks from CRLF to LF Modified: pkg/src/Rinterface.h =================================================================== --- pkg/src/Rinterface.h 2013-09-03 14:40:41 UTC (rev 104) +++ pkg/src/Rinterface.h 2013-09-08 09:17:14 UTC (rev 105) @@ -1,33 +1,33 @@ - -#include -#include -#include - - - -#ifdef _WIN32 -#define R_EXPORT __declspec(dllexport) -#else -#define R_EXPORT -#endif - - - - -#ifdef __cplusplus -extern "C" { -#endif - -/* FORWARD DECLARATIONS */ - -void R_EXPORT distMatrix(double *out, double *xa, double *xb, int *na, int*nb, int *d); -void R_EXPORT distMatrix_2d(double *out, double *xa, double *xb, int *na, int*nb); -void R_EXPORT distMatrixInner(double *out, double *xa, int *na, int *d); -void R_EXPORT distMatrixInner_2d(double *out, double *xa, int *na); - -void R_EXPORT getNeighbours_2d(double *out_locs, double *out_dists, double *data_locs, double *pred_locs, int *n_data, int *n_pred, double *min_dist, int *k, int *prediction); - - -#ifdef __cplusplus -} + +#include +#include +#include + + + +#ifdef _WIN32 +#define R_EXPORT __declspec(dllexport) +#else +#define R_EXPORT +#endif + + + + +#ifdef __cplusplus +extern "C" { +#endif + +/* FORWARD DECLARATIONS */ + +void R_EXPORT distMatrix(double *out, double *xa, double *xb, int *na, int*nb, int *d); +void R_EXPORT distMatrix_2d(double *out, double *xa, double *xb, int *na, int*nb); +void R_EXPORT distMatrixInner(double *out, double *xa, int *na, int *d); +void R_EXPORT distMatrixInner_2d(double *out, double *xa, int *na); + +void R_EXPORT getNeighbours_2d(double *out_locs, double *out_dists, double *data_locs, double *pred_locs, int *n_data, int *n_pred, double *min_dist, int *k, int *prediction); + + +#ifdef __cplusplus +} #endif \ No newline at end of file From noreply at r-forge.r-project.org Mon Sep 9 08:31:20 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 9 Sep 2013 08:31:20 +0200 (CEST) Subject: [spcopula-commits] r106 - / pkg Message-ID: <20130909063120.3BD7D1842CD@r-forge.r-project.org> Author: ben_graeler Date: 2013-09-09 08:31:19 +0200 (Mon, 09 Sep 2013) New Revision: 106 Modified: pkg/DESCRIPTION spcopula_0.1-1.tar.gz Log: - updated DESCRIPTION Modified: pkg/DESCRIPTION =================================================================== --- pkg/DESCRIPTION 2013-09-08 09:17:14 UTC (rev 105) +++ pkg/DESCRIPTION 2013-09-09 06:31:19 UTC (rev 106) @@ -3,7 +3,9 @@ Title: copula driven spatial analysis Version: 0.1-1 Date: 2013-07-23 -Author: Benedikt Graeler +Authors at R: c(person("Benedikt", "Graeler", role = c("aut", "cre"), email = + "ben.graeler at uni-muenster.de"), person("Marius", "Appel", + role = "ctb")) Maintainer: Benedikt Graeler Description: This package provides a framework to analyse via copulas spatial and spatio-temporal data provided in the format of the spacetime package. Additionally, support for calculating different multivariate return periods is implemented. License: GPL-2 Modified: spcopula_0.1-1.tar.gz =================================================================== (Binary files differ) From noreply at r-forge.r-project.org Mon Sep 9 08:49:39 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 9 Sep 2013 08:49:39 +0200 (CEST) Subject: [spcopula-commits] r107 - pkg/man Message-ID: <20130909064939.C37D0183B91@r-forge.r-project.org> Author: ben_graeler Date: 2013-09-09 08:49:39 +0200 (Mon, 09 Sep 2013) New Revision: 107 Modified: pkg/man/calcBins.Rd pkg/man/composeSpCopula.Rd pkg/man/dependencePlot.Rd pkg/man/fitCorFun.Rd pkg/man/fitSpCopula.Rd pkg/man/getNeighbours.Rd pkg/man/getStNeighbours.Rd pkg/man/loglikByCopulasLags.Rd pkg/man/spCopPredict.Rd pkg/man/stCopPredict.Rd Log: - corrected line width in several man pages (\usage <= 90, \examples <= 100) Modified: pkg/man/calcBins.Rd =================================================================== --- pkg/man/calcBins.Rd 2013-09-09 06:31:19 UTC (rev 106) +++ pkg/man/calcBins.Rd 2013-09-09 06:49:39 UTC (rev 107) @@ -14,7 +14,8 @@ The (spatio-temporal) space is subdivided into pairs of observations that belong to certain spatial/spatio-temporal distance classes. For each distance class, the mean separating distance of all pairs involved is calculated alongside a correlation measure. The spatial/spatio-temporal correlogram is plotted by default. } \usage{ -calcBins(data, var, nbins = 15, boundaries = NA, cutoff = NA, cor.method="kendall", plot=TRUE, ...) +calcBins(data, var, nbins = 15, boundaries = NA, cutoff = NA, cor.method="kendall", + plot=TRUE, ...) } \arguments{ Modified: pkg/man/composeSpCopula.Rd =================================================================== --- pkg/man/composeSpCopula.Rd 2013-09-09 06:31:19 UTC (rev 106) +++ pkg/man/composeSpCopula.Rd 2013-09-09 06:49:39 UTC (rev 107) @@ -34,7 +34,7 @@ } \examples{ -composeSpCopula(c(1,1,2,3),families=list(frankCopula(.4), gumbelCopula(1.6),gumbelCopula(1.4)), +composeSpCopula(c(1,1,2,3),families=list(frankCopula(.4), gumbelCopula(1.6),gumbelCopula(1.4)), bins=data.frame(meanDists=c(500,1000,1500,2000,2500)),range=2250) } Modified: pkg/man/dependencePlot.Rd =================================================================== --- pkg/man/dependencePlot.Rd 2013-09-09 06:31:19 UTC (rev 106) +++ pkg/man/dependencePlot.Rd 2013-09-09 06:49:39 UTC (rev 107) @@ -7,7 +7,8 @@ Plots a kernel smoothed scatter plot of the provided rank-transformed sample. The work is done by the function \code{\link{panel.smoothScatter}}. } \usage{ -dependencePlot(var = NULL, smpl, bandwidth = 0.075, main="Stength of dependece", transformation = function(x) x, ...) +dependencePlot(var = NULL, smpl, bandwidth = 0.075, main="Stength of dependece", + transformation = function(x) x, ...) } %- maybe also 'usage' for other objects documented here. \arguments{ Modified: pkg/man/fitCorFun.Rd =================================================================== --- pkg/man/fitCorFun.Rd 2013-09-09 06:31:19 UTC (rev 106) +++ pkg/man/fitCorFun.Rd 2013-09-09 06:49:39 UTC (rev 107) @@ -8,7 +8,8 @@ Polynomials of different degrees can be fitted to the correlogram calculated using \code{\link{calcBins}}. This function will be used to adjust the copula parameter in the spatial/spatio-temporal copula. } \usage{ -fitCorFun(bins, degree = 3, cutoff = NA, bounds = c(0, 1), cor.method = NULL, weighted = FALSE) +fitCorFun(bins, degree = 3, cutoff = NA, bounds = c(0, 1), cor.method = NULL, + weighted = FALSE) } \arguments{ \item{bins}{ Modified: pkg/man/fitSpCopula.Rd =================================================================== --- pkg/man/fitSpCopula.Rd 2013-09-09 06:31:19 UTC (rev 106) +++ pkg/man/fitSpCopula.Rd 2013-09-09 06:49:39 UTC (rev 107) @@ -8,7 +8,8 @@ A bivariate spatial copula is composed out of a set of bivariate copulas. These are combined using a convex linear combination with weights based on distances where for copulas with a 1-1 correspondence of Kendall's tau or Spearman's rho a dependence function providing measures of association based on distances might be used. This function estimates a spatial dependence function, evaluates the log-likelihood per family and lag class, selects the best fits and composes a spatial bivariate copula. } \usage{ -fitSpCopula(bins, cutoff = NA, families = c(normalCopula(0), tCopula(0, dispstr = "un"), claytonCopula(0), frankCopula(1), gumbelCopula(1)), ...) +fitSpCopula(bins, cutoff = NA, families = c(normalCopula(0), tCopula(0, dispstr = "un"), + claytonCopula(0), frankCopula(1), gumbelCopula(1)), ...) } \arguments{ \item{bins}{ Modified: pkg/man/getNeighbours.Rd =================================================================== --- pkg/man/getNeighbours.Rd 2013-09-09 06:31:19 UTC (rev 106) +++ pkg/man/getNeighbours.Rd 2013-09-09 06:49:39 UTC (rev 107) @@ -8,7 +8,8 @@ This function calculates a local neighbourhood to be used for fitting of spatial/spatio-temporal vine copulas and for prediction using spatial/spatio-temporal vine copulas. } \usage{ -getNeighbours(dataLocs, predLocs, var = names(dataLocs)[1], size = 5, prediction=FALSE, min.dist = 0.01) +getNeighbours(dataLocs, predLocs, var = names(dataLocs)[1], size = 5, prediction=FALSE, + min.dist = 0.01) } \arguments{ \item{dataLocs}{ Modified: pkg/man/getStNeighbours.Rd =================================================================== --- pkg/man/getStNeighbours.Rd 2013-09-09 06:31:19 UTC (rev 106) +++ pkg/man/getStNeighbours.Rd 2013-09-09 06:49:39 UTC (rev 107) @@ -8,7 +8,8 @@ This function calculates local spatio-temporal neighbourhoods to be used for fitting of spatio-temporal vine copulas and for prediction using spatio-temporal vine copulas. } \usage{ -getStNeighbours(stData, ST, var = names(stData at data)[1], spSize = 4, t.lags=-(0:2), timeSteps=NA, prediction=FALSE, min.dist = 0.01) +getStNeighbours(stData, ST, var = names(stData at data)[1], spSize = 4, t.lags=-(0:2), + timeSteps=NA, prediction=FALSE, min.dist = 0.01) } \arguments{ \item{stData}{ Modified: pkg/man/loglikByCopulasLags.Rd =================================================================== --- pkg/man/loglikByCopulasLags.Rd 2013-09-09 06:31:19 UTC (rev 106) +++ pkg/man/loglikByCopulasLags.Rd 2013-09-09 06:49:39 UTC (rev 107) @@ -7,7 +7,8 @@ This function calculates the log-likelihood for a set of provided copula families per lag class. The copulas' parameters are either fitted by a provided distance dependent function, or through the function \code{\link{fitCopula}} per lag and copula family. } \usage{ -loglikByCopulasLags(bins, families = c(normalCopula(0), tCopula(0, dispstr = "un"), claytonCopula(0), frankCopula(1), gumbelCopula(1)), calcCor) +loglikByCopulasLags(bins, families = c(normalCopula(0), tCopula(0, dispstr = "un"), + claytonCopula(0), frankCopula(1), gumbelCopula(1)), calcCor) } \arguments{ Modified: pkg/man/spCopPredict.Rd =================================================================== --- pkg/man/spCopPredict.Rd 2013-09-09 06:31:19 UTC (rev 106) +++ pkg/man/spCopPredict.Rd 2013-09-09 06:49:39 UTC (rev 107) @@ -57,7 +57,8 @@ meuse$rtZinc <- rank(meuse$zinc)/(length(meuse)+1) -predMeuseNeigh <- getNeighbours(meuse[1:4,], meuse.grid[c(9:12,15:19,24:28,34:38),],"rtZinc",5L,TRUE,-1) +predMeuseNeigh <- getNeighbours(meuse[1:4,], meuse.grid[c(9:12,15:19,24:28,34:38),], + "rtZinc", 5L, TRUE, -1) qMar <- function(x) { qlnorm(x,mean(log(meuse$zinc)),sd(log(meuse$zinc))) Modified: pkg/man/stCopPredict.Rd =================================================================== --- pkg/man/stCopPredict.Rd 2013-09-09 06:31:19 UTC (rev 106) +++ pkg/man/stCopPredict.Rd 2013-09-09 06:49:39 UTC (rev 107) @@ -55,7 +55,8 @@ meuse$rtZinc <- rank(meuse$zinc)/(length(meuse)+1) -predMeuseNeigh <- getNeighbours(meuse[1:4,], meuse.grid[c(9:12,15:19,24:28,34:38),],"rtZinc",5L,TRUE,-1) +predMeuseNeigh <- getNeighbours(meuse[1:4,], meuse.grid[c(9:12,15:19,24:28,34:38),], + "rtZinc", 5L, TRUE, -1) qMar <- function(x) { qlnorm(x,mean(log(meuse$zinc)),sd(log(meuse$zinc))) From noreply at r-forge.r-project.org Mon Sep 9 10:58:05 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 9 Sep 2013 10:58:05 +0200 (CEST) Subject: [spcopula-commits] r108 - / pkg pkg/demo pkg/man Message-ID: <20130909085805.9B0EF185D93@r-forge.r-project.org> Author: ben_graeler Date: 2013-09-09 10:58:05 +0200 (Mon, 09 Sep 2013) New Revision: 108 Modified: pkg/DESCRIPTION pkg/NAMESPACE pkg/demo/pureSpVineCopula.R pkg/demo/spCopula.R pkg/man/calcBins.Rd pkg/man/getNeighbours.Rd pkg/man/getNeighbours.experimental.Rd pkg/man/getStNeighbours.Rd pkg/man/neighbourhood-class.Rd pkg/man/neighbourhood.Rd pkg/man/spCopPredict.Rd pkg/man/stCopPredict.Rd pkg/man/stNeighbourhood.Rd spcopula_0.1-1.tar.gz spcopula_0.1-1.zip Log: - moved sp and spacetime from depends to imports and adapted examples and demos to these changes. Modified: pkg/DESCRIPTION =================================================================== --- pkg/DESCRIPTION 2013-09-09 06:49:39 UTC (rev 107) +++ pkg/DESCRIPTION 2013-09-09 08:58:05 UTC (rev 108) @@ -10,7 +10,8 @@ Description: This package provides a framework to analyse via copulas spatial and spatio-temporal data provided in the format of the spacetime package. Additionally, support for calculating different multivariate return periods is implemented. License: GPL-2 LazyLoad: yes -Depends: copula (>= 0.999-7), spacetime (>= 1.0-2), VineCopula (>= 1.1-1), methods, R (>= 2.15.0) +Depends: copula (>= 0.999-7), VineCopula (>= 1.1-1), methods, R (>= 2.15.0) +Imports: sp, spacetime (>= 1.0-2) URL: http://r-forge.r-project.org/projects/spcopula/ Collate: Classes.R Modified: pkg/NAMESPACE =================================================================== --- pkg/NAMESPACE 2013-09-09 06:49:39 UTC (rev 107) +++ pkg/NAMESPACE 2013-09-09 08:58:05 UTC (rev 108) @@ -1,4 +1,5 @@ -import(copula, spacetime, VineCopula) +import(copula, VineCopula) +import(sp, spacetime) # constructor export(asCopula, cqsCopula) Modified: pkg/demo/pureSpVineCopula.R =================================================================== --- pkg/demo/pureSpVineCopula.R 2013-09-09 06:49:39 UTC (rev 107) +++ pkg/demo/pureSpVineCopula.R 2013-09-09 08:58:05 UTC (rev 108) @@ -1,6 +1,7 @@ ## librarys ## library(spcopula) # library(evd) +library(sp) ## meuse - spatial poionts data.frame ## data(meuse) Modified: pkg/demo/spCopula.R =================================================================== --- pkg/demo/spCopula.R 2013-09-09 06:49:39 UTC (rev 107) +++ pkg/demo/spCopula.R 2013-09-09 08:58:05 UTC (rev 108) @@ -1,5 +1,6 @@ ## librarys ## library(spcopula) +library(sp) # library(evd) ## meuse - spatial poionts data.frame ## Modified: pkg/man/calcBins.Rd =================================================================== --- pkg/man/calcBins.Rd 2013-09-09 06:49:39 UTC (rev 107) +++ pkg/man/calcBins.Rd 2013-09-09 08:58:05 UTC (rev 108) @@ -59,6 +59,7 @@ \code{\link{VineCopula-package}} } \examples{ +library(sp) data(meuse) coordinates(meuse) = ~x+y dataSet <- meuse Modified: pkg/man/getNeighbours.Rd =================================================================== --- pkg/man/getNeighbours.Rd 2013-09-09 06:49:39 UTC (rev 107) +++ pkg/man/getNeighbours.Rd 2013-09-09 08:58:05 UTC (rev 108) @@ -40,6 +40,7 @@ See \code{\link{neighbourhood}} for the native constructor of a \code{\linkS4class{neighbourhood}} class. } \examples{ +library(sp) spdf <- data.frame(x=c(112,154,212,289,345),y=c(124,198,85,168,346),measure=rlnorm(5)) coordinates(spdf) <- ~x+y Modified: pkg/man/getNeighbours.experimental.Rd =================================================================== --- pkg/man/getNeighbours.experimental.Rd 2013-09-09 06:49:39 UTC (rev 107) +++ pkg/man/getNeighbours.experimental.Rd 2013-09-09 08:58:05 UTC (rev 108) @@ -1,47 +1,48 @@ -\name{getNeighbours.experimental} -\alias{getNeighbours.experimental} - -\title{ -Creating Local Neighbourhoods -} -\description{ -This function calculates a local neighbourhood to be used for fitting of spatial/spatio-temporal vine copulas and for prediction using spatial/spatio-temporal vine copulas. -} -\usage{ -getNeighbours.experimental(dataLocs, predLocs, var = names(dataLocs)[1], size = 5, prediction=FALSE, min.dist = 0.01) -} -\arguments{ - \item{dataLocs}{ -some spatial data frame holding the data used for estimation/prediction -} - \item{predLocs}{ -A spatial object defining the prediction locations, might be missing if the neighbourhood is used for fitting. -} - \item{var}{ -the variable name of interest, by default the first variable is used. -} - \item{size}{ -The size of the neighbourhood including the location of interest (for fitting as well for prediction). -} - \item{prediction}{whether the neighbourhood should be used for prediction (TRUE) or spatial/Spatio-temporal vine copula fitting.} - \item{min.dist}{ -the minimal distance for a location to be included. Must be larger than 0 for fitting purposes and might be 0 for prediction. -} -} -\value{ -An object of \code{\linkS4class{neighbourhood}}. -} -\author{ -Benedikt Graeler -} - -\seealso{ -See \code{\link{neighbourhood}} for the native constructor of a \code{\linkS4class{neighbourhood}} class. -} -\examples{ -spdf <- data.frame(x=c(112,154,212,289,345),y=c(124,198,85,168,346),measure=rlnorm(5)) -coordinates(spdf) <- ~x+y - -getNeighbours.experimental(spdf,size=4) -} +\name{getNeighbours.experimental} +\alias{getNeighbours.experimental} + +\title{ +Creating Local Neighbourhoods +} +\description{ +This function calculates a local neighbourhood to be used for fitting of spatial/spatio-temporal vine copulas and for prediction using spatial/spatio-temporal vine copulas. +} +\usage{ +getNeighbours.experimental(dataLocs, predLocs, var = names(dataLocs)[1], size = 5, prediction=FALSE, min.dist = 0.01) +} +\arguments{ + \item{dataLocs}{ +some spatial data frame holding the data used for estimation/prediction +} + \item{predLocs}{ +A spatial object defining the prediction locations, might be missing if the neighbourhood is used for fitting. +} + \item{var}{ +the variable name of interest, by default the first variable is used. +} + \item{size}{ +The size of the neighbourhood including the location of interest (for fitting as well for prediction). +} + \item{prediction}{whether the neighbourhood should be used for prediction (TRUE) or spatial/Spatio-temporal vine copula fitting.} + \item{min.dist}{ +the minimal distance for a location to be included. Must be larger than 0 for fitting purposes and might be 0 for prediction. +} +} +\value{ +An object of \code{\linkS4class{neighbourhood}}. +} +\author{ +Benedikt Graeler +} + +\seealso{ +See \code{\link{neighbourhood}} for the native constructor of a \code{\linkS4class{neighbourhood}} class. +} +\examples{ +library(sp) +spdf <- data.frame(x=c(112,154,212,289,345),y=c(124,198,85,168,346),measure=rlnorm(5)) +coordinates(spdf) <- ~x+y + +getNeighbours.experimental(spdf,size=4) +} \keyword{ spatial } \ No newline at end of file Modified: pkg/man/getStNeighbours.Rd =================================================================== --- pkg/man/getStNeighbours.Rd 2013-09-09 06:49:39 UTC (rev 107) +++ pkg/man/getStNeighbours.Rd 2013-09-09 08:58:05 UTC (rev 108) @@ -43,6 +43,7 @@ } \examples{ ## the spatial version: +library(sp) spdf <- data.frame(x=c(112,154,212,289,345),y=c(124,198,85,168,346),measure=rlnorm(5)) coordinates(spdf) <- ~x+y Modified: pkg/man/neighbourhood-class.Rd =================================================================== --- pkg/man/neighbourhood-class.Rd 2013-09-09 06:49:39 UTC (rev 107) +++ pkg/man/neighbourhood-class.Rd 2013-09-09 08:58:05 UTC (rev 108) @@ -44,6 +44,7 @@ \code{\link{getNeighbours}} } \examples{ +library(sp) spdf <- data.frame(x=c(112,154,212,289),y=c(124,198,85,168),measure=rlnorm(4)) coordinates(spdf) <- ~x+y Modified: pkg/man/neighbourhood.Rd =================================================================== --- pkg/man/neighbourhood.Rd 2013-09-09 06:49:39 UTC (rev 107) +++ pkg/man/neighbourhood.Rd 2013-09-09 08:58:05 UTC (rev 108) @@ -25,6 +25,7 @@ \code{\linkS4class{neighbourhood}}, \code{\link{getNeighbours}} } \examples{ +library(sp) spdf <- data.frame(x=c(112,154,212,289),y=c(124,198,85,168),measure=rlnorm(4)) coordinates(spdf) <- ~x+y Modified: pkg/man/spCopPredict.Rd =================================================================== --- pkg/man/spCopPredict.Rd 2013-09-09 06:49:39 UTC (rev 107) +++ pkg/man/spCopPredict.Rd 2013-09-09 08:58:05 UTC (rev 108) @@ -48,6 +48,7 @@ spVineCop <- spVineCopula(spCop, vineCopula(4L)) +library(sp) data(meuse.grid) coordinates(meuse.grid) <- ~x+y gridded(meuse.grid) <- TRUE Modified: pkg/man/stCopPredict.Rd =================================================================== --- pkg/man/stCopPredict.Rd 2013-09-09 06:49:39 UTC (rev 107) +++ pkg/man/stCopPredict.Rd 2013-09-09 08:58:05 UTC (rev 108) @@ -46,6 +46,7 @@ spVineCop <- spVineCopula(spCop, vineCopula(4L)) +library(sp) data(meuse.grid) coordinates(meuse.grid) <- ~x+y gridded(meuse.grid) <- TRUE Modified: pkg/man/stNeighbourhood.Rd =================================================================== --- pkg/man/stNeighbourhood.Rd 2013-09-09 06:49:39 UTC (rev 107) +++ pkg/man/stNeighbourhood.Rd 2013-09-09 08:58:05 UTC (rev 108) @@ -26,6 +26,7 @@ } \examples{ ## the spatial version +library(sp) spdf <- data.frame(x=c(112,154,212,289),y=c(124,198,85,168),measure=rlnorm(4)) coordinates(spdf) <- ~x+y Modified: spcopula_0.1-1.tar.gz =================================================================== (Binary files differ) Modified: spcopula_0.1-1.zip =================================================================== (Binary files differ) From noreply at r-forge.r-project.org Wed Sep 18 15:13:11 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 18 Sep 2013 15:13:11 +0200 (CEST) Subject: [spcopula-commits] r109 - / pkg pkg/R Message-ID: <20130918131312.03446183B43@r-forge.r-project.org> Author: ben_graeler Date: 2013-09-18 15:13:11 +0200 (Wed, 18 Sep 2013) New Revision: 109 Removed: spcopula_0.1-1.tar.gz spcopula_0.1-1.zip Modified: / pkg/DESCRIPTION pkg/R/spatialPreparation.R Log: - corrected small bug in [[ for neighbourhood Property changes on: ___________________________________________________________________ Modified: svn:ignore - spcopula_1.0.48.tar.gz spcopula_1.0.48.zip .Rd2pdf6724 .Rhistory .Rproj.user spcopula.Rcheck spcopula.Rproj spcopula_1.0.66.tar.gz Meuse_spcopula_estimation.R man pkg.Rcheck pkg.pdf + .Rd2pdf6724 .Rhistory .Rproj.user Meuse_spcopula_estimation.R pkg.Rcheck pkg.pdf spcopula.Rcheck spcopula.Rproj Modified: pkg/DESCRIPTION =================================================================== --- pkg/DESCRIPTION 2013-09-09 08:58:05 UTC (rev 108) +++ pkg/DESCRIPTION 2013-09-18 13:13:11 UTC (rev 109) @@ -2,7 +2,7 @@ Type: Package Title: copula driven spatial analysis Version: 0.1-1 -Date: 2013-07-23 +Date: 2013-09-18 Authors at R: c(person("Benedikt", "Graeler", role = c("aut", "cre"), email = "ben.graeler at uni-muenster.de"), person("Marius", "Appel", role = "ctb")) @@ -10,7 +10,7 @@ Description: This package provides a framework to analyse via copulas spatial and spatio-temporal data provided in the format of the spacetime package. Additionally, support for calculating different multivariate return periods is implemented. License: GPL-2 LazyLoad: yes -Depends: copula (>= 0.999-7), VineCopula (>= 1.1-1), methods, R (>= 2.15.0) +Depends: copula (>= 0.999-7), VineCopula (>= 1.1-2), methods, R (>= 2.15.0) Imports: sp, spacetime (>= 1.0-2) URL: http://r-forge.r-project.org/projects/spcopula/ Collate: Modified: pkg/R/spatialPreparation.R =================================================================== --- pkg/R/spatialPreparation.R 2013-09-09 08:58:05 UTC (rev 108) +++ pkg/R/spatialPreparation.R 2013-09-18 13:13:11 UTC (rev 109) @@ -43,7 +43,7 @@ setMethod(spplot, signature("neighbourhood"), spplotNeighbourhood) selectFromNeighbourhood <- function(x, i) { - newSp <- x at locations[i,] + newSp <- x at dataLocs[i,] new("neighbourhood", data=x at data[i,,drop=F], distances=x at distances[i,,drop=F], dataLocs=newSp, predLocs=x at predLocs, bbox=newSp at bbox, Deleted: spcopula_0.1-1.tar.gz =================================================================== (Binary files differ) Deleted: spcopula_0.1-1.zip =================================================================== (Binary files differ)