r - Interpolation with na.approx : How does it do that? -


i doing light un-suppression of employment data, , stumbled on na.approx approach in zoo package. data represents percentage of total government employment, , figured rough estimate @ trends of change between state , local government. should add one.

        state % local % 2001    na  na 2002    na  na 2003    na  na 2004    0.118147539 0.881852461 2005    0.114500321 0.885499679 2006    0.117247083 0.882752917 2007    0.116841331 0.883158669 

i use spline setting allows estimation of leading na's

z <- zoo(df2,1:7)     d<-na.spline(z,na.rm=false,maxgap=inf) 

which gives output:

state % local % 0.262918013 0.737081987 0.182809891 0.817190109 0.137735231 0.862264769 0.118147539 0.881852461 0.114500321 0.885499679 0.117247083 0.882752917 0.116841331 0.883158669 

great right? part amazes me that, approximated na values sum 1 (which want, unexpected!) documentation na.approx says each column separately, column-wise. missing something? money's on mis-reading documentation

i believe it's chance property of linear least squares. slopes of both regressions sum zero, result of constraint sum of series equals one; , intercepts sum one. hence fitted values both regressions @ point in time sum one.

edit: bit more explanations.
y1 = + beta * t + epsilon
y2 = 1-y1 = (1-a) + (- beta) * t - epsilon
therefore, running ols give intercepts summing one, , slopes zero.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -