2
$\begingroup$

I have fit a linear model and I now doing a lack-of-fit test. If the model has a good fit, the residual deviance should follow a $\chi^2$ distribution. The model I just ran has a very poor fit, and now I want to show this visually. I have used the following R code to plot the value of the residual deviance and the $\chi^2$ distribution it should come from (under the hypothesis of good fit).

df <- 384162 resdev <- 750749 x <- seq(from=350000, to=800000, by=1) y <- dchisq(x, df=df) plot(x, y, type='l') abline(v=resdev, col='red') 

Everything is working fine, except now the X-axis values are displaying in scientific notation. How to I control the formating of the axis values? I understand it may be crowded if I use normal notation, so can I format labels something like 350k for 350,000?

$\endgroup$

1 Answer 1

1
$\begingroup$

Look at function axis help page. Something like the following should work:

axis(1, at = x <- seq(3.5e5, 8e5, by = 5e4), labels = paste(x/1000, "k", sep = "" )) 
$\endgroup$
2
  • 1
    $\begingroup$ @Daniel: if applying this, turn off the x-axis in the plot() call: plot(x, y, type = "l", xaxt = "n") and change the two x s so you don't overwrite the data you created to draw the plot. $\endgroup$ Commented Dec 8, 2010 at 19:12
  • $\begingroup$ This worked, except it plotted the new axis over the old one. How would I address this issue? $\endgroup$ Commented Dec 8, 2010 at 19:16

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.