#---------------------------# # Loesungen UeBlatt12 # #---------------------------# --------------- # Aufgabe 1 # --------------- N = 10000 n = 15 mu = -6 sigma = 2 T = rep(0,N) for(k in 1:N) { x = rnorm(n,mean=mu,sd=sigma) hatmu = sum(x)/n hats = sqrt( sum((x-hatmu)^2)/(n-1) ) T[k] = (hatmu-mu)/(hats/sqrt(n)) } hist(T,prob=TRUE,xlim=c(-10,10),ylim=c(0,0.5),breaks=60) curve(dt(x,df=n-1),col="red",add=TRUE) --------------- # Aufgabe 2 # --------------- # 2a) bevdata = read.table("C:/Users/detlef/OneDrive/hochschule/Vorlesungen/WS2122/Oekonometrie/Weltbevoelkerung.csv",header=TRUE,sep=";") bevdata bev = bevdata[,4] bev zeiten = bevdata[,3] zeiten plot(zeiten,bev) # 2b+c) zeiten[14] zeiten2 = zeiten[1:14] bev2 = bev[1:14] zeiten2 = zeiten2 -1950 zeiten = zeiten -1950 logbev2 = log(bev2) # Modell (1): res2 = lm(bev2 ~ zeiten2) a0 = res2\$coef[1] a1 = res2\$coef[2] a0 a1 bevfit1 = a0 + a1*zeiten # Modell (2): X = cbind(zeiten2,zeiten2^2) res3 = lm(bev2 ~ X ) b0 = res3\$coef[1] b1 = res3\$coef[2] b2 = res3\$coef[3] b0 b1 b2 bevfit2 = b0 + b1*zeiten + b2*zeiten^2 # Modell (3): res1 = lm(logbev2 ~ zeiten2) beta0 = res1\$coef[1] beta1 = res1\$coef[2] B0 = exp(beta0) r = beta1 B0 r bevfit3 = B0 * exp(r*zeiten) plot(zeiten,bev) lines(zeiten,bevfit1,col="red") lines(zeiten,bevfit2,col="blue") lines(zeiten,bevfit3,col="green")