pendensity-package {pendensity} | R Documentation |
The package 'pendensity' offers routines for estimating penalized unconditional and conditional (on factor groups) densities. For details see the description of the function pendensity.
Package: | pendensity |
Type: | Package |
Version: | 0.2 |
Date: | 2009-10-27 |
License: GPL (>= 2) LazyLoad: | yes |
The packages contributes the function 'pendensity()' for estimating densities using penalized splines techniques.
Christian Schellhase <cschellhase@wiwi.uni-bielefeld.de>
Density Estimation with a Penalized Mixture ApproachPenalized Density Estimation, Kauermann G. and Schellhase C. (2009), to appear.
y <- rnorm(100) test <- pendensity(y~1) plot(test) ################# #second simple example #with covariate x <- rep(c(0,1),200) y <- rnorm(400,x*0.2,1) test <- pendensity(y~as.factor(x)) plot(test) ################# #density-example of the stock exchange Allianz in 2006 data(Allianz) form<-'%d.%m.%y' time.Allianz <- strptime(Allianz[,1],form) #looking for all dates in 2006 data.Allianz <- Allianz[which(time.Allianz$year==106),2] #building differences of first order d.Allianz <- diff(data.Allianz) #estimating the density density.Allianz <- pendensity(d.Allianz~1) plot(density.Allianz) ################# #density-example of the stock exchange Allianz in 2006 and 2007 data(Allianz) form<-'%d.%m.%y' time.Allianz <- strptime(Allianz[,1],form) #looking for all dates in 2006 data.Allianz <- Allianz[which(time.Allianz$year==106|time.Allianz$year==107),2] #building differences of first order d.Allianz <- diff(data.Allianz) #estimating the density density.Allianz <- pendensity(d.Allianz~as.factor(time.Allianz$year)) plot(density.Allianz,legend.txt=c("2006","2007"))