1981 年から 1986 年までの各YEAR (1982...1985) および各AGEグループ (10-14,..., 55-59)の調査間の人口推定値を計算しようとしています。私のデータセットの複雑な要因は、52 の州と約 600 の ZONA91OK (地区) があり、各州には異なる数の地区があることです。
欠落している YEAR、NATIONALITY、PROVINCE、および各地区 (ZONA91OK) の情報を含むベクトルを取得するために適用したい式は次のとおりです。
元。1982年
1982 年、年齢グループ 10 ~ 14 の値: x(10,1982)=[(x(10,1981)-x(15,1986))/5]-x(10,1982)
x(15,1982)= [(x(15,1981)-x(20,1986))/5]-x(15,1982)
x(20,1982)=[(x(20,1981)-x(25,1986))/ 5]-x(20,1982)
...
x(55,1982)=[(x(55,1981)-x(55,1986))/5]-x(55,1982) -例外-
この問題に関するヘルプは大歓迎です!
再現可能なサンプルは次のとおりです (非常に大きいため、データベース全体のサブセット)。
mydata<-structure(list(YEAR = c(1981, 1981, 1981, 1981, 1981, 1981, 1981,
1981, 1981, 1981, 1981, 1981, 1981, 1981, 1981, 1981, 1981, 1981,
1981, 1981, 1981, 1981, 1981, 1981, 1981, 1981, 1981, 1981, 1981,
1981, 1981, 1981, 1981, 1981, 1981, 1981, 1986, 1986, 1986, 1986,
1986, 1986, 1986, 1986, 1986, 1986, 1986, 1986, 1986, 1986, 1986,
1986, 1986, 1986, 1986, 1986, 1986, 1986, 1986, 1986, 1986, 1986,
1986, 1986, 1986, 1986, 1986, 1986, 1986, 1986, 1986, 1986),
PROVINCE = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
ZONA91OK = c(101, 101, 101, 101, 101, 101, 101, 101, 101,
102, 102, 102, 102, 102, 102, 102, 102, 102, 1036, 1036,
1036, 1036, 1036, 1036, 1036, 1036, 1036, 1059, 1059, 1059,
1059, 1059, 1059, 1059, 1059, 1059, 101, 101, 101, 101, 101,
101, 101, 101, 101, 102, 102, 102, 102, 102, 102, 102, 102,
102, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036,
1059, 1059, 1059, 1059, 1059, 1059, 1059, 1059, 1059), AGE5 = c(10,
15, 20, 25, 30, 35, 40, 45, 50, 10, 15, 20, 25, 30, 35, 40,
45, 50, 10, 15, 20, 25, 30, 35, 40, 45, 50, 10, 15, 20, 25,
30, 35, 40, 45, 50, 10, 15, 20, 25, 30, 35, 40, 45, 50, 10,
15, 20, 25, 30, 35, 40, 45, 50, 10, 15, 20, 25, 30, 35, 40,
45, 50, 10, 15, 20, 25, 30, 35, 40, 45, 50), NATIONALITY = structure(c(9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L), .Label = c("España",
"UE-15 y PD", "Resto Europa", "Magreb", "África Sub-sahariana",
"Latinoamérica", "Asia", "Resto del Mundo", "No computable"
), class = "factor"), FREQUENCY = c(993.8141, 994.907, 894.0322,
845.8348, 659.6786, 577.2588, 540.6329, 684.9917, 673.6348,
910.511, 1068.9258, 936.9949, 763.547, 643.4404, 572.72,
536.6591, 665.975, 768.6866, 967.694100000002, 980.340100000001,
811.637500000001, 746.058500000001, 769.820600000001, 722.398000000001,
730.371600000001, 690.084600000001, 501.9178, 8243.04149999997,
7785.02419999994, 7505.78429999991, 7464.74579999992, 7663.47079999997,
6700.90559999997, 5203.31959999996, 5582.66059999997, 4837.30459999996,
869.1754, 982.7461, 945.5031, 904.2817, 813.7127, 663.955,
577.2896, 544.1257, 689.9815, 780.3824, 879.7538, 1025.5724,
882.475, 716.0049, 627.3571, 579.4372, 525.4546, 679.9666,
1035.6544, 952.521599999999, 962.537599999999, 832.3296,
733.1696, 726.1568, 704.1248, 700.1136, 667.0624, 9023.05139999993,
8285.31719999994, 8080.95919999994, 8175.28479999993, 7786.53429999994,
7796.56439999994, 6842.11639999996, 5239.83509999998, 5616.95939999997
)), .Names = c("YEAR", "PROVINCE", "ZONA91OK", "AGE5", "NATIONALITY",
"FREQUENCY"), row.names = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L,
10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L,
23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L,
36L, 8173L, 8174L, 8175L, 8176L, 8177L, 8178L, 8179L, 8180L,
8181L, 8182L, 8183L, 8184L, 8185L, 8186L, 8187L, 8188L, 8189L,
8190L, 8191L, 8192L, 8193L, 8194L, 8195L, 8196L, 8197L, 8198L,
8199L, 8200L, 8201L, 8202L, 8203L, 8204L, 8205L, 8206L, 8207L,
8208L), class = "data.frame")