Regression over multiple Countries

Hi everyone,

I'm trying to run a time fixed effects regression over multiple countries. Looking at the export to the US for all the countries. I have the correct 'formula' to put in R but i just can't do it over all countries. I want to see the effect over all the countries combined as one variable, but not all countries separately.

The dataset is as followed:
'Year' - Export_country 1 - Export_country 2, etc - Other variable - Other variable

|Year | Export_country1 | Export_Country2 | ControlVariable | other variable|

|--- | --- | --- | --- | ---|

| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |

Does someone know what i'm doing wrong? I think the solution is close but I just don't know.

The formula I use:
tfe<- plm(formula = Export (which should be of all the countries) ~ GDP worldwide + partij_dummy, data = df, index = c("Year"), model = "within", effect = "time")

Thanks in advance!

Hi Thom,

Could you do two things?

  1. Tell us the dimensions of the table df that you're using, and
  2. Post a screenshot showing both the command you executed (but didn't give you the results you wanted), along with the output of that command.

This would help folks begin to understand how they could be of help to you.

It will help if you post your data using dput(), or at least a portion of it.

My guess is you want to use pivot_longer() to make one export variable.

Thank you for your response! Ofcourse:

  1. [1] 51 63

(if the screenshot doesn't work):
Call:
plm(formula = Export_Totaal ~ Procentuele_Groei_BBP + partij_dummy,
data = Alles_Totaal_3_, effect = "time", model = "within",
index = c("Jaar"))

Balanced Panel: n = 51, T = 1, N = 51

Residuals:
Min. 1st Qu. Median 3rd Qu. Max.
-1407.09 -806.55 -501.01 1098.88 2019.68

Coefficients:
Estimate Std. Error t-value Pr(>|t|)
Procentuele_Groei_BBP -7207.35 8969.84 -0.8035 0.4256
partij_dummy 488.53 302.29 1.6161 0.1126

Total Sum of Squares: 57550000
Residual Sum of Squares: 54030000
R-Squared: 0.061177
Adj. R-Squared: 0.022059
F-statistic: 1.56392 on 2 and 48 DF, p-value: 0.21979

i hope this is what you need!

Thank you for thinking with me!

does this help?

the first few years are NA for some countries but that's okay for now!

This is helpful. Now could execute the following code?

# direct output to new file, "for_posit.txt"
sink("for_posit.txt")

# write content of table to file
dput(Alles_Totaal_3_)

# redirect output back to console (very important!)
sink()

then open the file "for_posit.txt", select all, copy, and paste here, alsjeblieft? That is, between a pair of triple backticks, like this:

``` r
[<-- paste here]
```
1 Like

That looks good. What isn't working?

Thanks!

structure(list(Jaar = c(1971, 1972, 1973, 1974, 1975, 1976, 1977, 
1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 
1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 
2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 
2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021
), Export_Totaal = c(62.34, 74.22, 91.16, 127.47, 122.73, 151.15, 
182.44, 212.25, 252.67, 293.83, 317.76, 303.18, 328.64, 405.11, 
417.23, 452.87, 508.72, 553.99, 591.03, 629.73, 623.54, 667.79, 
719.97, 813.42, 902.57, 963.97, 1055.77, 1115.69, 1252.46, 1477.18, 
1403.56, 1437.72, 1557.12, 1810.5, 2041.48, 2256.62, 2395.23, 
2576.15, 2001.93, 2389.56, 2695.48, 2769.32, 2766.38, 2887.45, 
2794.85, 2738.36, 2924.99, 3131.17, 3117.24, 2776.12, 3401.36
), Procentuele_Groei_BBP = c(0.043, 0.056, 0.064, 0.018, 0.006, 
0.053, 0.041, 0.041, 0.042, 0.019, 0.02, 0.003, 0.026, 0.047, 
0.037, 0.034, 0.037, 0.046, 0.037, 0.028, 0.014, 0.02, 0.018, 
0.033, 0.031, 0.036, 0.039, 0.029, 0.036, 0.045, 0.02, 0.023, 
0.031, 0.045, 0.04, 0.044, 0.044, 0.021, -0.014, 0.045, 0.033, 
0.027, 0.028, 0.031, 0.031, 0.028, 0.034, 0.033, 0.026, -0.031, 
0.062), Export_Canada = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, 69006.4, 68252.7, 71084.9, 81398, 87953, 
91380.1, 91063.9, 98629.8, 111216.4, 128405.9, 144369.9, 155892.6, 
167234.1, 173256, 198711.1, 230838.3, 216267.9, 209087.7, 221594.650307, 
256359.835924, 290384.293155, 302437.859257, 317056.762618, 339491.425363, 
226248.448986, 277636.732987, 315324.753291, 324263.012583, 332503.645324, 
349286.122826, 296305.080863, 277719.813481, 299065.421162, 318574.772746, 
318588.767408, 270025.523613, 357279.450281), Export_Mexico = c(NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 19131.7, 
17301.7, 20270.8, 23259.8, 27162.1, 30156.8, 31129.6, 35211.1, 
39917.5, 49493.7, 62100.4, 74297.2, 85937.6, 94629, 109720.5, 
135926.3, 131337.9, 134616, 138059.990668, 155901.520879, 170108.614084, 
198253.159036, 210713.966788, 215941.618934, 176654.372581, 229985.623006, 
262873.595958, 277593.639546, 280556.040242, 295729.962846, 296433.325024, 
293500.60666, 312666.740496, 343680.54051, 356093.584045, 323476.917991, 
382588.717029), Export_Guatemala = c(NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, 409, 601, 495.2, 433.5, 608.9, 
794.3, 899.2, 1081.3, 1194.2, 1282.8, 1526.8, 1678.5, 1990.1, 
2071.6, 2265.2, 2607.5, 2588.6, 2796.4, 2946.782207, 3153.978503, 
3137.382263, 3102.282088, 3026.095015, 3462.740635, 3147.541215, 
3522.648526, 4713.979911, 4491.426314, 4171.493471, 4217.973012, 
4120.741073, 3937.451948, 4014.464244, 4195.357225, 3986.419578, 
3842.648196, 4666.173656), `Export_El Salvador` = c(NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 395.6, 385.3, 283.7, 
283.9, 244.9, 237.6, 303, 383.8, 487.8, 609.2, 812.2, 975.4, 
1346.2, 1437.8, 1605, 1933, 1880.3, 1982.3, 2019.832291, 2052.247139, 
1988.765718, 1856.821932, 2043.503686, 2227.975732, 1821.80707, 
2205.710607, 2484.612208, 2587.56348, 2437.350911, 2397.754497, 
2531.668563, 2495.907382, 2463.853548, 2523.101498, 2478.149522, 
1921.530537, 2514.396324), Export_Honduras = c(NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 375.4, 432.7, 489, 440.3, 
460.5, 490.8, 556.8, 782, 914, 1097.6, 1441.2, 1795.4, 2322.2, 
2544.6, 2713.2, 3090.1, 3126.5, 3261.3, 3312.682869, 3639.989158, 
3749.243099, 3717.498062, 3912.104025, 4041.228449, 3319.283433, 
3932.993035, 4500.958709, 4647.809134, 4543.138877, 4645.940629, 
4759.552878, 4616.364852, 4574.859421, 4658.777082, 4790.5532, 
3840.973037, 5199.521293), `Export_Costa Rica` = c(NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 501.3, 640.7, 669.6, 
773.8, 962.4, 1005.2, 1153.6, 1411.4, 1541.3, 1646.9, 1843.2, 
1974.3, 2323.3, 2744.9, 3967.8, 3538.6, 2886.2, 3141.9, 3364.242303, 
3333.276244, 3415.279262, 3844.142053, 3941.540359, 3938.067781, 
5611.644252, 8697.340843, 10115.304799, 12046.09777, 11914.159665, 
9516.339311, 4488.909896, 4330.635445, 4563.521561, 4890.384397, 
5152.917823, 5349.270273, 6535.640662), Export_Panama = c(NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 410.6, 365.6, 
355.6, 263.9, 268, 233.9, 269.2, 253.9, 279.7, 322.4, 307.1, 
346.2, 367.2, 312.3, 364.7, 307.1, 290.7, 302.5, 301.428278, 
315.855793, 327.060069, 378.687851, 365.172576, 379.057193, 302.296683, 
380.982072, 389.380075, 540.342228, 448.745053, 431.685691, 408.375747, 
409.997556, 442.493651, 419.507037, 439.561874, 707.4923, 755.379873
), Export_Jamaica = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, 272.7, 299.3, 395, 443.5, 508.9, 568.9, 575.8, 
599.1, 719.6, 746.7, 846.9, 838.3, 738.1, 755, 678, 648.1, 460.5, 
396.4, 422.748801, 319.73713, 375.57236, 528.131242, 720.445231, 
728.687455, 467.581232, 327.66667, 566.089945, 507.205331, 414.493158, 
285.559719, 305.998096, 303.13925, 337.365931, 378.421046, 391.000452, 
383.677598, 505.752802), Export_Haiti = c(NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, 389.6, 375.3, 394.7, 382.5, 
374.3, 343, 284.2, 107, 154.1, 58.7, 129.9, 143.4, 188.3, 271.7, 
301, 296.9, 263.2, 255.2, 332.340309, 370.68072, 447.217315, 
496.11098, 487.767116, 450.082545, 552.090736, 550.910491, 742.179942, 
774.736792, 847.053529, 908.360463, 950.091535, 898.848191, 919.00342, 
990.113531, 1045.950259, 827.446659, 1102.74953), `Export_Dominican Republik` = c(NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 982.3, 1085.2, 
1162.8, 1409.7, 1645.7, 1751.8, 2007.5, 2372.5, 2671.7, 3090.5, 
3398.9, 3575, 4326.8, 4441.1, 4286.6, 4383.3, 4183.4, 4168.8, 
4455.230348, 4527.099908, 4603.684143, 4532.378534, 4215.643656, 
3977.827623, 3329.451899, 3671.724506, 4198.735888, 4370.378862, 
4261.021154, 4528.317254, 4667.606203, 4678.484257, 4743.483815, 
5302.21515, 5539.513493, 5159.349573, 6309.02836), Export_Colombia = c(NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1330.7, 1874.3, 
2232.4, 2160.9, 2555.3, 3167.5, 2736.3, 2837.4, 3031.7, 3171, 
3791, 4423.8, 4737.4, 4656.1, 6259, 6968, 5710.3, 5604.4, 6385.065623, 
7256.111634, 8849.380048, 9265.683816, 9433.58938, 13093.204502, 
11323.117375, 15659.297836, 23114.211762, 24621.667665, 21626.226647, 
18315.916716, 14078.802978, 13798.22597, 13552.160458, 13751.767203, 
14150.97464, 10779.986716, 13175.521534), Export_Venezuela = c(NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 6537.1, 5096.7, 
5578.9, 5157.4, 6770.7, 9479.4, 8178.5, 8181.1, 8139.8, 8371.1, 
9764, 13173, 13477.1, 9181.4, 11334.4, 18623.3, 15250.4, 15093.6, 
17136.094094, 24920.563843, 33978.134805, 37133.8064, 39909.62933, 
51423.62838, 28059.033911, 32707.38718, 43256.522079, 38723.837591, 
31997.529566, 30220.133632, 15564.364752, 10894.912267, 12344.266763, 
13194.111428, 1933.744473, 167.405606, 294.972942), Export_Ecuador = c(NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1836.5, 1464.6, 
1265.7, 1227.8, 1474.3, 1375.7, 1327.2, 1344, 1399.4, 1726.1, 
1939.7, 1958.1, 2054.9, 1752.2, 1821.2, 2237.9, 2009.5, 2143.4, 
2721.985419, 4283.399559, 5758.679346, 7093.850766, 6134.999496, 
9048.41096, 5272.566301, 7451.049426, 9622.290751, 9484.411908, 
11491.157685, 10869.500529, 7467.174553, 6058.623946, 6378.539039, 
6737.708134, 6952.525181, 5939.055896, 8156.139886), Export_Peru = c(NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1086.6, 802.9, 
768.5, 658.4, 814, 801.7, 775.8, 738.3, 753.9, 841.1, 1034.4, 
1261, 1772.4, 1975.3, 1928.4, 1995, 1843.9, 1939.3, 2408.723259, 
3701.553446, 5119.15577, 5880.38532, 5271.605833, 5812.452843, 
4223.312297, 5243.307323, 6605.022259, 6418.281945, 8126.732397, 
6079.27593, 5055.549626, 6253.193596, 7273.423515, 7892.300402, 
6139.459663, 5519.639426, 6882.518771), Export_Chile = c(NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 745.2, 820.1, 
980.9, 1181.3, 1292.2, 1312.5, 1302.1, 1388.1, 1462.1, 1820.4, 
1930.8, 2262.2, 2293.3, 2452.5, 2953.3, 3269, 3495.2, 3784.5, 
3705.438117, 4732.287954, 6664.333836, 9565.127122, 8998.792694, 
8195.971599, 5949.252719, 7017.465154, 9076.034955, 9366.566426, 
10384.68785, 9479.495972, 8776.814205, 8796.901501, 10550.262184, 
11380.015842, 10393.74412, 10100.015886, 15061.874139), Export_Brazil = c(NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 7526.2, 6812.9, 
7865.4, 9294.3, 8410, 7898.1, 6716.7, 7609.1, 7478.8, 8682.5, 
8832.9, 8773.1, 9625.3, 10101.8, 11313.9, 13852.6, 14466.3, 15780.5, 
17910.335999, 21159.920924, 24435.519379, 26366.72536, 25644.187123, 
30452.944177, 20069.606594, 23958.063867, 31736.521991, 32123.378693, 
27541.199001, 30020.937116, 27473.620048, 26043.371004, 29461.613229, 
31203.047235, 30934.128999, 23363.615837, 31237.243186), Export_Paraguay = c(NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 23.6, 29.6, 
21.9, 35.3, 44.4, 50.4, 43.1, 35.3, 49.8, 80, 55, 42.4, 40.5, 
33.6, 48.3, 40.8, 32.6, 43.7, 53.277006, 58.582946, 51.645596, 
58.038901, 67.969086, 78.403962, 56.405447, 62.138779, 109.957418, 
196.931657, 276.967267, 196.379113, 162.904233, 149.076993, 125.073924, 
130.775331, 161.680943, 149.754576, 187.750132), Export_Uruguay = c(NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 556.6, 472.4, 
343.8, 270.6, 219, 205.9, 237.3, 265.8, 265.5, 167.8, 167.2, 
260.5, 229, 255.8, 198.7, 313.1, 227.7, 193.2, 255.730783, 579.993554, 
732.311644, 512.307227, 491.922168, 244.310589, 239.22559, 235.379696, 
291.454584, 357.532717, 423.082838, 456.868124, 604.765257, 534.04047, 
584.021678, 507.913526, 519.02417, 550.288448, 633.957203), Export_Argentina = c(NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1069.3, 855.5, 
1079.7, 1435.7, 1390.7, 1511.4, 1286.9, 1256.4, 1205.7, 1725.4, 
1760.8, 2279.2, 2228.1, 2230.9, 2598.4, 3099.5, 3013.4, 3187.3, 
3169.783857, 3745.506076, 4583.613305, 3978.98852, 4486.947482, 
5822.06418, 3890.111947, 3802.754172, 4502.877176, 4350.419991, 
4642.343655, 4246.388507, 3950.916648, 4653.737054, 4785.065651, 
4832.567958, 4930.555341, 4194.541239, 5121.495178), Export_Iceland = c(NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 247.8, 237.9, 
285.9, 187.9, 208.2, 163.4, 208.8, 164.7, 232.6, 248.7, 232.8, 
236, 230.7, 267.9, 303.6, 259.9, 232.4, 297, 281.768396, 273.750028, 
268.97508, 227.534467, 205.735006, 240.697731, 179.146449, 201.249833, 
215.74448, 283.735298, 291.301637, 300.304111, 316.534176, 371.036575, 
412.226711, 429.580763, 483.002484, 424.293669, 579.958702), 
    Export_Sweden = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
    NA, NA, NA, NA, 4123.7, 4419.5, 4758.4, 4984.8, 4891.6, 4937.3, 
    4524.5, 4716, 4533.7, 5040.9, 6256.4, 7152.8, 7299, 7848.1, 
    8102.5, 9596.9, 8908.6, 9216.4, 11119.184284, 12683.043045, 
    13820.977243, 13870.39886, 13023.904257, 12498.322694, 8185.507543, 
    10497.387347, 11489.582168, 10221.780983, 9173.837772, 10360.433927, 
    9910.151086, 9698.970348, 10749.451943, 10980.332997, 12124.935364, 
    12279.049934, 14825.229896), Export_Norway = c(NA, NA, NA, 
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1164.3, 1078.9, 
    1404.2, 1446.1, 1991.1, 1830, 1623.8, 1968.6, 1957.4, 2353.4, 
    3086.7, 3992.5, 3752.1, 2871.5, 4042.4, 5706.2, 5202.8, 5842.5, 
    5231.944277, 6508.711984, 6776.30892, 7085.306498, 7317.730173, 
    7315.13931, 5688.164538, 6950.265655, 8304.891628, 6566.005881, 
    5510.574445, 5366.006902, 4762.63131, 4407.3814, 5050.71438, 
    6781.154293, 6523.579555, 3943.014676, 6724.035029), Export_Finland = c(NA, 
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 895.2, 
    907.5, 999.5, 1202.6, 1370.4, 1262.5, 1084.6, 1184.9, 1608.3, 
    1800.5, 2269.9, 2388.9, 2391.6, 2595.7, 2907.6, 3250.9, 3393.8, 
    3447.1, 3602.296175, 3886.927493, 4341.679942, 4973.872821, 
    5266.161796, 5903.287905, 3985.288638, 3883.667052, 4435.63551, 
    5109.658449, 4653.190718, 5035.156921, 4510.434993, 4572.809537, 
    5892.785485, 7161.470625, 6384.771075, 4926.079774, 6763.975492
    ), Export_Denmark = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, 
    NA, NA, NA, NA, NA, 1664.4, 1757.2, 1778.4, 1664.4, 1535.1, 
    1677.7, 1661.4, 1666.9, 1664, 2121.6, 1944.9, 2141.6, 2137.8, 
    2394.9, 2818.8, 2965, 3406.6, 3237.3, 3708.39792, 3876.289205, 
    5144.20165, 5540.10062, 6064.385266, 6446.407831, 5510.513708, 
    6011.905061, 6760.153719, 6777.117904, 6494.360492, 7534.43307, 
    7760.069063, 7942.747758, 7691.019198, 8853.611878, 11007.045752, 
    11626.053697, 12107.21188), Export_UK = c(NA, NA, NA, NA, 
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 14937.2, 15395.9, 
    17341.2, 17976.5, 18319.1, 20188.3, 18412.9, 20093.2, 21730.3, 
    25057.4, 26929.7, 28978.7, 32659.2, 34838.3, 39237.3, 43345.1, 
    41368.7, 40744.9, 42794.957453, 46273.823372, 51032.621105, 
    53513.018484, 56857.542425, 58587.383031, 47479.890559, 49805.396025, 
    51262.501564, 55005.810676, 52741.231492, 54689.496275, 58057.103977, 
    54266.364199, 53279.057647, 60740.348403, 63272.043613, 50279.812747, 
    56266.021534), Export_Netherlands = c(NA, NA, NA, NA, NA, 
    NA, NA, NA, NA, NA, NA, NA, NA, NA, 4081.3, 4065.9, 3963.5, 
    4559, 4809.6, 4951.6, 4811.2, 5300.5, 5443.1, 6006.8, 6404.9, 
    6583.1, 7292.9, 7599.3, 8474.9, 9670.7, 9515.2, 9848.4, 10952.826096, 
    12450.529457, 14862.041511, 17342.261801, 18403.138184, 21122.912325, 
    16098.460471, 19055.457711, 23454.922504, 22259.597393, 19234.449656, 
    20899.069308, 16843.991579, 16109.980686, 17806.548523, 24510.833933, 
    29672.634486, 27381.047922, 35155.212511), Export_Belgium = c(NA, 
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 3355.2, 
    4038.5, 4167.8, 4328.4, 4337.3, 4375.1, 3929.5, 4476.2, 5149.2, 
    6354.2, 6053.9, 6775.6, 7911.9, 8440.1, 9196.2, 9929.4, 10158.4, 
    9806.7, 10140.820332, 12446.22916, 13022.90274, 14405.413443, 
    15281.17993, 17308.06397, 13825.678762, 15551.88055, 17431.303419, 
    17367.885511, 19010.319465, 20962.038182, 19486.832284, 17012.127251, 
    14979.384464, 17171.563356, 20121.86534, 21028.71878, 21469.950432
    ), Export_France = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, 
    NA, NA, NA, NA, NA, 9482, 10128.6, 10730.3, 12508.7, 13013.4, 
    13153.4, 13333, 14797.2, 15279.1, 16699.1, 17209.4, 18645.7, 
    20636.3, 24016, 25708.6, 29800.1, 30408, 28240.1, 29219.279722, 
    31605.738585, 33842.057513, 37039.631721, 41552.711122, 44049.335702, 
    34236.042957, 38355.493121, 40049.048317, 41646.128474, 45706.31628, 
    47105.368636, 47808.780079, 46708.643871, 48909.603946, 52493.782487, 
    57595.884794, 42970.381349, 50144.20162), Export_Germany = c(NA, 
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 20239.2, 
    25123.8, 27069.4, 26362, 24832.3, 28162, 26136.4, 28820.4, 
    28562, 31744.3, 36843.9, 38944.9, 43121.4, 49841.9, 55228.3, 
    58512.9, 59076.6, 62505.7, 68112.691842, 77265.574324, 84750.871375, 
    89082.049315, 94164.095641, 97496.573724, 71498.154314, 82450.411862, 
    98684.337899, 109225.772833, 114341.899964, 124181.984009, 
    124887.804524, 114092.493567, 117539.152399, 125714.427228, 
    127454.861626, 114896.827026, 134846.997091), Export_Austria = c(NA, 
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 833.7, 
    864.2, 929, 1074.4, 1135.3, 1318.5, 1263.5, 1306.7, 1410.9, 
    1749.8, 1963.2, 2200.2, 2368.4, 2561, 2909.1, 3226.6, 3968.6, 
    3815.2, 4492.253736, 5798.38279, 6102.944725, 8304.346256, 
    10668.880036, 8457.019639, 6378.561635, 6835.322637, 9482.732806, 
    9449.154334, 9780.427617, 10828.029924, 11312.473913, 10865.610456, 
    11725.523872, 13571.609243, 13164.507275, 11616.673079, 15138.337361
    ), Export_Hungary = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, 
    NA, NA, NA, NA, NA, 218.3, 225.1, 278.9, 293, 328.2, 347.6, 
    367, 347, 400.5, 470.4, 547, 676, 1078.9, 1566.6, 1892.6, 
    2715.1, 2964.6, 2637.5, 2700.652835, 2572.607225, 2561.172978, 
    2584.325846, 2827.524521, 3102.759935, 2223.435499, 2491.186229, 
    2948.676937, 3201.285721, 3767.870817, 5331.43153, 5719.428687, 
    5335.154089, 5077.540489, 5061.840779, 5295.355647, 5277.495343, 
    7054.27638), Export_Switzerland = c(NA, NA, NA, NA, NA, NA, 
    NA, NA, NA, NA, NA, NA, NA, NA, 3476.1, 5252.8, 4249.5, 4610.9, 
    4714.4, 5587, 5575.9, 5644.6, 5973, 6373, 7593.9, 7792.4, 
    8405.1, 8690.1, 9538.6, 10159.9, 9669.6, 9382.1, 10685.253629, 
    11627.729462, 12999.881084, 14229.862998, 14760.206008, 17781.886332, 
    16052.92445, 19136.758378, 24362.463267, 25672.465676, 28275.333645, 
    31321.989634, 31430.956228, 36340.933007, 35972.733877, 41083.99211, 
    44625.373073, 74928.777998, 63515.377687), Export_Poland = c(NA, 
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 220.2, 
    232.5, 296.1, 376.7, 387.1, 408.4, 356.7, 374.8, 453.8, 651.2, 
    663.6, 627.9, 695.6, 783.8, 816.2, 1041.2, 952.6, 1108.4, 
    1323.730509, 1821.48468, 1948.58625, 2252.580826, 2226.011699, 
    2586.896169, 2038.060569, 2963.740384, 4378.519315, 4621.448472, 
    4885.379184, 5214.173362, 5611.300874, 5950.081247, 7103.032231, 
    8002.215353, 8366.120917, 8600.974396, 9744.786525), Export_Spain = c(NA, 
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 2515.2, 
    2702, 2838.6, 3203.6, 3316.9, 3311.2, 2848, 3001.9, 2992, 
    3555, 3879.7, 4279.7, 4605.4, 4780.4, 5059.3, 5713.3, 5197.3, 
    5733.1, 6676.664019, 7350.158929, 8614.64214, 9778.321333, 
    10498.117006, 11093.896785, 7856.650625, 8553.600677, 11017.979491, 
    11767.974982, 11667.754249, 14458.806909, 14132.759939, 13421.198293, 
    15657.760706, 17211.237723, 16761.177608, 15297.276912, 18567.115076
    ), Export_Portugal = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, 
    NA, NA, NA, NA, NA, 546, 551.9, 664.3, 692.6, 799.6, 831.8, 
    695.3, 664.3, 785.2, 898.5, 1056.7, 1016.4, 1138, 1265.3, 
    1355.7, 1578.6, 1555.3, 1672.8, 1967.015689, 2243.256871, 
    2328.674933, 3060.090808, 3049.347631, 2451.4361, 1577.117726, 
    2141.53292, 2582.511678, 2609.550991, 2831.107431, 3226.409015, 
    3270.540198, 3204.378247, 3502.698378, 3878.357407, 3887.929099, 
    3775.894714, 4944.015953), Export_Italy = c(NA, NA, NA, NA, 
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 9673.8, 10607.4, 
    11039.5, 11576, 11933.1, 12751.5, 11764.2, 12314.4, 13215.5, 
    14802.2, 16348.4, 18324.8, 19407.5, 20959.1, 22356.5, 25042.6, 
    23789.7, 24220.5, 25414.233532, 28097.274991, 31009.260076, 
    32655.070514, 35027.629526, 36134.975141, 26429.78824, 28513.642243, 
    33973.740824, 36964.764394, 38708.79904, 42377.879302, 44220.552948, 
    45272.000577, 49885.944602, 54677.406169, 57248.706451, 49448.298403, 
    60997.706657), Export_Greece = c(NA, NA, NA, NA, NA, NA, 
    NA, NA, NA, NA, NA, NA, NA, NA, 394.7, 394.4, 480.1, 528.1, 
    473.3, 508.7, 429.4, 369.7, 347.6, 455.3, 397.1, 505.9, 453.4, 
    466.6, 563, 591.6, 505.3, 546.1, 613.965426, 723.595185, 
    883.73016, 965.663603, 1191.92988, 998.93807, 840.548792, 
    797.874265, 865.444211, 986.934224, 954.238447, 1050.046634, 
    1356.52235, 1227.788166, 1257.068382, 1605.262434, 1511.874561, 
    1301.128875, 1677.236918), Export_Turkey = c(NA, NA, NA, 
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 601.9, 633.3, 
    821.2, 978.8, 1371.4, 1182.4, 1005.6, 1109.8, 1197.6, 1574.9, 
    1797.9, 1778.3, 2120.9, 2542.6, 2629.3, 3041.7, 3054.7, 3516, 
    3788.188533, 4933.808167, 5182.052179, 5359.037652, 4600.564845, 
    4641.877863, 3661.58671, 4207.151173, 5220.844682, 6294.133798, 
    6669.565173, 7412.926409, 7886.319743, 8035.051505, 9385.461354, 
    10298.779835, 10586.516085, 10971.213196, 15872.663745), 
    Export_Iran = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
    NA, NA, NA, 725.1, 568.9, 1667.5, 9, 8.6, 6.8, 230.7, 0.7, 
    0.1, 0.8, 0.2, 0, 0.1, 0, 2.4, 168.7, 143.5, 156.3, 161.254038, 
    151.586976, 174.457417, 157.240649, 173.133194, 104.144319, 
    64.646665, 94.506447, 1.005187, 2.11355, 2.208518, 0, 10.766314, 
    87.73502, 63.099116, 69.975536, 1.410667, 3.863444, 1.237957
    ), Export_Kuwait = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, 
    NA, NA, NA, NA, NA, 184, 266.8, 521.5, 464.1, 973.1, 569.2, 
    36, 281.3, 1818.5, 1457.5, 1335.5, 1651.1, 1816.4, 1266.1, 
    1439.3, 2781.2, 1990.5, 1940.3, 2276.927983, 3230.816478, 
    4334.781445, 3980.900848, 4118.456968, 7092.985034, 3782.559318, 
    5382.010083, 7808.733355, 13020.902287, 12636.911189, 11437.050349, 
    4684.780276, 3301.42292, 2925.889157, 2088.334766, 1418.102403, 
    714.143486, 1070.447645), `Export_Saudi Arabia` = c(NA, NA, 
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1907.1, 3611.6, 
    4433, 5620.3, 7157.1, 10020.8, 10900.2, 10371.4, 7707.8, 
    7688.1, 8376.6, 10467.3, 9365, 6241.3, 8253.5, 14364.8, 13272.2, 
    13149.9, 18068.614592, 20958.676619, 27192.642038, 31689.028037, 
    35625.98683, 54747.448525, 22053.149818, 31412.822978, 47476.336256, 
    55666.95084, 51806.698721, 47041.338853, 22083.194415, 16923.622262, 
    18867.747453, 24065.670185, 13403.765754, 8993.754483, 13717.488535
    ), Export_India = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
    NA, NA, NA, NA, 2294.7, 2283.2, 2528.4, 2939.5, 3314.4, 3196.8, 
    3192.4, 3779.7, 4553.6, 5309.6, 5726.3, 6169.5, 7322.5, 8237.2, 
    9070.8, 10686.6, 9737.3, 11818.4, 13055.290633, 15572.03644, 
    18804.169654, 21830.821397, 24073.264282, 25704.382575, 21165.965968, 
    29532.939005, 36154.495638, 40512.644038, 41809.988752, 45357.982213, 
    44782.656358, 46024.248727, 48549.442371, 54249.561527, 57878.981681, 
    51254.588173, 73307.578206), Export_Pakistan = c(NA, NA, 
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 273.9, 325.1, 
    404.5, 458.8, 522.7, 609.6, 662.3, 865.8, 897.3, 1011.6, 
    1197, 1265.6, 1442.2, 1691.8, 1740.7, 2166.8, 2249.5, 2305, 
    2531.157242, 2874.98797, 3253.181975, 3672.222686, 3577.641329, 
    3591.062421, 3162.815294, 3509.06732, 3832.115894, 3627.553133, 
    3688.503361, 3675.599106, 3701.030295, 3442.808763, 3573.509279, 
    3705.5512, 3920.233317, 3899.360122, 5281.776951), Export_Bangladesh = c(NA, 
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 196, 
    230, 369.8, 367.1, 428, 538.9, 523.8, 831, 886.4, 1080, 1257.2, 
    1343, 1679.4, 1846, 1918.1, 2417.5, 2358.9, 2134.1, 2073.871901, 
    2302.589719, 2693.035035, 3271.396005, 3432.080304, 3748.440438, 
    3698.952442, 4293.920187, 4877.104938, 4915.569502, 5351.935923, 
    5276.759511, 5990.466943, 5910.076118, 5686.125763, 6098.256338, 
    6671.01945, 6064.777735, 8292.69092), Export_Thailand = c(NA, 
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1428.3, 
    1747.3, 2220.2, 3209.8, 4379.5, 5288.6, 6122, 7528.9, 8541.6, 
    10305.8, 11348.1, 11336, 12601.4, 13436.4, 14330, 16385.4, 
    14727, 14792.9, 15178.49236, 17578.944669, 19889.755777, 
    22466.332985, 22754.659878, 23538.275396, 19082.487689, 22693.58028, 
    24831.572526, 26066.841763, 26169.602629, 27229.294785, 28622.17837, 
    29484.052274, 31108.472556, 31872.659599, 33442.622059, 37554.949461, 
    47360.942138), Export_Malaysia = c(NA, NA, NA, NA, NA, NA, 
    NA, NA, NA, NA, NA, NA, NA, NA, 2299.9, 2420.4, 2921, 3691.8, 
    4744, 5272, 6101.5, 8294.1, 10563, 13981.6, 17454.9, 17828.8, 
    18026.8, 19000, 21424.5, 25568.3, 22340.3, 24008.9, 25440.202859, 
    28178.866175, 33685.159566, 36533.140829, 32628.505447, 30736.075258, 
    23282.618764, 25900.949586, 25776.851224, 25934.755355, 27288.73502, 
    30563.787818, 33971.867415, 36607.397631, 37369.173174, 39342.133743, 
    40510.98159, 44098.168701, 56072.031142), Export_Singapore = c(NA, 
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 4259.9, 
    4725.1, 6201, 7973.3, 9002.8, 9800.6, 9956.6, 11312.6, 12798.2, 
    15357.7, 18560.4, 20343.1, 20074.6, 18355.8, 18191.3, 19178.3, 
    15000, 14802.3, 15137.746744, 15370.37944, 15110.089622, 
    17768.095532, 18393.659432, 15884.931018, 15704.899318, 17427.588477, 
    19115.895767, 20231.867784, 17842.859828, 16501.526179, 18272.022889, 
    17832.10584, 19367.390992, 26519.764788, 26395.855542, 30774.979991, 
    29609.462951), Export_Indonesia = c(NA, NA, NA, NA, NA, NA, 
    NA, NA, NA, NA, NA, NA, NA, NA, 4568.9, 3311.6, 3393.8, 3150.5, 
    3528.5, 3341, 3240.6, 4529.5, 5435.5, 6546.8, 7435.3, 8250, 
    9188.3, 9340.7, 9525.5, 10366.9, 10103.5, 9643.4, 9515.07129, 
    10810.516207, 12014.344185, 13424.717182, 14301.257157, 15799.137766, 
    12938.589076, 16478.339564, 19110.896131, 18002.185532, 18871.609478, 
    19389.820947, 19605.232082, 19184.01155, 20205.135079, 20824.53493, 
    20104.615181, 20198.16252, 27046.504696), Export_Philippines = c(NA, 
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 2145, 
    1972.2, 2263.8, 2666.4, 3067.9, 3383.9, 3471.4, 4354.9, 4893.5, 
    5719, 7006.5, 8161.4, 10444.9, 11947.3, 12352.9, 13934.6, 
    11325.5, 10979.8, 10059.031779, 9136.669506, 9250.433389, 
    9694.336645, 9408.192993, 8713.32677, 6794.098806, 7982.003448, 
    9144.85931, 9580.45138, 9268.689135, 10189.879702, 10231.603389, 
    10042.425048, 11622.710638, 12586.944243, 12661.699193, 11121.894329, 
    13993.816654), Export_China = c(NA, NA, NA, NA, NA, NA, NA, 
    NA, NA, NA, NA, NA, NA, NA, 3861.7, 4771, 6293.6, 8510.9, 
    11989.7, 15237.4, 18969.2, 25727.5, 31539.9, 38786.8, 45543.2, 
    51512.8, 62557.7, 71168.6, 81788.2, 100018.2, 102278.4, 125192.6, 
    152436.096898, 196682.033935, 243470.104795, 287774.352612, 
    321442.866934, 337772.627823, 296373.883488, 364952.633595, 
    399371.232631, 425619.082637, 440430.019592, 468474.894856, 
    483201.655364, 462419.991603, 505165.098057, 538514.158526, 
    449110.676707, 432548.018651, 504286.202159), `Export_South Korea` = c(NA, 
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 10013.3, 
    12729.2, 16986.8, 20105.1, 19736.5, 18485.4, 17018.3, 16682.3, 
    17118.1, 19629.3, 24184, 22654.9, 23173.2, 23941.7, 31178.4, 
    40307.7, 35181.5, 35571.7, 37229.404155, 46167.937074, 43781.441056, 
    45803.586952, 47562.311363, 48069.078711, 39215.588565, 48875.170948, 
    56661.359461, 58898.926491, 62370.452198, 69676.890586, 71775.318803, 
    69886.778026, 71416.537956, 74238.869911, 77476.28859, 76010.953517, 
    95096.451822), Export_Japan = c(NA, NA, NA, NA, NA, NA, NA, 
    NA, NA, NA, NA, NA, NA, NA, 68782.9, 81911, 84574.9, 89518.9, 
    93552.5, 89684, 91510.6, 97413.7, 107246.4, 119155.8, 123479.3, 
    115187.1, 121663.3, 121845.1, 130863.8, 146479.4, 126473.1, 
    121428.6, 118036.645528, 129805.198658, 138003.696155, 148180.775579, 
    145463.342556, 139262.197032, 95803.683368, 120552.145178, 
    128927.889476, 146431.693012, 138575.341868, 134504.542819, 
    131445.490188, 132000.449556, 136411.34157, 142228.28456, 
    143590.954959, 119506.50017, 134832.537575), Export_Australia = c(NA, 
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 2836.3, 
    2627.7, 3005.5, 3541.4, 3872.9, 4446.6, 3988, 3687.6, 3297.3, 
    3202.1, 3323, 3868.9, 4602.3, 5387, 5280.1, 6438, 6477.8, 
    6478.8, 6413.662958, 7545.500435, 7342.17895, 8204.002398, 
    8615.018556, 10588.812772, 8011.502299, 8582.910903, 10242.853389, 
    9566.806259, 9272.561327, 10697.322349, 10885.57602, 9507.82154, 
    10049.318045, 10058.651721, 10823.847416, 14416.386255, 12451.663952
    ), Export_Algeria = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, 
    NA, NA, NA, NA, NA, 2333, 1831.4, 1998.8, 1814.3, 1829.5, 
    2625.5, 2102.6, 1586.1, 1583, 1526.9, 1749.5, 2125.7, 2439.5, 
    1638.1, 1824.2, 2724.2, 2702, 2360.2, 4748.410137, 7409.533543, 
    10446.437854, 15455.929235, 17816.053966, 19354.781015, 10717.809142, 
    14517.955926, 14609.285365, 9993.334569, 4830.871545, 4628.902129, 
    3371.547769, 3227.920172, 3810.521868, 4618.350005, 2479.529457, 
    488.160313, 1888.022545), Export_Egypt = c(NA, NA, NA, NA, 
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 79.1, 111.4, 464.9, 
    220.4, 226.4, 398, 205.8, 434.3, 612.9, 548.8, 606.3, 680.4, 
    657.7, 660.5, 617.6, 887.8, 882.3, 1355.9, 1143.042341, 1283.838703, 
    2091.236887, 2395.831868, 2376.708563, 2370.437872, 2057.71362, 
    2238.217595, 2058.680312, 3000.102332, 1614.573961, 1411.081466, 
    1405.849543, 1493.070585, 1637.038784, 2479.205406, 3153.825311, 
    2179.724583, 3309.099503), Export_Nigeria = c(NA, NA, NA, 
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 3001.9, 2530.3, 
    3573.5, 3278.6, 5283.9, 5982.1, 5168, 5102.4, 5301.4, 4429.9, 
    4930.5, 5978.3, 6349.4, 4194, 4385.1, 10537.6, 8774.9, 5945.3, 
    10393.591566, 16248.524885, 24239.356731, 27863.119324, 32770.23223, 
    38068.007014, 19128.17939, 30515.94985, 33854.186372, 19014.224369, 
    11723.857816, 3839.515295, 1915.81516, 4172.170788, 7050.16659, 
    5616.098665, 4609.511216, 1484.712995, 3444.170794), Export_Gabon = c(NA, 
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 501.9, 
    207.3, 357.9, 173.5, 436.8, 701.1, 711.5, 921, 961.1, 1134, 
    1463.9, 1983.5, 2202.2, 1258.9, 1543.2, 2196.5, 1659.8, 1587.4, 
    1969.523773, 2466.704034, 2815.602273, 1361.2083, 2181.807539, 
    2278.515032, 1230.680274, 2211.988341, 4566.651306, 1885.875183, 
    1112.280961, 798.012548, 337.024529, 107.345057, 198.88047, 
    288.15134, 121.122071, 76.073357, 114.795844), `Export_South Africa` = c(NA, 
    NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 2070.9, 
    2364.3, 1345.4, 1512.9, 1531, 1697.4, 1727.9, 1726.6, 1844.8, 
    2030.7, 2208, 2323.3, 2510.1, 3049, 3194.4, 4210, 4432.5, 
    4034.1, 4624.410084, 5944.776834, 5885.639948, 7500.754236, 
    9054.116703, 9948.021279, 5878.856481, 8220.181819, 9486.919792, 
    8672.332572, 8465.226229, 8325.573295, 7323.02555, 6784.318939, 
    7735.223232, 8465.348965, 7794.517648, 11360.974479, 15736.920995
    ), `Partij Affiliatie` = c("Red", "Red", "Red", "Red", "Red", 
    "Red", "Blue", "Blue", "Blue", "Blue", "Red", "Red", "Red", 
    "Red", "Red", "Red", "Red", "Red", "Red", "Red", "Red", "Red", 
    "Blue", "Blue", "Blue", "Blue", "Blue", "Blue", "Blue", "Blue", 
    "Red", "Red", "Red", "Red", "Red", "Red", "Red", "Red", "Blue", 
    "Blue", "Blue", "Blue", "Blue", "Blue", "Blue", "Blue", "Red", 
    "Red", "Red", "Red", "Blue"), partij_dummy = c(0, 0, 0, 0, 
    0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 
    1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 
    1, 1, 1, 1, 0, 0, 0, 0, 1)), row.names = c(NA, -51L), class = c("tbl_df", 
"tbl", "data.frame"))

it's a lot of information, please let me know if I did anything wrong or if you need more!
Thanks for helping tho!

1 Like

Well I would like the dependent variable to be the effect on Export to the US. But i would like to see the effect for all countries and not just for every country separate, like the overall effect.

Thanks, Thom — this is very helpful. In the output, what part tells you something is being calculated for each country individually, rather than all countries together?

Thank you.

Because when I execute the codes i can only use one country at a time as the dependent variable, or the column 'Export_Totaal' (which is like the total imput of the US which I added because i couldn't figure out how to code it using the countries).

2 Likes

Try

df <- Alles_Totaal_3_ |> pivot_longer(cols = Export_Canada:`Export_South Africa`,values_to = "exports_to")
1 Like

Thanks!! I think this works!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.