用协变量绘制和建模纵向数据

时间:2015-04-09 15:21:04

标签: r

我有96个国家10年的数据。这些数据是关于奥运会10年的国家奖牌数,那些年的人口和国内生产总值。 我想绘制数据,以便我可以检查图中是否存在主题特定效果。我该怎么做?

我尝试使用:

library(lattice)
xyplot(medals ~ pop|Year + Countries)

并收到以下错误:

Error in UseMethod("depth") : 
  no applicable method for 'depth' applied to an object of class "NULL"

另外,如果我想要拟合转换模型,我该如何确定AR的顺序?

1 个答案:

答案 0 :(得分:0)

对于玩具数据,您需要从格子中获得什么?我不能在最后评论过渡模型问题。

Countries <- c("A", "B", "C", "D")
medals <- 1:4
gdp <- seq(1000000000, 4000000000, 1000000000)
pop <- seq(10000000, 40000000, 10000000)
Year <- c("1970", "1980", "1990", "2000") 
df <- cbind(Countries = country, medals = as.integer(medals), gdp = as.numeric(gdp),
                                                   pop = as.numeric(pop), Year = as.factor(Year))
df.two <- as.data.frame(df)

library(lattice)
xyplot(data = df.two, medals ~ pop|Year + Countries)

enter image description here