Skip to content
This repository has been archived by the owner on Apr 13, 2020. It is now read-only.

Commit

Permalink
update example
Browse files Browse the repository at this point in the history
  • Loading branch information
bonartm committed Jan 24, 2018
1 parent 14ff83f commit b60d177
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 6 deletions.
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# Generated by roxygen2: do not edit by hand

export(factorCopula)
export(fitFactorCopula)
21 changes: 15 additions & 6 deletions R/simFactorCopula.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,22 @@ genBetaMat <- function(beta, theta){
return(matrix(as.numeric(beta), ncol = ncol(beta)))
}




#' Simulate values from a factor copula model
#'
#' @param beta a character matrix of size [NxK] indicating the names and position of the beta parameters (see example)
#' @param N the number of variables
#' @param Z a named list of size K and names equal to a random number generator function which takes an argument n and possibly other arguments passed as numeric values or characters (if parameter)
#' @param eps a named list of size 1 (see Z)
#' @param zFixed if TRUE zMatrix is only simulated once and stays fixed
#' @param epsFixed see zFixed
#' @param S the number of observations, only needed if zFixed or epsFixed is TRUE
#'
#' @return a function which can be used to simulate values from a factor copula model
#' @export
factorCopula <- function(beta, N, Z, eps, zFixed = FALSE, epsFixed = zFixed, S = NULL){
# Returns a function which can be used to simulate values from a factor copula model
# beta: a character matrix of size [NxK] indicating the names and position of the beta parameters (see example)
# Z: a named list of size K and names equal to a random number generator function which takes an argument n and possibly other arguments passed as numeric values or characters (if parameter)
# eps: a named list of size 1 (see Z)
# zFixed: if TRUE zMatrix is only simulated once and stays fixed
# epsFixed: see zFixed
# value: a function with arguments:
# theta: a named vector of parameters which is matched to the parameters in Z, eps and beta
# S: the number of simulations
Expand Down
14 changes: 14 additions & 0 deletions R/smm.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@ Q <- function(x, y, W){
t(diff)%*%W%*%diff
}

#' Fit a factor copula model
#'
#' @param Y A dataframe or matrix like object
#' @param copFun A copula function estimated by @references factorCopula
#' @param k A vector with length ncol(Y) defining the groups (e.q. equi-dependence or block-euqidependence model)
#' @param S The number of simulations to use
#' @param lower Lower bound for optimazation: Named vector with parameters
#' @param upper Upper bound for optimazation: Named vector with parameters
#' @param seed Fixed random number seed to use during optimazation
#' @param method "DEoptim", "genoud" or "subplex" (see Details)
#' @param control named list of arguments passed to the optimizer
#'
#' @return a list of optimazation results
#' @export
fitFactorCopula <- function(Y, copFun, k = rep(1, ncol(Y)), S, lower, upper, seed = runif(1, 1, .Machine$integer.max), method = c("DEoptim", "genoud", "subplex"), control) {
method <- match.arg(method)

Expand Down
29 changes: 29 additions & 0 deletions man/factorCopula.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions man/fitFactorCopula.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b60d177

Please sign in to comment.