~ubuntu-branches/ubuntu/maverick/openturns/maverick

« back to all changes in this revision

Viewing changes to debian/rotRPackage/R/computeResidualLm.R

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Prud'homme
  • Date: 2008-10-03 10:55:20 UTC
  • Revision ID: james.westby@ubuntu.com-20081003105520-i4sqk110f19vp7hd
Tags: 0.12.1-6
* debian/rules: Fix FTBS on hppa, sparc, arm, and armel because of
  __sync_fetch_and_add_4 not being available, the remedy is to use
  -DBOOST_SP_USE_PTHREADS
* debian/rules: add --disable-debug option to configure and set the
  compiler flags to -g -O2 (no -Wall)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
"computeResidualLm" <-
 
2
function(x, beta, y){
 
3
  
 
4
  # Checking for NAs in y, beta is assumed not to contain any
 
5
  indexNA <- which(is.na(y))
 
6
 
 
7
  if(length(indexNA) > 0) {
 
8
    x[indexNA, ] <- NA 
 
9
  }
 
10
 
 
11
  # Checking for NAs in x, beta is assumed not to contain any
 
12
  indexNA <- which(is.na(x), arr.ind=TRUE)
 
13
 
 
14
  if(length(indexNA) > 0) {
 
15
 
 
16
    x[indexNA[, 1], ] <- NA 
 
17
    y[indexNA[, 1]] <- NA
 
18
    # Eliminating the NAs
 
19
    x <- matrix(x[ ! is.na(x)], ncol = ncol(x))
 
20
    y <- y[ ! is.na(y)]
 
21
  }
 
22
 
 
23
  # Computing the residual. 
 
24
  completeX <- cbind(rep(1, nrow(x)), x)
 
25
  predictedSample <- completeX %*% beta
 
26
  residual <- y - predictedSample  
 
27
 
 
28
  return(residual)
 
29
 
 
30
}
 
31