Error in Plot.window(...) : need Finite 'ylim' values

Asked

Viewed 688 times

4

I have a continuous variable whose n=15000 comments and 451 Als. When rotating the qqnorm For the evaluation of normality, I verified that it does not present normality and therefore I applied a logarithmic transformation. However, when rotating the 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 Als from the variable, but the error persisted, so the problem is probably not in the missings. What could be preventing qqnorm generation with log-transformed data?

OBS.: I applied the same transformation in other variables and there was no problem, only in this one.

1 answer

4


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

Delete the infinite information from your dataset. A common way to do this is to add 1 to the vector that should be plotted, as log(1) = 0. Therefore,

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

should solve your problem.

If you just want to remove the 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 precisely the previous one, adding 1 to the data.

  • Hey, Marcus, thanks for the suggestion. However I tried to run the two suggested ways and this time the following error message appears: Error in qqnorm.default(log.microalb[! is.Infinite(log.microalb)]) : y is Empty or has only Nas Error in qqnorm.default(log.microalb + 1, main = "Q-Q Plot - Log microalb", : y is Empty or has only Nas

  • log.microalb exists? What is the output of summary(log.microalb)?

  • Yes, there is: > Summary(log.microalb) Min. 1st Qu. Median Mean 3rd Qu. Max. NA’s -Inf -1.0570 -0.6847 -Inf -0.1713 5.7300 451

  • Marcus, o seguinte plot funcionou: qqnorm(log.microalb[!is.infinite(log.microalb)]) Entretanto, o seguinte plot apresentou uma mensagem de erro: > qqnorm(log.microalb.mgdl+1, main="Q-Q Plot - Log microalb.mgdl", 
+ xlab="Quantis Teóricos", ylab= "Quantis Observados") Error in Plot.window(...) : need Finite 'ylim' values Anyway, thanks for the suggestions, the second one worked.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.