|  |  | 
estimateCoefsTruncatedPInv <- function(x, y, rds, order) { 
estimateVolterraModel <- function(x, y, rds, order) {
  
    # project stimuli in relevant dimensions
  
    px <- x%*%rds
  
    # build data matrix of Volterra linear equation
  
    dataMatrix <- buildDataMatrix(px=px, order=order, nRDs=ncol(rds))
  
    # solve the Volterra linear equation 
  
    coefs <- solveTruncatedPInv(x=dataMatrix, y=y)
  
    return(coefs)
}
  
    # estimate coefficients of the low-dimensional Volterra problem
  
    coefs <- estimateCoefsTruncatedPInv(x=x, y=y, rds=rds, order=order)
  
    # reconstruct the first and second order kernels
  
    k1 <- getK1FromCoefsAndRDs(coefs=coefs, rds=rds)
  
    k2 <- getK2FromCoefsAndRDs(coefs=coefs, rds=rds)
  
    return(list(coefs=coefs, k1=k1, k2=k2))
}