Upload
studycam
View
10
Download
0
Embed Size (px)
DESCRIPTION
Homework solutions to applied linear regression wiley series in probability and statistics third editionContains selected problems for each chapter in the textbook. Statements of the problems are in the book. This documents only has the solutions
Citation preview
Applied Linear RegressionHomework #1
2.a) > seq(1,10,2) [1] 1 3 5 7 9Make a vector of sequential values from 1 to 10 in steps of 2.
b) > seq(1,5)-0.5[1] 0.5 1.5 2.5 3.5 4.5Make a vector of sequential values from 1 to 5 and subtracting 0.5 to each element of the vector.
c) > trials=rbinom(30,10,0.3)> trials [1] 3 4 2 4 3 1 1 5 1 2 4 2 3 4 3 5 2 2 3 3 6 3 5 1 6 2 0 1 3 3> hist(trials)
d) > my.breaks=seq(0,11)-0.5> hist(trials,breaks=my.breaks)
e) Because after the transformation it looks more normally distributed.
3.a) > library(car)Loading required package: MASSLoading required package: nnetLoading required package: survivalLoading required package: splines?car> data(Angell)?Angell> Angell
moral hetero mobilit region
yRochester 19 20.6 15 ESyracuse 17 15.6 20.2 EWorcester 16.4 22.1 13.6 EErie 16.2 14 14.8 EMilwaukee 15.8 17.4 17.6 MWBridgeport 15.3 27.9 17.5 EBuffalo 15.2 22.3 14.7 EDayton 14.3 23.7 23.8 MWReading 14.2 10.6 19.4 EDes_Moines 14.1 12.7 31.9 MWCleveland 14 39.7 18.6 MWDenver 13.9 13 34.5 WPeoria 13.8 10.7 35.1 MWWichita 13.6 11.9 42.7 MWTrenton 13 32.5 15.8 EGrand_Rapids 12.8 15.7 24.2 MWToledo 12.7 19.2 21.6 MWSan_Diego 12.5 15.9 49.8 WBaltimore 12 45.8 12.1 ESouth_Bend 11.8 17.9 27.4 MWAkron 11.3 20.4 22.1 MWDetroit 11.1 38.3 19.5 MWTacoma 10.9 17.8 31.2 WFlint 9.8 19.3 32.2 MWSpokane 9.6 12.3 38.9 WSeattle 9 23.9 34.2 WIndianapolis 8.8 29.2 23.1 MWColumbus 8 27.4 25 MWPortland_Oregon 7.2 16.4 35.8 WRichmond 10.4 65.3 24.9 SHouston 10.2 49 36.1 SFort_Worth 10.2 30.5 36.8 SOklahoma_City 9.7 20.7 47.2 SChattanooga 9.3 57.7 27.2 SNashville 8.6 57.4 25.4 SBirmingham 8.2 83.1 25.9 SDallas 8 36.8 37.8 SLouisville 7.7 31.5 19.4 SJacksonville 6 73.7 27.7 SMemphis 5.4 84.5 26.7 S
Tulsa 5.3 23.8 44.9 SMiami 5.1 50.2 41.8 SAtlanta 4.2 70.6 32.6 S
> head(Angell)
moral heteromobility region
Rochester 19 20.6 15 ESyracuse 17 15.6 20.2 EWorcester 16.4 22.1 13.6 EErie 16.2 14 14.8 EMilwaukee 15.8 17.4 17.6 MWBridgeport 15.3 27.9 17.5 E
b) > plot(Angell$hetero,Angell$moral)
> plot(Angell$moral~Angell$hetero)
4.a) > getwd()[1] "C:/Users/Carlos/Documents"
b) > write.csv(Angell,"Angell_data.csv")
c) > read.csv("C:/Users/Carlos/Documents/Angell_data.csv",header=TRUE)