demo/dyn-na.R

library(dyn)

x.zoo <- structure(c(NA, NA, NA, 1.59528080213779, 0.329507771815361, 
-0.820468384118015, 0.487429052428485, 0.738324705129217, 0.575781351653492, 
-0.305388387156356, NA, NA, NA, -2.2146998871775, 1.12493091814311, 
-0.0449336090152309, -0.0161902630989461, 0.94383621068530, 0.821221195098089, 
0.593901321217509, 0.918977371608218, 0.782136300731067, 0.0745649833651906, 
-1.98935169586337, 0.61982574789471, -0.0561287395290008, -0.155795506705329, 
-1.47075238389927, -0.47815005510862, 0.417941560199702, 1.35867955152904, 
-0.102787727342996, 0.387671611559369, -0.0538050405829051, -1.37705955682861, 
-0.41499456329968, -0.394289953710349, -0.0593133967111857, 1.10002537198388, 
0.763175748457544), .Dim = c(20, 2), .Dimnames = list(NULL, c("gdp", 
"ipi")), index = c(1950, 1950.25, 1950.5, 1950.75, 1951, 1951.25, 
1951.5, 1951.75, 1952, 1952.25, 1952.5, 1952.75, 1953, 1953.25, 
1953.5, 1953.75, 1954, 1954.25, 1954.5, 1954.75), frequency = 4, 
class = c("zooreg", "zoo"))
x.zoo.mf <- dyn$model.frame(formula = lag(gdp) ~ lag(gdp, -2) + lag(ipi, -1), 
	data = x.zoo, na.action = na.exclude)
x.zoo.lm <- dyn$lm(formula = gdp ~ lag(gdp, -2) + lag(ipi, -1), 
		data = x.zoo, na.action = na.omit)
fitted(x.zoo.lm)
resid(x.zoo.lm)

predict(x.zoo.lm, x.zoo)

Try the dyn package in your browser

Any scripts or data that you put into this service are public.

dyn documentation built on May 30, 2017, 1:09 a.m.