# generate data to fit m <- 2; c <- -1; sy <- 1.2 mux <- 3:20 muy <- m*mux + c n <- length(mux) x <- mux y <- muy + rnorm(n, 0, sy) # least square fit fit <- lm(y ~ x) abline(fit, col='red') fit # command from console str(fit) # command from console # http://www.public.iastate.edu/~alicia/stat544/software.htm source("writeDatafileR.txt") writeDatafileR(list(x=x, y=y, n=n, x1=1.5*x[n]), "fit_data_OB.txt") writeDatafileR(list(m=1, c=0, tau=1/2^2, y1=x[n]), "fit_inits_OB.txt") # inits do not need to be close to expectations!