koti tentti: data tiedosto/home exam data

tekijä: Dario Gasbarra Viimeisin muutos perjantai 08. huhtikuuta 2011, 12.20

Objective-C source code icon home_exam_data.m — Objective-C source code, 1 KB (1570 bytes)

Tiedoston sisältö

######### brake-data for exercise 2 

x<-c( 4,4,7,7,8,9,10,10,10,11,11,12,12,12,12,13,13,13,13,14,14,14,14,15,15,15,
     16,16,17,17,17,18,18,18,18,19,19,19,20,20,20,20,20,22,23,24,24,24,24,25)
y<-c(2,10,4,22,16,10,18,26,34,17,28,14,20,24,28,26,34,34,56,26,36,60,80,20,26,
     54,32,40,32,40,50,42,56,76,84,36,46,68,32,48,52,56,64,66,54,70,92,93,120,85 )


#R-code

regressiondata<-data.frame(x,y)

#linear model

fitted.model <- lm(y~x, regressiondata)
 fitted.model
plot( x, y)
lines(x,fitted.model$coefficients[1]+fitted.model$coefficients[2]*x   )
summary(fitted.model)

#quadratic model

fitted.model <- lm(y~x+I(x^2), regressiondata)
 fitted.model
plot( x, y)
lines(x,fitted.model$coefficients[1]+fitted.model$coefficients[2]*x +fitted.model$coefficients[3]*x^2   )
summary(fitted.model)


################# exercise 3: mixed model data

X=c(-0.0153,0.0305,-0.0120,0.0856,0.1742,0.0465,0.1982,0.1541,0.3241,0.0961,0.0981,0.5720,0.4922,0.4976,
 0.6387,0.8265,0.8685,1.0255,1.1858,1.1593,1.2203,1.3839,1.5694,1.3769,1.4005,1.5517,1.4777,1.4597,1.6067,
 1.6918,1.6941,1.5925,1.7422,1.9580,2.2188,2.2998,2.6073,2.7795,2.7310,3.0587,3.3305,3.5364,3.4311,3.5320,
 3.6299,3.8725,3.7669,3.8347,3.5253,3.5071,3.3509,3.3257,3.2347,3.0698,3.3924,2.3479,2.1231,1.7488,1.1923,
 1.4268,1.3024,1.0590,0.8167,0.9264,0.5895,0.8094,0.8233,0.7721,0.6843,0.5710,0.6625,0.5485,0.3989,0.5159,
 0.4660,0.3813,0.5022,0.4332,0.4025,0.3460,0.5640,0.4776,0.3380,0.3575,0.4999,0.5250,0.4405,0.2898,0.1683,
 0.2838,0.1174,0.0647,0.1204,0.1818,0.1004,0.0915,0.1725,0.0785,-0.0797,0.1072 )