Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Simple Linear Regression: Estimating and Comparing Regression Lines using R - Prof. Alexei, Study notes of Data Analysis & Statistical Methods

An example of how to estimate and compare regression lines using r for a given dataset. It covers various functions such as lm() and glm(), and calculates statistics like sxx, sxy, syy, and predicts y values for new x values. It also includes a simulation part to understand the sampling distribution of the estimators.

Typology: Study notes

2009/2010

Uploaded on 12/09/2010

cmoy21
cmoy21 🇺🇸

2 documents

1 / 2

Toggle sidebar

Related documents


Partial preview of the text

Download Simple Linear Regression: Estimating and Comparing Regression Lines using R - Prof. Alexei and more Study notes Data Analysis & Statistical Methods in PDF only on Docsity! ## Simple Linear Regression STAT 420 Fall 2008 Examples for 09/23/2008 ## Data x = c(2,6,8,8,12,16,20,20,22,26) y = c(58,105,88,118,117,137,157,169,149,202) N = length(x) ## Estimate the regression line using pre-defined R functions fit = lm(y ~ x) fit summary(fit) names(fit) plot(x, y) abline(fit$coefficients) fit$fitted.values fit$residuals sum(fit$residuals^2) sum((y-fit$fitted.values)^2) s2 = sum(fit$residuals^2)/(N-2); s2 s = sqrt(s2); s ## SXX, SXY, SYY sum((x-mean(x))^2) sum((x-mean(x))*(y-mean(y))) sum((y-mean(y))^2) ## Predicting Y values predict(fit,data.frame(x=10)) predict(fit,data.frame(x=38)) ## Estimate the regression line using pre-defined R functions fit1 = glm(y ~ x) fit1 summary(fit1) names(fit1) ########## ########## ########## ## True relationship alpha = 10 beta = 5 truevar = 10
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved