[R] Simulate residuals with different properties for a linear model (regression)

2009-07-20 Thread Friedericksen Hope
Hey guys, for educational purposes I wonder if it is possible to simulate different data sets (or specifically residuals) for a linear regression. I would like to show my students residuals with different means, variances and distributions (normal, but also not normal) in the plots created with

Re: [R] Simulate residuals with different properties for a linear model (regression)

2009-07-20 Thread Juliet Hannah
Here are a couple of examples. # residuals not normal n - 100; x = seq(n) y = 10 + 10 *x + 20 * rchisq(n,df=2) non_normal_lm = lm(y~x) #non-constant variance n - 100; x = seq(n) y = 100 + 3 * x + rnorm(n,0,3) * x; het_var_lm = lm(y~x) #For each of these try: plot(non_normal_lm) plot(het_var_lm)

Re: [R] Simulate residuals with different properties for a linear model (regression)

2009-07-20 Thread hadley wickham
for educational purposes I wonder if it is possible to simulate different data sets (or specifically residuals) for a linear regression. I would like to show my students residuals with different means, variances and distributions (normal, but also not normal) in the plots created with the

Re: [R] Simulate residuals with different properties for a linear model (regression)

2009-07-20 Thread Friedericksen Hope
Thank you both for your responses and the hints for help! Greetings, Friedericksen Friedericksen Hope wrote: Hey guys, for educational purposes I wonder if it is possible to simulate different data sets (or specifically residuals) for a linear regression. I would like to show my students