Back transform from normal (Gaussian) data to actual data

209 views Asked by At

I have converted raw data (a vector with some values) into normal (Gaussian) data, with mean = 0 and std = 1 with the following function:

nscores  <- qqnorm(RawVar)$x

Then, I wanted to convert the normal data back to Raw data. For that purpose, I have considered the backtr function as follow:

model <- data.frame(x = sort(RawVar), nscore = sort(nscores))
testbacktr <- backtr( nscores, model, tails = "none", draw = TRUE )

But, I do not get a reasonable answer. Is there any way to convert the data properly back to the actual units?

1

There are 1 answers

0
knstr On

a bit late, but here's my solution:

norm_trans <- function(x,x_backtr=NULL){
  #normal score transform data. mu=0, std=1:
  x_norm <- qqnorm(x)$x
  
  #backtransform data if the data to be backtransformed is available
  if (is.null(x_backtr)){
    return(x_norm)
  } else{
    return(approx(x_norm,x,x_backtr)$y)
  }
}

If only one vector with data is provided, then a (forward) normal score transfromation is performed. If a second vector is provided, then this vector is backtransformed using the transformation that would have been performed on the first vector.

I hope this helps?