rm(list=ls()) #A2 library(fda) library(KernSmooth) mae<-growth$hgtf dim(mae) ju<-growth$hgtm gall<-cbind(mae,ju) time<-growth$age gesf<-matrix(NA,401,93) veloc<-gesf accel<-gesf for (i in 1:93) { gesf[,i]<-locpoly(time,gall[,i],bandwidth=1)$y t<-locpoly(time,gall[,i],bandwidth=1)$x veloc[,i]<-locpoly(time,gall[,i],bandwidth=1,drv=1)$y accel[,i]<-locpoly(time,gall[,i],bandwidth=1,drv=2)$y } par(mfrow=c(1,3)) matplot(t,gesf,type="l",col=3,main="Wachstum") lines(t,apply(gesf,1,mean),lwd=2) abline(v=0,h=0,lty=2) matplot(t,veloc,type="l",col=3,main="Geschwindigkeit") abline(v=0,h=0,lty=2) #negative Geschwindigkeiten? lines(t,apply(veloc,1,mean),lwd=2) matplot(t,accel,type="l",col=3,main="Beschleunigung") lines(t,apply(accel,1,mean),lwd=2) abline(v=0,h=0,lty=2) par(mfrow=c(3,3)) matplot(t,gesf[,1:54],type="l",col="plum2",main="Wachstum",ylim=range(gesf)) lines(t,apply(gesf[,1:54],1,mean),lwd=2,col=2) matplot(t,gesf[,55:93],type="l",col="skyblue",main="Wachstum",ylim=range(gesf)) lines(t,apply(gesf[,55:93],1,mean),lwd=2,col=4) matplot(t,gesf,type="l",col=c(rep("plum2",54),rep("skyblue",39)),main="Wachstum") lines(t,apply(gesf[,1:54],1,mean),lwd=2,col=2) lines(t,apply(gesf[,55:93],1,mean),lwd=2,col=4) #par(mfrow=c(1,3)) matplot(t,veloc[,1:54],type="l",col="plum2",main="Geschwindigkeit",ylim=range(veloc)) lines(t,apply(veloc[,1:54],1,mean),lwd=2,col=2) matplot(t,veloc[,55:93],type="l",col="skyblue",main="Wachstum",ylim=range(veloc)) lines(t,apply(veloc[,55:93],1,mean),lwd=2,col=4) matplot(t,veloc,type="l",col=c(rep("plum2",54),rep("skyblue",39)),main="Geschwindigkeit") lines(t,apply(veloc[,1:54],1,mean),lwd=2,col=2) lines(t,apply(veloc[,55:93],1,mean),lwd=2,col=4) #par(mfrow=c(1,3)) matplot(t,accel[,1:54],type="l",col="plum2",main="Beschleunigung",ylim=range(accel)) lines(t,apply(accel[,1:54],1,mean),lwd=2,col=2) matplot(t,accel[,55:93],type="l",col="skyblue",main="Beschleunigung",ylim=range(accel)) lines(t,apply(accel[,55:93],1,mean),lwd=2,col=4) matplot(t,accel,type="l",col=c(rep("plum2",54),rep("skyblue",39)),main="Beschleunigung") lines(t,apply(accel[,1:54],1,mean),lwd=2,col=2) lines(t,apply(accel[,55:93],1,mean),lwd=2,col=4)