Error in plot.window (...): need finite 'ylim' values

4

I have a continuous variable whose n=15000 remarks and displays 451 NA's. When running qqnorm to evaluate the normality, I verified that it does not present normality and so I applied a logarithmic transformation. However, when running qqnorm with the log-transformed variable, the graph was not plotted and the following error message appeared:

Error in plot.window(...) : need finite 'ylim' values

Below the script in the order explained above:

> summary(data1$microalb)
Min.  1st Qu.   Median     Mean  3rd Qu.     Max.     NA's 
0.0000   0.3474   0.5042   1.3220   0.8426 308.0000      451 

> qqnorm(data1$microalb) # inspecionando a normalidade
> log.microalb=log(data1$microalb) # aplicando transformação logarítmica
> qqnorm(log.microalb, main="Q-Q Plot - Log microalb", xlab="Quantis Teóricos", ylab= "Quantis Observados")

I deleted the NA's from the variable, but the error persisted, so probably the problem is not in the missings. What could be making qqnorm generation with log-transformed data impossible?

NOTE: I applied the same transformation to other variables and there was no problem, just that.

    
asked by anonymous 07.09.2017 / 14:06

1 answer

3

The minimum of data1$microalb is zero. Therefore, log(min(data1$microalb)) = -Inf . Rotate summary(log.microalb) to confirm this.

Delete the infinite information from your data set. A common way to do this is to add 1 to the vector that must be plotted, because log(1) = 0 . Therefore,

qqnorm(log.microalb+1, main="Q-Q Plot - Log microalb", 
  xlab="Quantis Teóricos", ylab= "Quantis Observados")

It should solve your problem.

If you just want to remove infinite observations from your data set, run

qqnorm(log.microalb[!is.infinite(log.microalb)])

although this solution is not the most common in the literature. The most used procedure is just the previous one, adding 1 to the data.

    
07.09.2017 / 14:19