library(RPostgreSQL) drv <- dbDriver("PostgreSQL") con <- dbConnect(drv, user="...", password="...", dbname="...", host="localhost") res <- dbGetQuery(con, "select artikel, max(preis) as preis, sum(menge) as menge from artikel left join aufpos on artikel.nr = aufpos.artikel group by artikel;") attach(res) preis menge m <- lm(menge ~ preis) summary(m) m <- lm(menge ~ preis ) m summar <- summary(m) summar coeff <- summar$coefficients b0 <- coeff["(Intercept)","Estimate"] b0p <- coeff["(Intercept)","Pr(>|t|)"] b1 <- coeff["preis","Estimate"] b1p <- coeff["preis","Pr(>|t|)"] b0p b1p cat("{\\rtf {\\fonttbl {\\f0 Times New Roman;}}\n", file="pm.rtf") cat("\\b Result:\\b0 \\par \nEs wurde das folgende lineare Modell geschaetzt:\n y = b0 + b1 * x + e\n", file="pm.rtf", append=T) cat("\\par\\par ", file="pm.rtf", append=T) cat(b0, file="pm.rtf", append=T) cat(" + ", file="pm.rtf", append=T) cat(b1, file="pm.rtf", append=T) cat(" * x\n", file="pm.rtf", append=T) sn <- 0.05 cat("\\par\\par Unser Signifikanznineau ist ", file="pm.rtf", append=T) cat(sn, file="pm.rtf", append=T) cat("\n\\par\\par Pr(>|t|) fuer b0: ", file="pm.rtf", append=T) cat(b0p, file="pm.rtf", append=T) if (b0p > sn) { cat("\n\\par\\par \\b nicht \\b0 signifikant!\n", file="pm.rtf", append=T) } cat("\n\\par\\par Pr(>|t|) fuer b1: ", file="pm.rtf", append=T) cat(b1p, file="pm.rtf", append=T) if (b1p > sn) { cat("\n\\par\\par \\b nicht \\b0 signifikant!\n", file="pm.rtf", append=T) } cat("\n}\n", file="pm.rtf", append=T)