pbreheny / visreg

Visualization of regression functions
http://pbreheny.github.io/visreg/
61 stars 18 forks source link

Spacing of fit point should account for xtrans #118

Closed pbreheny closed 3 months ago

pbreheny commented 3 months ago

For example, if x is on log scale, there are huge jumps between fit points at one end, and infinitesimal jumps at the other:

library(visreg)
y <- rnorm(100)
x <- rnorm(100) |> exp()

fit <- lm(y ~ log(x))
v <- visreg(fit, xtrans=log, plot=FALSE)

head(v$fit)
#>            x          y   visregFit  visregLwr visregUpr
#> 1 -3.3619860 0.03509659 -0.15937096 -0.7858621 0.4671202
#> 2 -1.8638006 0.03509659 -0.10206768 -0.4855609 0.2814255
#> 3 -1.2891754 0.03509659 -0.08008915 -0.3801425 0.2199642
#> 4 -0.9265592 0.03509659 -0.06621964 -0.3204345 0.1879952
#> 5 -0.6610104 0.03509659 -0.05606281 -0.2823695 0.1702439
#> 6 -0.4513858 0.03509659 -0.04804499 -0.2571641 0.1610741
tail(v$fit)
#>            x          y  visregFit  visregLwr visregUpr
#> 96  2.440098 0.03509659 0.06254979 -0.4062509 0.5313505
#> 97  2.450538 0.03509659 0.06294910 -0.4075328 0.5334310
#> 98  2.460870 0.03509659 0.06334428 -0.4088027 0.5354913
#> 99  2.471096 0.03509659 0.06373542 -0.4100608 0.5375316
#> 100 2.481219 0.03509659 0.06412260 -0.4113072 0.5395524
#> 101 2.491240 0.03509659 0.06450590 -0.4125422 0.5415540