{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# Rforch12 - R Material for Chapter 12 >...

This preview shows pages 1–3. Sign up to view the full content.

R Material for Chapter 12 > attach(binjuries.data) > binjuries.data ## Bicycle Injury Data year injuries 1 1 5696 2 2 5110 3 3 4731 4 4 4585 5 5 4476 6 6 4970 7 7 4991 8 8 4820 9 9 4515 10 10 4227 > reg <- lm(injuries~year) > summary(reg) Call: lm(formula = injuries ~ year) Residuals: Min 1Q Median 3Q Max -382.2 -276.3 0.4 230.0 468.6 Coefficients: Estimate Std. Error t value Pr(>|t|) ## Usual LS Fit (Intercept) 5319.73 219.50 24.236 8.96e-09 *** year -92.30 35.38 -2.609 0.0312 * --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 321.3 on 8 degrees of freedom Multiple R-squared: 0.4597, Adjusted R-squared: 0.3922 F-statistic: 6.807 on 1 and 8 DF, p-value: 0.03118 >library(car) ## Library required for Durbin-Watson Test > dwt(reg) ## Durbin-Watson Test lag Autocorrelation D-W Statistic p-value 1 0.380236 0.9388191 0.024 Alternative hypothesis: rho != 0 > diff1 <- rep(0,9) > for(i in 1:9) {diff1[i] <- injuries[i+1]-.380236*injuries[i]} > diff1 [1] 2944.176 2787.994 2786.103 2732.618 3268.064 3101.227 2922.242 2682.262 [9] 2510.234 > index1 <- rep(0,9) > for(i in 1:9) {index1[i] <- year[i+1]-.380236*year[i]} > index1 [1] 1.619764 2.239528 2.859292 3.479056 4.098820 4.718584 5.338348 5.958112 [9] 6.577876

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
> reg2 <- lm(diff1~index1) > summary(reg2) Call: lm(formula = diff1 ~ index1) Residuals: Min 1Q Median 3Q Max -255.1 -142.0 -106.6 109.9 408.6 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 3015.08 214.46 14.059 2.18e-06 *** index1 -37.97 48.74 -0.779 0.461 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern